Search code examples
optimizationlinear-programmingcplex

Get infeasibilities with IBM cplex feasopt python's interface


I am using IBM CPLEX python's API to solve a linear program.

The linear program I am solving turned out to be infeasible, so I am using feasopt() from CPLEX to relax the problem.

I could get a feasible solution through my_prob.feasopt(my_prob.feasopt.all_constraints()), where feasopt relaxes all the constraints.

But I am interested in getting the amount of relaxation for each constraint. Particularly, in the documentation it says In addition to that conventional solution vector, FeasOpt also produces a vector of values that provide useful information about infeasible constraints and variables.

I am interested in getting this vector.


Solution

  • I believe you are looking for the methods available under the Cplex.solution.infeasibility interface.

    Example usage:

    # query the infeasibilities for all linear constraints
    rowinfeas = my_prob.solution.infeasibility.linear_constraints(
        my_prob.solution.get_values())