From bc13236cf184315d54fcb8b6e9f96022998afd3a Mon Sep 17 00:00:00 2001 From: Gleb Belov Date: Wed, 20 Mar 2024 12:26:46 +1100 Subject: [PATCH] ModelExplorer: NL nonlin/lin/logical cons #232 --- support/modelexplore/scripts/python/model.py | 35 +++++++++++--------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/support/modelexplore/scripts/python/model.py b/support/modelexplore/scripts/python/model.py index 2350b9bda..62880ca4d 100644 --- a/support/modelexplore/scripts/python/model.py +++ b/support/modelexplore/scripts/python/model.py @@ -21,8 +21,9 @@ def __init__(self): self._cons_NL_all = [] self._cons_NL = { ## NL + SOS "All" : [], - #"Linear" : [], - #"Logical": [], + "Nonlinear" : [], + "Linear" : [], + "Logical": [], "SOS": []} self._cons_Flat = {} self._cons_Flat_Group = {} @@ -43,11 +44,15 @@ def UpdateFlatObj(self, idx, data): def UpdateNLCon(self, type, idx, data): if "nonlin"==type: - self._updateNodeData(self._cons_NL["All"], idx, data) + self._updateNodeData(self._cons_NL["Nonlinear"], + len(self._cons_NL["Nonlinear"]), ## these just 1x + data) elif "lin"==type: - self._updateNodeData(self._cons_NL["All"], idx, data) + self._updateNodeData(self._cons_NL["Linear"], + len(self._cons_NL["Linear"]), data) else: # "logical"==type: - self._updateNodeData(self._cons_NL["All"], idx, data) + self._updateNodeData(self._cons_NL["Logical"], + len(self._cons_NL["Logical"]), data) def UpdateFlatConGroup(self, type, data): self._cons_Flat_Group[type] = data @@ -81,16 +86,16 @@ def MatchOrigModel(self, keyw): result["NL Variables"] = self._matchRecords(self._vars, keyw, "is_from_nl") result["NL Defined Variables"] = self._matchRecords(self._dvars, keyw) result["NL Objectives"] = self._matchRecords(self._objs_NL, keyw) - result["NL Constraints"] \ - = self._matchRecords(self._cons_NL.get("All"), keyw) - #result["NL Nonlinear Constraints"] \ - # = self._matchRecords(self._cons_NL.get("Nonlinear"), keyw) - #result["NL Linear Constraints"] \ - # = self._matchRecords(self._cons_NL.get("Linear"), keyw) - #result["NL Logical Constraints"] \ - # = self._matchRecords(self._cons_NL.get("Logical"), keyw) - #result["NL SOS Constraints"] \ - # = self._matchRecords(self._cons_NL.get("SOS"), keyw) +# result["NL Constraints"] \ +# = self._matchRecords(self._cons_NL.get("All"), keyw) + result["NL Nonlinear Constraints"] \ + = self._matchRecords(self._cons_NL.get("Nonlinear"), keyw) + result["NL Linear Constraints"] \ + = self._matchRecords(self._cons_NL.get("Linear"), keyw) + result["NL Logical Constraints"] \ + = self._matchRecords(self._cons_NL.get("Logical"), keyw) + result["NL SOS Constraints"] \ + = self._matchRecords(self._cons_NL.get("SOS"), keyw) return result # Match keyword to the final model