Skip to content

Commit

Permalink
ModelExplorer: only final flat cons #232
Browse files Browse the repository at this point in the history
  • Loading branch information
glebbelov committed Mar 20, 2024
1 parent bcf1306 commit 480085a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
9 changes: 6 additions & 3 deletions include/mp/flat/constr_keeper.h
Original file line number Diff line number Diff line change
Expand Up @@ -930,7 +930,8 @@ class ConstraintKeeper final
/// This is called in the end,
/// so printing the readable form.
void ExportConStatus(int i_con, const Container& cnt,
const std::vector<std::string>* pvnam) {
const std::vector<std::string>* pvnam,
bool add2final) {
if (GetLogger()) {
fmt::MemoryWriter wrt;
{
Expand All @@ -948,6 +949,7 @@ class ConstraintKeeper final
jw["depth"] = cnt.GetDepth();
jw["unused"] = (int)cnt.IsUnused();
jw["bridged"] = (int)cnt.IsBridged();
jw["final"] = (int)add2final;
}
wrt.write("\n"); // EOL
GetLogger()->Append(wrt);
Expand Down Expand Up @@ -1057,7 +1059,8 @@ class ConstraintKeeper final
int con_index=0;
auto con_group = GetConstraintGroup(be);
for (const auto& cont: cons_) {
if (!cont.IsBridged()) {
bool adding = !cont.IsBridged();
if (adding) {
static_cast<Backend&>(be).AddConstraint(cont.con_);
GetConverter().GetCopyLink().
AddEntry({
Expand All @@ -1066,7 +1069,7 @@ class ConstraintKeeper final
GetConValues()(con_group).Add()
});
}
ExportConStatus(con_index, cont, pvnam);
ExportConStatus(con_index, cont, pvnam, adding);
++con_index; // increment index
}
}
Expand Down
21 changes: 11 additions & 10 deletions support/modelexplore/scripts/python/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,15 @@ def _matchRecords(self, cnt, keyw, keyNeed1=None):
if cnt is None:
return result
for i in cnt:
pr = str(i) ## TODO printed form
if "printed" in i:
pr = i["printed"]
assert len(pr)
if ';'!=pr[-1]:
pr = pr + ';'
if (""==keyw or keyw in pr) \
and (keyNeed1==None \
or (keyNeed1 in i and 1==i[keyNeed1])):
result = result + " \n" + pr ## Markdown: 2x spaces + EOL
if "final" not in i or 1==i["final"]:
pr = str(i) ## TODO printed form
if "printed" in i:
pr = i["printed"]
assert len(pr)
if ';'!=pr[-1]:
pr = pr + ';'
if (""==keyw or keyw in pr) \
and (keyNeed1==None \
or (keyNeed1 in i and 1==i[keyNeed1])):
result = result + " \n" + pr ## Markdown: 2x spaces + EOL
return result

0 comments on commit 480085a

Please sign in to comment.