Skip to content

Commit 9bf2d9b

Browse files
fix lotsizing_lazy example (#1150)
* fix lotsizing_lazy example * changelog
1 parent 2645c4d commit 9bf2d9b

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
- all fundamental callbacks now raise an error if not implemented
1010
- Fixed the type of MatrixExpr.sum(axis=...) result from MatrixVariable to MatrixExpr.
1111
- Updated IIS result in PyiisfinderExec()
12+
- Fixed lotsizing_lazy example
1213
### Changed
1314
- changed default value of enablepricing flag to True
1415
### Removed

examples/finished/lotsizing_lazy.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ def addcut(self, checkonly, sol):
4141
return cutsadded
4242

4343
def conscheck(self, constraints, solution, checkintegrality, checklprows, printreason, completely):
44-
if not self.addcut(checkonly=True, sol=solution):
44+
if self.addcut(checkonly=True, sol=solution):
4545
return {"result": SCIP_RESULT.INFEASIBLE}
4646
else:
4747
return {"result": SCIP_RESULT.FEASIBLE}
4848

4949
def consenfolp(self, constraints, nusefulconss, solinfeasible):
50-
if self.addcut(checkonly=False):
50+
if self.addcut(checkonly=False, sol=None):
5151
return {"result": SCIP_RESULT.CONSADDED}
5252
else:
5353
return {"result": SCIP_RESULT.FEASIBLE}
@@ -151,6 +151,7 @@ def mk_example():
151151
model = sils(T, f, c, d, h)
152152
y, x, I = model.data
153153
model.optimize()
154+
sils_obj = model.getObjVal()
154155
print("\nOptimal value [standard]:", model.getObjVal())
155156
print("%8s%8s%8s%8s%8s%8s%12s%12s" % ("t", "fix", "var", "h", "dem", "y", "x", "I"))
156157
for t in range(1, T + 1):
@@ -161,9 +162,12 @@ def mk_example():
161162
model = sils_cut(T, f, c, d, h, conshdlr)
162163
model.setBoolParam("misc/allowstrongdualreds", 0)
163164
model.optimize()
165+
sils_cut_obj = model.getObjVal()
164166
y, x, I = model.data
165167
print("\nOptimal value [cutting planes]:", model.getObjVal())
166168
print("%8s%8s%8s%8s%8s%8s%12s%12s" % ("t", "fix", "var", "h", "dem", "y", "x", "I"))
167169
for t in range(1, T + 1):
168170
print("%8d%8d%8d%8d%8d%8.1f%12.1f%12.1f" % (
169171
t, f[t], c[t], h[t], d[t], model.getVal(y[t]), model.getVal(x[t]), model.getVal(I[t])))
172+
173+
assert abs(sils_obj - sils_cut_obj) <= 1e-6

0 commit comments

Comments
 (0)