Skip to content

Commit

Permalink
Slight refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
SanPen committed Nov 17, 2023
1 parent b984320 commit 2102368
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 49 deletions.
73 changes: 29 additions & 44 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 3 additions & 5 deletions src/GridCalEngine/Utils/MIP/ortools_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,14 +272,12 @@ def get_value(self, x: Union[float, int, LpVar, LpExp, LpCst, LpCstBounded]) ->
"""
Get the value of a variable stored in a numpy array of objects
:param x: solver object (it may be a LP var or a number)
:return: result or previous numeric value
:return: result or zero
"""
if isinstance(x, LpVar):
val = self.solver.value(x)
elif isinstance(x, LpExp):
val = self.solver.value(x)
elif isinstance(x, LpCst):
val = self.solver.dual_value(x)
elif isinstance(x, LpCstBounded):
val = self.solver.value(x.expression)
elif isinstance(x, float) or isinstance(x, int):
Expand All @@ -294,9 +292,9 @@ def get_value(self, x: Union[float, int, LpVar, LpExp, LpCst, LpCstBounded]) ->

def get_dual_value(self, x: LpCst) -> float:
"""
Get the value of a variable stored in a numpy array of objects
Get the dual value of a variable stored in a numpy array of objects
:param x: constraint
:return: result or previous numeric value
:return: result or zero
"""
if isinstance(x, LpCst):
val = self.solver.dual_value(x)
Expand Down

0 comments on commit 2102368

Please sign in to comment.