How to obtain extreme ray for unbounded problem in Cplex with Python

Viewed 30

I wanted to run the simple code of an unbounded problem in Cplex using python API:

import docplex.mp.model as cpx from docplex.util.status import JobSolveStatus

my_bdrex_SP=cpx.Model('My Benders Model Sub Problem')

Adding variables:

v_1=my_bdrex_SP.continuous_var(name='v_1', lb=0)

v_2=my_bdrex_SP.continuous_var(name='v_2', lb=0)

Defining the objective function

objective_SP=0v_1-6v_2

Adding constraints

my_bdrex_SP.add_constraint(4v_1+2v_2>=2)

my_bdrex_SP.add_constraint(-2v_1+3v_2>=-3)

my_bdrex_SP.add_constraint(3v_1-1v_2>=1)

Solving the problem

my_bdrex_SP.minimize(objective_SP)

my_bdrex_SP.solve()

my_bdrex_SP.print_solution()

print(my_bdrex_SP.get_solve_status())

This problem is unbounded and Cplex gives the results as "unbounded or infeasible". To obtain the feasibility cut, I need an extreme ray. For that, I am using the following line

ray = my_bdrex_SP.get_engine().get_cplex().solution.advanced.get_ray()

But unfortunately I am receiving error like cplex.exceptions.errors.CplexSolverError: CPLEX Error 1217: No solution exists.

I request here to the community to help me to obtain the extreme ray of unbounded problem.

Thanks........

1 Answers

I think you have to turn the presolve off with

my_bdrex_SP.parameters.preprocessing.presolve = 0

and you will get

* unbounded ray (vector): [1.0, 1.0, 0.0]
* unbounded ray (expr): x+y
Related