1
$\begingroup$

I am new to cplex with python. I want to solve a problem using the Benders decomposition approach. Where I want to use UserCutCallback and LazyConstraintCallback. I am writing code in script format (which means I am not defining class, object, etc.). Would I be able to code my problem in that format while using UserCutCallback and LazyConstraintCallback? If yes, how can I use UserCutCallback and LazyConstraintCallback? My problem is as follows:

Defining Model

my_bdrex_OP=Model('My Original Model',log_output=True)

Defining Variables

x_1=my_bdrex_OP.integer_var(name='x_1', lb=0)
x_2=my_bdrex_OP.integer_var(name='x_2', lb=0)
y_1=my_bdrex_OP.continuous_var(name='y_1', lb=0)
y_2=my_bdrex_OP.continuous_var(name='y_2', lb=0)
y_3=my_bdrex_OP.continuous_var(name='y_3', lb=0)

Adding constraints

my_bdrex_OP.add_constraint(2*x_1+4*x_2+4*y_1-2*y_2+3*y_3<=12)
my_bdrex_OP.add_constraint(3*x_1+5*x_2+2*y_1+3*y_2-y_3<=10)
my_bdrex_OP.add_constraint(x_1<=2)
my_bdrex_OP.add_constraint(x_2<=2)

Defining Objective function

objective_OP=4*x_1+7*x_2+2*y_1-3*y_2+y_3
my_bdrex_OP.maximize(objective_OP)

Solving

my_bdrex_OP.print_information()
print(my_bdrex_OP.export_as_lp_string())

I am solving the above problem by using the Benders strategy:

my_bdrex_OP.parameters.benders.strategy = 3
my_bdrex_OP.solve()
my_bdrex_OP.print_solution()

And I successfully got the solution.

But I want to solve it by using the UserCutCallback and LazyConstraintCallback method. I request to the community please help to understand the use of UserCutCallback and LazyConstraintCallback to solve the problem in the Benders decomposition technique.

$\endgroup$

1 Answer 1

0
$\begingroup$

For the implementation issue in UserCutCallback & LazyConstraintCallback, you might refer this github Python Example

For technique detail between both Callback functions, you also can refer CPLEX Official website

Hope those information is useful for you.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.