jump-dev / CPLEX.jl

A Julia interface to the CPLEX solver
https://www.ibm.com/products/ilog-cplex-optimization-studio
MIT License
134 stars 63 forks source link

Annotating a model for Benders Decomposition #268

Closed hdavid16 closed 4 years ago

hdavid16 commented 4 years ago

I am wondering if it is possible to use CPLEX.jl to annotate models to implement the CPLEX benders decomposition (see https://www.ibm.com/support/knowledgecenter/SSSA5P_12.8.0/ilog.odms.cplex.help/CPLEX/UsrMan/topics/discr_optim/benders/parameterBenders.html).

I have successfully used the MOI.RawParameter as suggested in the README, to set the CPLEX benders strategy to automatic. However, I would like to specify which variables should belong to which subproblem. To do so, I need to annotate the model, but am not sure if CPLEX.jl has these capabilities included (see https://www.ibm.com/support/knowledgecenter/SSSA5P_12.8.0/ilog.odms.cplex.help/CPLEX/UsrMan/topics/discr_optim/benders/annotatedDecomp.html).

Thank you!

odow commented 4 years ago

This functionality isn't wrapped.

The first step is to wrap these C functions: https://www.ibm.com/support/knowledgecenter/SSSA5P_12.8.0/ilog.odms.cplex.help/CPLEX/UsrMan/topics/discr_optim/benders/annotationsC.html

And then provide MOI attributes (like RawParameter) to get/set them.

hdavid16 commented 4 years ago

Thank you for your response. Looking in the cpx_solve.jl file, I found that the functionality is in fact implemented already via newlongannotation and setlongannotations. I have the annotations working and benders decomposition running. However, I am getting some random strange behavior in the annotations during some runs. The last input to setlongannotations is to specify an array with long values. I am using the form [Clong(some_number)] for this input. Most of the times, the correct number is annotated, however, sometimes I get very strange behavior (see snippet of the .ann file generated by CPLEX):

`<?xml version='1.0' encoding='utf-8'?>

` You will notice that the variable with index 27 is annotated with 4294967297. However, I am specifying that it should be 1 (i.e. Clong(1)). When I rerun my code, a different variable is randomly annotated to some very large positive or negative number. Any idea what is going on? Is this an a problem with C.jl or IBM? My current workaround thus far has been to use Julia to write the .ann file with the annotations and feed them to to CPLEX via CPXreadcopyannotations.