Skip to content

Commit

Permalink
FlatConTypes() #232
Browse files Browse the repository at this point in the history
Nicer flat constraint names
  • Loading branch information
glebbelov committed Mar 25, 2024
1 parent 343bced commit 8dc475f
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 3 deletions.
75 changes: 75 additions & 0 deletions support/modelexplore/scripts/python/con_types.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# This Python file uses the following encoding: utf-8

# if __name__ == "__main__":
# pass

def FlatConTypes():
res = {
'_abs': 'AbsConstraint',
'_acos': 'AcosConstraint',
'_acosh': 'AcoshConstraint',
'_alldiff': 'AllDiffConstraint',
'_and': 'AndConstraint',
'_asin': 'AsinConstraint',
'_asinh': 'AsinhConstraint',
'_atan': 'AtanConstraint',
'_atanh': 'AtanhConstraint',
'_compl': 'ComplementarityLinear',
'_complquad': 'ComplementarityQuadratic',
'_condlineq': 'CondLinConEQ',
'_condlinge': 'CondLinConGE',
'_condlingt': 'CondLinConGT',
'_condlinle': 'CondLinConLE',
'_condlinlt': 'CondLinConLT',
'_condquadeq': 'CondQuadConEQ',
'_condquadge': 'CondQuadConGE',
'_condquadgt': 'CondQuadConGT',
'_condquadle': 'CondQuadConLE',
'_condquadlt': 'CondQuadConLT',
'_cos': 'CosConstraint',
'_cosh': 'CoshConstraint',
'_count': 'CountConstraint',
'_div': 'DivConstraint',
'_expa': 'ExpAConstraint',
'_exp': 'ExpConstraint',
'_expcone': 'ExponentialConeConstraint',
'_geomcone': 'GeometricConeConstraint',
'_ifthen': 'IfThenConstraint',
'_impl': 'ImplicationConstraint',
'_indeq': 'IndicatorConstraintLinEQ',
'_indge': 'IndicatorConstraintLinGE',
'_indle': 'IndicatorConstraintLinLE',
'_indquadeq': 'IndicatorConstraintQuadEQ',
'_indquadge': 'IndicatorConstraintQuadGE',
'_indquadle': 'IndicatorConstraintQuadLE',
'_lineq': 'LinConEQ',
'_linge': 'LinConGE',
'_linle': 'LinConLE',
'_linrange': 'LinConRange',
'_linfunccon': 'LinearFunctionalConstraint',
'_loga': 'LogAConstraint',
'_log': 'LogConstraint',
'_max': 'MaxConstraint',
'_min': 'MinConstraint',
'_not': 'NotConstraint',
'_numberofconst': 'NumberofConstConstraint',
'_numberofvar': 'NumberofVarConstraint',
'_or': 'OrConstraint',
'_pl': 'PLConstraint',
'_pow': 'PowConstraint',
'_powercone': 'PowerConeConstraint',
'_quadeq': 'QuadConEQ',
'_quadge': 'QuadConGE',
'_quadle': 'QuadConLE',
'_quadrange': 'QuadConRange',
'_quadcone': 'QuadraticConeConstraint',
'_quadfunccon': 'QuadraticFunctionalConstraint',
'_rotatedquadcone': 'RotatedQuadraticConeConstraint',
'_sos1': 'SOS1Constraint',
'_sos2': 'SOS2Constraint',
'_sin': 'SinConstraint',
'_sinh': 'SinhConstraint',
'_tan': 'TanConstraint',
'_tanh': 'TanhConstraint',
'_uenc': 'UnaryEncodingConstraint' }
return res
6 changes: 3 additions & 3 deletions support/modelexplore/scripts/python/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
# if __name__ == "__main__":
# pass

import streamlit as st

from scripts.python.graph import DiGraph
from scripts.python.con_types import FlatConTypes

class Model:
"""
Expand Down Expand Up @@ -118,8 +117,9 @@ def MatchFinalModel(self, keyw):
result = {}
result["Variables"] = self._matchRecords(self._vars, keyw)
result["Objectives"] = self._matchRecords(self._objs, keyw)
ctypes = FlatConTypes()
for ct, cv in sorted(self._cons_Flat.items()):
result["Constraints '" + ct + "'"] \
result["Constraints '" + ctypes[ct] + "'"] \
= self._matchRecords(self._cons_Flat[ct], keyw)
return result

Expand Down

0 comments on commit 8dc475f

Please sign in to comment.