Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def x(self) -> float:
"""Value of this variable in the solution."""
if self.__model.status == OptimizationStatus.LOADED:
raise SolutionNotAvailable('Model was not optimized, \
solution not available.')
elif (self.__model.status == OptimizationStatus.INFEASIBLE
or self.__model.status == OptimizationStatus.CUTOFF):
raise SolutionNotAvailable('Infeasible __model, \
solution not available.')
elif self.__model.status == OptimizationStatus.UNBOUNDED:
raise SolutionNotAvailable('Unbounded __model, solution not \
available.')
elif self.__model.status == OptimizationStatus.NO_SOLUTION_FOUND:
raise SolutionNotAvailable('Solution not found \
during optimization.')
return self.__model.solver.var_get_x(self)
def xi(self, i: int) -> float:
"""Value for this variable in the :math:`i`-th solution from
the solution pool."""
if self.__model.status == OptimizationStatus.LOADED:
raise SolutionNotAvailable('Model was not optimized, \
solution not available.')
elif (self.__model.status == OptimizationStatus.INFEASIBLE or
self.__model.status == OptimizationStatus.CUTOFF):
raise SolutionNotAvailable('Infeasible __model, \
solution not available.')
elif self.__model.status == OptimizationStatus.UNBOUNDED:
raise SolutionNotAvailable('Unbounded __model, \
solution not available.')
elif self.__model.status == OptimizationStatus.NO_SOLUTION_FOUND:
raise SolutionNotAvailable('Solution not found \
during optimization.')
return self.__model.solver.var_get_xi(self, i)
def xi(self, i: int) -> float:
"""Value for this variable in the :math:`i`-th solution from
the solution pool."""
if self.__model.status == OptimizationStatus.LOADED:
raise SolutionNotAvailable('Model was not optimized, \
solution not available.')
elif (self.__model.status == OptimizationStatus.INFEASIBLE or
self.__model.status == OptimizationStatus.CUTOFF):
raise SolutionNotAvailable('Infeasible __model, \
solution not available.')
elif self.__model.status == OptimizationStatus.UNBOUNDED:
raise SolutionNotAvailable('Unbounded __model, \
solution not available.')
elif self.__model.status == OptimizationStatus.NO_SOLUTION_FOUND:
raise SolutionNotAvailable('Solution not found \
during optimization.')
return self.__model.solver.var_get_xi(self, i)
def x(self) -> float:
"""Value of this variable in the solution."""
if self.__model.status == OptimizationStatus.LOADED:
raise SolutionNotAvailable('Model was not optimized, \
solution not available.')
elif (self.__model.status == OptimizationStatus.INFEASIBLE
or self.__model.status == OptimizationStatus.CUTOFF):
raise SolutionNotAvailable('Infeasible __model, \
solution not available.')
elif self.__model.status == OptimizationStatus.UNBOUNDED:
raise SolutionNotAvailable('Unbounded __model, solution not \
available.')
elif self.__model.status == OptimizationStatus.NO_SOLUTION_FOUND:
raise SolutionNotAvailable('Solution not found \
during optimization.')
return self.__model.solver.var_get_x(self)
def x(self) -> float:
"""Value of this variable in the solution."""
if self.__model.status == OptimizationStatus.LOADED:
raise SolutionNotAvailable('Model was not optimized, \
solution not available.')
elif (self.__model.status == OptimizationStatus.INFEASIBLE
or self.__model.status == OptimizationStatus.CUTOFF):
raise SolutionNotAvailable('Infeasible __model, \
solution not available.')
elif self.__model.status == OptimizationStatus.UNBOUNDED:
raise SolutionNotAvailable('Unbounded __model, solution not \
available.')
elif self.__model.status == OptimizationStatus.NO_SOLUTION_FOUND:
raise SolutionNotAvailable('Solution not found \
during optimization.')
return self.__model.solver.var_get_x(self)
def x(self) -> float:
"""Value of this variable in the solution."""
if self.__model.status == OptimizationStatus.LOADED:
raise SolutionNotAvailable('Model was not optimized, \
solution not available.')
elif (self.__model.status == OptimizationStatus.INFEASIBLE
or self.__model.status == OptimizationStatus.CUTOFF):
raise SolutionNotAvailable('Infeasible __model, \
solution not available.')
elif self.__model.status == OptimizationStatus.UNBOUNDED:
raise SolutionNotAvailable('Unbounded __model, solution not \
available.')
elif self.__model.status == OptimizationStatus.NO_SOLUTION_FOUND:
raise SolutionNotAvailable('Solution not found \
during optimization.')
return self.__model.solver.var_get_x(self)
def var_get_x(self, var: Var):
if self._cb_sol == ffi.NULL:
raise SolutionNotAvailable("Solution not available")
return self._cb_sol[var.idx]
def xi(self, i: int) -> float:
"""Value for this variable in the :math:`i`-th solution from
the solution pool."""
if self.__model.status == OptimizationStatus.LOADED:
raise SolutionNotAvailable('Model was not optimized, \
solution not available.')
elif (self.__model.status == OptimizationStatus.INFEASIBLE or
self.__model.status == OptimizationStatus.CUTOFF):
raise SolutionNotAvailable('Infeasible __model, \
solution not available.')
elif self.__model.status == OptimizationStatus.UNBOUNDED:
raise SolutionNotAvailable('Unbounded __model, \
solution not available.')
elif self.__model.status == OptimizationStatus.NO_SOLUTION_FOUND:
raise SolutionNotAvailable('Solution not found \
during optimization.')
return self.__model.solver.var_get_xi(self, i)
def xi(self, i: int) -> float:
"""Value for this variable in the :math:`i`-th solution from
the solution pool."""
if self.__model.status == OptimizationStatus.LOADED:
raise SolutionNotAvailable('Model was not optimized, \
solution not available.')
elif (self.__model.status == OptimizationStatus.INFEASIBLE or
self.__model.status == OptimizationStatus.CUTOFF):
raise SolutionNotAvailable('Infeasible __model, \
solution not available.')
elif self.__model.status == OptimizationStatus.UNBOUNDED:
raise SolutionNotAvailable('Unbounded __model, \
solution not available.')
elif self.__model.status == OptimizationStatus.NO_SOLUTION_FOUND:
raise SolutionNotAvailable('Solution not found \
during optimization.')
return self.__model.solver.var_get_xi(self, i)
def rc(self) -> float:
"""Reduced cost, only available after a linear programming model (only
continuous variables) is optimized"""
if self.__model.status != OptimizationStatus.OPTIMAL:
raise SolutionNotAvailable('Solution not available.')
return self.__model.solver.var_get_rc(self)