Skip to content

Commit

Permalink
variable errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jurgen-lentz committed Oct 30, 2024
1 parent e15a57a commit e4d2efb
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions amplpy/variable.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ cdef class Variable(Entity):
value: value to be set.
"""
if isinstance(value, Parameter):
campl.AMPL_VariableInstanceSetValue(self._c_ampl, self._name, self._index, value.value())
PY_AMPL_CALL(campl.AMPL_VariableInstanceSetValue(self._c_ampl, self._name, self._index, value.value()))
else:
campl.AMPL_VariableInstanceSetValue(self._c_ampl, self._name, self._index, float(value))
PY_AMPL_CALL(campl.AMPL_VariableInstanceSetValue(self._c_ampl, self._name, self._index, float(value)))

def astatus(self):
"""
Expand All @@ -91,23 +91,23 @@ cdef class Variable(Entity):
variable out.
"""
cdef int value
campl.AMPL_InstanceGetIntSuffix(self._c_ampl, self._name, self._index, campl.AMPL_NUMERICSUFFIX.AMPL_DEFEQN, &value)
PY_AMPL_CALL(campl.AMPL_InstanceGetIntSuffix(self._c_ampl, self._name, self._index, campl.AMPL_NUMERICSUFFIX.AMPL_DEFEQN, &value))
return value

def dual(self):
"""
Get the dual value on defining constraint of variable substituted out.
"""
cdef double value
campl.AMPL_InstanceGetDoubleSuffix(self._c_ampl, self._name, self._index, campl.AMPL_NUMERICSUFFIX.AMPL_DUAL, &value)
PY_AMPL_CALL(campl.AMPL_InstanceGetDoubleSuffix(self._c_ampl, self._name, self._index, campl.AMPL_NUMERICSUFFIX.AMPL_DUAL, &value))
return value

def init(self):
"""
Get the current initial guess.
"""
cdef double value
campl.AMPL_InstanceGetDoubleSuffix(self._c_ampl, self._name, self._index, campl.AMPL_NUMERICSUFFIX.AMPL_INIT, &value)
PY_AMPL_CALL(campl.AMPL_InstanceGetDoubleSuffix(self._c_ampl, self._name, self._index, campl.AMPL_NUMERICSUFFIX.AMPL_INIT, &value))
return value

def init0(self):
Expand All @@ -116,111 +116,111 @@ cdef class Variable(Entity):
statement).
"""
cdef double value
campl.AMPL_InstanceGetDoubleSuffix(self._c_ampl, self._name, self._index, campl.AMPL_NUMERICSUFFIX.AMPL_INIT0, &value)
PY_AMPL_CALL(campl.AMPL_InstanceGetDoubleSuffix(self._c_ampl, self._name, self._index, campl.AMPL_NUMERICSUFFIX.AMPL_INIT0, &value))
return value

def lb(self):
"""
Returns the current lower bound.
"""
cdef double value
campl.AMPL_InstanceGetDoubleSuffix(self._c_ampl, self._name, self._index, campl.AMPL_NUMERICSUFFIX.AMPL_LB, &value)
PY_AMPL_CALL(campl.AMPL_InstanceGetDoubleSuffix(self._c_ampl, self._name, self._index, campl.AMPL_NUMERICSUFFIX.AMPL_LB, &value))
return value

def ub(self):
"""
Returns the current upper bound.
"""
cdef double value
campl.AMPL_InstanceGetDoubleSuffix(self._c_ampl, self._name, self._index, campl.AMPL_NUMERICSUFFIX.AMPL_UB, &value)
PY_AMPL_CALL(campl.AMPL_InstanceGetDoubleSuffix(self._c_ampl, self._name, self._index, campl.AMPL_NUMERICSUFFIX.AMPL_UB, &value))
return value

def lb0(self):
"""
Returns the initial lower bounds, from the var declaration.
"""
cdef double value
campl.AMPL_InstanceGetDoubleSuffix(self._c_ampl, self._name, self._index, campl.AMPL_NUMERICSUFFIX.AMPL_LB0, &value)
PY_AMPL_CALL(campl.AMPL_InstanceGetDoubleSuffix(self._c_ampl, self._name, self._index, campl.AMPL_NUMERICSUFFIX.AMPL_LB0, &value))
return value

def ub0(self):
"""
Returns the initial upper bound, from the var declaration.
"""
cdef double value
campl.AMPL_InstanceGetDoubleSuffix(self._c_ampl, self._name, self._index, campl.AMPL_NUMERICSUFFIX.AMPL_UB0, &value)
PY_AMPL_CALL(campl.AMPL_InstanceGetDoubleSuffix(self._c_ampl, self._name, self._index, campl.AMPL_NUMERICSUFFIX.AMPL_UB0, &value))
return value

