From 480085add279b6683ef8d383b59fdaca6acdc4d3 Mon Sep 17 00:00:00 2001 From: Gleb Belov Date: Wed, 20 Mar 2024 13:54:25 +1100 Subject: [PATCH] ModelExplorer: only final flat cons #232 --- include/mp/flat/constr_keeper.h | 9 ++++++--- support/modelexplore/scripts/python/model.py | 21 ++++++++++---------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/include/mp/flat/constr_keeper.h b/include/mp/flat/constr_keeper.h index 28393b2ee..d299e4050 100644 --- a/include/mp/flat/constr_keeper.h +++ b/include/mp/flat/constr_keeper.h @@ -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* pvnam) { + const std::vector* pvnam, + bool add2final) { if (GetLogger()) { fmt::MemoryWriter wrt; { @@ -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); @@ -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(be).AddConstraint(cont.con_); GetConverter().GetCopyLink(). AddEntry({ @@ -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 } } diff --git a/support/modelexplore/scripts/python/model.py b/support/modelexplore/scripts/python/model.py index 225fe42a3..15ce9ed77 100644 --- a/support/modelexplore/scripts/python/model.py +++ b/support/modelexplore/scripts/python/model.py @@ -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