Issue
This Content is from Stack Overflow. Question asked by Mohammad Samiullah
I wanted to solve the simple example, given below, using the Benders decomposition approach.
from docplex.mp.model import Model
Creating model
my_bdrex=Model('My Benders Model',log_output=True)
Defining variables
x_1=my_bdrex.integer_var(name='x_1', lb=0)
x_2=my_bdrex.integer_var(name=’x_2′, lb=0)
y_1=my_bdrex.integer_var(name=’y_1′, lb=0)
y_2=my_bdrex.integer_var(name=’y_2′, lb=0)
y_3=my_bdrex.integer_var(name=’y_3′, lb=0)
Adding constraints
my_bdrex.add_constraint(2x_1+4x_2+4y_1-2y_2+3*y_3<=12)
my_bdrex.add_constraint(3x_1+5x_2+2y_1+3y_2-y_3<=10)
my_bdrex.add_constraint(x_1<=2)
my_bdrex.add_constraint(x_2<=2)
Defining the objective function
objective_bdrex=4x_1+7x_2+2y_1-3y_2+y_3
Solving the Model
my_bdrex.maximize(objective_bdrex)
my_bdrex.parameters.benders.strategy = 1
x_1.benders_annotation=0
x_2.benders_annotation=0
y_1.benders_annotation=1
y_2.benders_annotation=1
y_3.benders_annotation=1
my_bdrex_MP.print_information()
print(my_bdrex_MP.export_as_lp_string())
my_bdrex_MP.solve(clean_before_solve=True)
my_bdrex_MP.print_solution()
The above problem is an integer programming problem. I want to solve it by putting some variables in the master problem and remaining in the subproblem. But when I run the code I got the error: CPLEX Error 2002: Invalid Benders decomposition.
I request here to the community please help me to solve it by using the Benders decomposition approach.
Thanks…………
Solution
In documentation Benders decomposition: CPLEX default
CPLEX implements a default Benders decomposition in certain
situations.
We can read
if there are no continuous variables in your model, CPLEX raises an
error stating that it cannot automatically decompose the model to
apply a Benders strategy.
There is no continuous variable in your model, which explains why you got an error
This Question was asked in StackOverflow by Mohammad Samiullah and Answered by Alex Fleischer It is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.