Skip to content

Commit 57da1a7

Browse files
committed
remove optimality assertions, add comment
1 parent 75d6ea6 commit 57da1a7

File tree

1 file changed

+20
-15
lines changed

1 file changed

+20
-15
lines changed

src/pyscipopt/lp.pxi

+20-15
Original file line numberDiff line numberDiff line change
@@ -373,19 +373,21 @@ cdef class LP:
373373
return SCIPlpiIsOptimal(self.lpi)
374374

375375
def getObjVal(self):
376-
"""Returns the objective value of the last LP solve."""
377-
assert self.isOptimal(), "LP is not optimal"
378-
376+
"""
377+
Returns the objective value of the last LP solve.
378+
Please note that infeasible or unbounded LPs might return unexpected results.
379+
"""
379380
cdef SCIP_Real objval
380381

381382
PY_SCIP_CALL(SCIPlpiGetSol(self.lpi, &objval, NULL, NULL, NULL, NULL))
382383

383384
return objval
384385

385386
def getPrimal(self):
386-
"""Returns the primal solution of the last LP solve."""
387-
assert self.isOptimal(), "LP is not optimal"
388-
387+
"""
388+
Returns the primal solution of the last LP solve.
389+
Please note that infeasible or unbounded LPs might return unexpected results.
390+
"""
389391
cdef int ncols = self.ncols()
390392
cdef SCIP_Real* c_primalsol = <SCIP_Real*> malloc(ncols * sizeof(SCIP_Real))
391393
cdef int i
@@ -403,9 +405,10 @@ cdef class LP:
403405
return SCIPlpiIsPrimalFeasible(self.lpi)
404406

405407
def getDual(self):
406-
"""Returns the dual solution of the last LP solve."""
407-
assert self.isOptimal(), "LP is not optimal"
408-
408+
"""
409+
Returns the dual solution of the last LP solve.
410+
Please note that infeasible or unbounded LPs might return unexpected results.
411+
"""
409412
cdef int nrows = self.nrows()
410413
cdef SCIP_Real* c_dualsol = <SCIP_Real*> malloc(nrows * sizeof(SCIP_Real))
411414
cdef int i
@@ -471,9 +474,10 @@ cdef class LP:
471474
return niters
472475

473476
def getActivity(self):
474-
"""Returns the row activity vector of the last LP solve."""
475-
assert self.isOptimal(), "LP is not optimal"
476-
477+
"""
478+
Returns the row activity vector of the last LP solve.
479+
Please note that infeasible or unbounded LPs might return unexpected results.
480+
"""
477481
cdef int nrows = self.nrows()
478482
cdef SCIP_Real* c_activity = <SCIP_Real*> malloc(nrows * sizeof(SCIP_Real))
479483
cdef int i
@@ -489,9 +493,10 @@ cdef class LP:
489493
return activity
490494

491495
def getRedcost(self):
492-
"""Returns the reduced cost vector of the last LP solve."""
493-
assert self.isOptimal(), "LP is not optimal"
494-
496+
"""
497+
Returns the reduced cost vector of the last LP solve.
498+
Please note that infeasible or unbounded LPs might return unexpected results.
499+
"""
495500
cdef int ncols = self.ncols()
496501
cdef SCIP_Real* c_redcost = <SCIP_Real*> malloc(ncols * sizeof(SCIP_Real))
497502
cdef int i

0 commit comments

Comments
 (0)