Open
Description
Dear support team,
I want to know how to set the initial solution when using benders decomposition.
I want to solve the problem with benders decomposition
min 3x + 2y + z
s.t. 2x + y>=5,
x + z>=4
0 <= x <= 10,
0 <= y <= 10,
0 <= z
This is my demo code.
from pyscipopt import Model, Benders
def create_master_problem():
master = Model("Master Problem")
x = master.addVar("x", vtype="C", lb=0, ub=10)
y = master.addVar("y", vtype="C", lb=0, ub=10)
master.setObjective(3 * x + 2 * y, "minimize")
master.addCons(2 * x + y >= 5)
return master, x, y
def create_sub_problem():
sub = Model("Sub Problem")
z = sub.addVar("z", vtype="C", lb=0)
x = sub.addVar("x", vtype="C", lb=0, ub=10)
sub.setObjective(z , "minimize")
sub.addCons(z >= 4 - x)
return sub, x, z
def benders_decomposition():
master, x, y = create_master_problem()
sub, sub_x, sub_z = create_sub_problem()
master.initBendersDefault(sub)
master_initial_sol = master.createSol()
master.setSolVal(master_initial_sol, x, 3)
master.setSolVal(master_initial_sol, y, 1)
master.addSol(master_initial_sol)
master.optimize()
print("Optimal value for x:", master.getVal(x))
print("Optimal value for y:", master.getVal(y))
print("Optimal objective value:", master.getObjVal())
if __name__ == "__main__":
benders_decomposition()
When I don't set master.initBendersDefault(sub)
, scip hints
1/1 feasible solution given by solution candidate storage, new primal bound 1.100000e+01
I can get answer:
Optimal value for x: 2.5
Optimal value for y: 0.0
Optimal objective value: 7.5
But I set master.initBendersDefault(sub)
, scip hints
all 1 solutions given by solution candidate storage are infeasible
Benders' decomposition: Objective coefficients of copied of master problem variables has been changed to zero.
I get answer
Optimal value for x: 2.5
Optimal value for y: 0.0
Optimal objective value: 9.0
Why is there infeasible when I set initBendersDefault
? And I'm really confused about how to set the initial solution for the Benders decomposition.