Decision Optimization

Expand all | Collapse all

callbacks help!

  • 1.  callbacks help!

    Posted Thu June 25, 2020 02:24 PM
    I am using the cplexAPI package of R to solve mixed-integer problems in the cplex environment. I have already successfully written the problem, getting the final optimal solution, and now I would like to get the internal solutions of the branch and bound tree. I guess that I must use the callbacks, but I do not know how to implement it in R. For the other functions/instructions, many examples can be found in the tutorial of the cplexAPI for R. However, no example exists for the callbacks. Could anyone help me?
    Many thanks,
    Inês Soares


    ------------------------------
    Inês Soares
    ------------------------------


  • 2.  RE: callbacks help!

    Posted Fri June 26, 2020 01:02 AM
    I am not sure this is the best place to ask your question. cplexAPI is not an official IBM product. You may want to contact the authors/maintainers of that project. Or ask them to answer here :-)

    ------------------------------
    Daniel Junglas
    ------------------------------



  • 3.  RE: callbacks help!

    Posted Sun June 28, 2020 12:37 PM
    Hi Daniel,

    Many thanks for the suggestion. I will try to contact them. 

    Alternatively to cplexAPI, I also tried to solve the problem by writing the MIP model in OPL (which can be used in R by external call), but I also could not implement neither the callbacks nor another alternative strategy able of getting a set of internal feasible solutions of the branch and bound tree (not only the optimal solution of the MIP model)OPL is an IBM product, right? In that case, can you help me?

    Best,

    Inês Soares



    ------------------------------
    Inês Soares
    ------------------------------



  • 4.  RE: callbacks help!

    Posted Sun June 28, 2020 01:14 PM
    Hi,

    within OPL you can get many solutions through the solution pool.

    See several solutions in https://www.linkedin.com/pulse/making-decision-optimization-simple-alex-fleischer/

    During the search you may also postprocess  all feasible solutions : https://www.ibm.com/support/knowledgecenter/SSSA5P_12.10.0/ilog.odms.ide.help/OPL_Studio/usroplide/topics/opl_ide_script_cover_post.html

    regards

    ------------------------------
    ALEX FLEISCHER
    ------------------------------



  • 5.  RE: callbacks help!

    Posted Wed July 01, 2020 06:07 PM
    Hi Alex and Daniel,

    Many thanks for your suggestions. It seems that the pool of feasible solutions within OPL is a good alternative (OPL can be used in R by external call).

    I made the implementations according to the examples in the link sent by Alex, but I have a question and I really really appreciate it if you could help me. 
     
    For instance, in a MIP problem with 920 variables (667 integer and 253 continuous) and 368 constraints, considering cplex.solnpoolintensity=2 a set with 60 solutions is obtained, setting cplex.solnpoolintensity=4 a set with 37 solutions is obtained. But should not the number of solutions increase when changing cplex.solnpoolintensity from 2 to 4? How can I solve this issue?

    Also, I was expecting to obtain a larger number of solutions (in the order of magnitude of thousands). Is there any way to largely increase the number of feasible solutions obtained?

    Regarding the cplexAPI package, I had already contacted the developers, but to the moment still had no answer. Also, with the MIP starts query functions, even setting parameter CPX_PARAM_WRITELEVEL to 1, only a few number of solutions is outputted (smaller than 10 in the instances tested). But the problem seems to be circumvented by OPL. If you could further assist me with OPL, I would really appreciate .

    Regards,
    Inês


    ------------------------------
    Inês Soares
    ------------------------------



  • 6.  RE: callbacks help!

    Posted Thu July 02, 2020 01:29 AM
    You may want to read about the solution pool in the manual here, especially about enumerating all solutions. If calling from R, you have to call function CPXpopulate instead of CPXmipopt, I am not sure cplexAPI provides a wrapper for that function.

    Indeed, usually the number of solutions should increase with increasing solution pool intensitiy, but there is no guarantee that this happens. Maybe you can play with the other parameters that control solution pool behavior (see the doc links I shared above).

    ------------------------------
    Daniel Junglas
    ------------------------------



  • 7.  RE: callbacks help!

    Posted Mon July 13, 2020 08:44 PM
    Hi Daniel,
    Thanks for the suggestions. You are right, playing with the other parameters that control solution pool behavior it is really possible to increase the number of feasible solutions.
     
    It seems that my question is now solved within OPL, I get many feasible solutions through the solution pool of the branch and bound tree. I am going to check the structure of the solutions obtained.
    Many thanks.
    Best,
    Inês Soares


    ------------------------------
    Inês Soares
    ------------------------------



  • 8.  RE: callbacks help!

    Posted Tue June 30, 2020 04:47 AM
    You crossposted the question on stackoverflow here: https://stackoverflow.com/questions/62564754/how-to-use-callbacks-with-cplexapi-in-r

    From that it seems that you only want to have a list of alternative solutions. This can be done with the CPLEX solution pool. Alex described how to access the solution pool in OPL.

    Unfortunately, it seems that the solution pool functions are not exported in the cplexAPI package. You may want to contact the authors to ask them to do that.
    There is however a workaround: Every solution in the pool is also installed as a MIP starts. So right after the solve completes, you can use the writeMIPstartsCPLEX() function to write all MIP starts into a single file to disk. Or you can use the MIP starts query functions to directly query those MIP starts from R. When doing this, you may want to set parameter CPX_PARAM_WRITELEVEL to 1 so that all variables are included in the MIP start.

    ------------------------------
    Daniel Junglas
    ------------------------------



  • 9.  RE: callbacks help!

    Posted Wed July 01, 2020 06:08 PM
    Hi Alex and Daniel,

    Many thanks for your suggestions. It seems that the pool of feasible solutions within OPL is a good alternative (OPL can be used in R by external call).

    I made the implementations according to the examples in the link sent by Alex, but I have a question and I really really appreciate it if you could help me. 
     
    For instance, in a MIP problem with 920 variables (667 integer and 253 continuous) and 368 constraints, considering cplex.solnpoolintensity=2 a set with 60 solutions is obtained, setting cplex.solnpoolintensity=4 a set with 37 solutions is obtained. But should not the number of solutions increase when changing cplex.solnpoolintensity from 2 to 4? How can I solve this issue?

    Also, I was expecting to obtain a larger number of solutions (in the order of magnitude of thousands). Is there any way to largely increase the number of feasible solutions obtained?

    Regarding the cplexAPI package, I had already contacted the developers, but to the moment still had no answer. Also, with the MIP starts query functions, even setting parameter CPX_PARAM_WRITELEVEL to 1, only a few number of solutions is outputted (smaller than 10 in the instances tested). But the problem seems to be circumvented by OPL. If you could further assist me with OPL, I would really appreciate .

    Regards,
    Inês


    ------------------------------
    Inês Soares
    ------------------------------