def lb1(self):
"""
Returns the weaker lower bound from AMPL's presolve phase.
"""
cdef double value
campl.AMPL_InstanceGetDoubleSuffix(self._c_ampl, self._name, self._index, campl.AMPL_NUMERICSUFFIX.AMPL_LB1, &value)
PY_AMPL_CALL(campl.AMPL_InstanceGetDoubleSuffix(self._c_ampl, self._name, self._index, campl.AMPL_NUMERICSUFFIX.AMPL_LB1, &value))
return value

def ub1(self):
"""
Returns the weaker upper bound from AMPL's presolve phase.
"""
cdef double value
campl.AMPL_InstanceGetDoubleSuffix(self._c_ampl, self._name, self._index, campl.AMPL_NUMERICSUFFIX.AMPL_UB1, &value)
PY_AMPL_CALL(campl.AMPL_InstanceGetDoubleSuffix(self._c_ampl, self._name, self._index, campl.AMPL_NUMERICSUFFIX.AMPL_UB1, &value))
return value

def lb2(self):
"""
Returns the stronger lower bound from AMPL's presolve phase.
"""
cdef double value
campl.AMPL_InstanceGetDoubleSuffix(self._c_ampl, self._name, self._index, campl.AMPL_NUMERICSUFFIX.AMPL_LB2, &value)
PY_AMPL_CALL(campl.AMPL_InstanceGetDoubleSuffix(self._c_ampl, self._name, self._index, campl.AMPL_NUMERICSUFFIX.AMPL_LB2, &value))
return value

def ub2(self):
"""
Returns the stronger upper bound from AMPL's presolve phase.
"""
cdef double value
campl.AMPL_InstanceGetDoubleSuffix(self._c_ampl, self._name, self._index, campl.AMPL_NUMERICSUFFIX.AMPL_UB2, &value)
PY_AMPL_CALL(campl.AMPL_InstanceGetDoubleSuffix(self._c_ampl, self._name, self._index, campl.AMPL_NUMERICSUFFIX.AMPL_UB2, &value))
return value

def lrc(self):
"""
Returns the reduced cost at lower bound.
"""
cdef double value
campl.AMPL_InstanceGetDoubleSuffix(self._c_ampl, self._name, self._index, campl.AMPL_NUMERICSUFFIX.AMPL_LRC, &value)
PY_AMPL_CALL(campl.AMPL_InstanceGetDoubleSuffix(self._c_ampl, self._name, self._index, campl.AMPL_NUMERICSUFFIX.AMPL_LRC, &value))
return value

def urc(self):
"""
Returns the reduced cost at upper bound.
"""
cdef double value
campl.AMPL_InstanceGetDoubleSuffix(self._c_ampl, self._name, self._index, campl.AMPL_NUMERICSUFFIX.AMPL_URC, &value)
PY_AMPL_CALL(campl.AMPL_InstanceGetDoubleSuffix(self._c_ampl, self._name, self._index, campl.AMPL_NUMERICSUFFIX.AMPL_URC, &value))
return value

def lslack(self):
"""
Return the slack at lower bound (``val - lb``).
"""
cdef double value
campl.AMPL_InstanceGetDoubleSuffix(self._c_ampl, self._name, self._index, campl.AMPL_NUMERICSUFFIX.AMPL_LSLACK, &value)
PY_AMPL_CALL(campl.AMPL_InstanceGetDoubleSuffix(self._c_ampl, self._name, self._index, campl.AMPL_NUMERICSUFFIX.AMPL_LSLACK, &value))
return value

def uslack(self):
"""
Return the slack at upper bound (``ub - val``).
"""
cdef double value
campl.AMPL_InstanceGetDoubleSuffix(self._c_ampl, self._name, self._index, campl.AMPL_NUMERICSUFFIX.AMPL_USLACK, &value)
PY_AMPL_CALL(campl.AMPL_InstanceGetDoubleSuffix(self._c_ampl, self._name, self._index, campl.AMPL_NUMERICSUFFIX.AMPL_USLACK, &value))
return value

def rc(self):
"""
Get the reduced cost (at the nearer bound).
"""
cdef double value
campl.AMPL_InstanceGetDoubleSuffix(self._c_ampl, self._name, self._index, campl.AMPL_NUMERICSUFFIX.AMPL_RC, &value)
PY_AMPL_CALL(campl.AMPL_InstanceGetDoubleSuffix(self._c_ampl, self._name, self._index, campl.AMPL_NUMERICSUFFIX.AMPL_RC, &value))
return value

def slack(self):
Expand All @@ -229,7 +229,7 @@ cdef class Variable(Entity):
:func:`~amplpy.Variable.lslack` and :func:`~amplpy.Variable.uslack`.
"""
cdef double value
campl.AMPL_InstanceGetDoubleSuffix(self._c_ampl, self._name, self._index, campl.AMPL_NUMERICSUFFIX.AMPL_SLACK, &value)
PY_AMPL_CALL(campl.AMPL_InstanceGetDoubleSuffix(self._c_ampl, self._name, self._index, campl.AMPL_NUMERICSUFFIX.AMPL_SLACK, &value))
return value

def sstatus(self):
Expand Down

0 comments on commit e4d2efb

Please sign in to comment.