Decision Optimization

Decision Optimization

Delivers prescriptive analytics capabilities and decision intelligence to improve decision-making.


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Different solution using interactive optimizer and cplex callable library

    Posted 03/05/16 12:13 PM

    Originally posted by: Zele


    Hi all,

    I'm solving a mip problem using, by one one hand, interactive optimizer (only read the .sav file and mipopt), and, by the other hand, a c++ program, using callable library, in which I create a  problem named lp, read the same .sav file and say CPXmipopt(env,lp).

     The results are very strange to me: with interactive optimizer I find optimal solution in some minutes, and, with the program in c++, cplex is out of memory in 215 seconds!! How could it be possible?

    I don't fixed any different parameters in both of them (later, I have tried using CPX_PARAM_WORKMEN and CPX_PARAM_NODEFILEIND but cplex is out of memory again, only with c++ ). I need the optimal solution with my program, not only with the interactive optimizer.

    I attach the .sav  file (file.sav) and the resulting log  (mylog.log) using my program in c++. In interactive optimizer, how you can see by yourself, optimal is found.

    Thanks in advance.

     

     

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Different solution using interactive optimizer and cplex callable library

    Posted 03/05/16 05:45 PM

    Originally posted by: EdKlotz


    Does your program set any non default CPLEX parameters?   If so, that might explain the difference in performance.

    I ran interactive CPLEX on your SAV file, and it always solved within a second, even when I turned off heuristics and presolve to

    try to slow it down.    Comparing the fast runs with your mylog.log file, the key difference seems to be that the fast runs find

    a very good solution immediately, whereas your slow run finds a solution immediately, but with much worse objective.   That

    seems to play a role here.

    I also compiled, linked and run the ilomipex2.cpp program on your SAV file, and that program solved the model immediately.

    Similarly, the mipex2.c program that uses the C API solves it quickly.   So I suggest you compile and link those programs and

    see how they do on your SAV file.   If they solve it quickly, then you need to look at the differences between your program and those programs to figure out what is happening.

     

    Also, while it doesn't seem to play a role in the issue here, I see one thing from your log file that could adversely affect performance:

    Default variable names x1, x2 ... being created.
    Default row names c1, c2 ... being created.
    Warning:  File contains basis.  Basis is loaded.

     

    An advanced basis for a MIP will only help you solve the initial relaxation faster.   But, that gain comes at the expense of disabling CPLEX's presolve, which can be extremely helpful for MIPs.    So, in general we don't recommend including a basis in the SAV file when solving

    MIPs.   Use that for only for continuous problems, or at least compare performance with the basis (but without presolve) and without

    the basis (but with presolve).   Given how quickly the root relaxation solves, in this case I think you would be better off skipping the

    basis and taking advantage of CPLEX's presolve.

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Different solution using interactive optimizer and cplex callable library

    Posted 03/06/16 10:22 AM

    Originally posted by: Zele


     

    Hi, EdKlotz.

    Thanks for your time. First, sorry because I confused the file file.sav. I realized because you said that always solved within a seconds, and, usually, it is solved in minutes (about half an hour), with interactive optimizer. I have attached it again in previous post.

    About you say: no, I don't set any non default CPLEX parameters. Even so, I have just written in my program line "status=CPXsetdefaults(env);"  just before read the .sav file to ensure nothing escapes to me, and CPLEX is out of memory again.

    About basic variables, both, interactive optimizer and with my program, CPLEX says the same warning (of course, file is the same), but the behavior is different.

     I will try to explain why I use it, because these details could be useful: I have these basis variables because I am programming a heuristic that solves a big problem by parts. I mean, in the c++ program, I have a big problem, and, iteratively,by steps, I fix some variables to 0,1 each time. So, in the file.sav I attach, I am in a intermediate step: some variables are fixed to 0 or 1, and some variables (2000) are declared binary. So, the program solves this new problem, I save the solution, and later, in the next step for the algorithm, I save some 0-1 values for some variables, fix them, and declared another ones binary, etc, etc.  

     

    First, I thought that, how I am always with the same problem, fixing some variables,declaring binaries another ones, solving it again, etc, this affected the way CPLEX works. So, I tried, in each step, free the problem (using CPXfreeprob()), reading the .sav file I built in the previous step, and solve it, but I find the same "out of memory" problem. The only thing  I have not done is try to free, not only the problem, but all CPLEx memory used in each step, but I suppose that there must be a less drastic way to fix it.

    Thanks in advance.

     

     

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: Different solution using interactive optimizer and cplex callable library

    Posted 03/08/16 07:15 AM

    Originally posted by: Zele


    Hi again,

    As I have not yet solved the problem I explained above and I have tried something new, that I mention as information: inside code in VS with c++, each time I solve the problem with some fixed variables and some variables declared binaries, finally I have decided to close CPLEX (CPXcloseCPLEX) and open it again, in case it was necessary free memory in CPLEX, but, again, cplex is out of memory in c++.

    I appreciate it if someone could help me and tell me what's going on.

    Thanks in advance

     

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: Different solution using interactive optimizer and cplex callable library

    Posted 03/08/16 10:35 AM

    Two things:

    1. To avoid this out-of-memory issue you may want to use node files, see here.

    2. I failed to reproduce your issue here. I used this C++ program

    #include <ilcplex/cplex.h>
    
    int
    main(void)
    {
       int status;
       CPXENVptr env = CPXopenCPLEX(&status);
       if ( !env ) throw status;
       if ( (status = CPXsetintparam(env, CPX_PARAM_SCRIND, CPX_ON)) )
          throw status;
    
       CPXLPptr lp = CPXcreateprob(env, &status, "");
       if ( !lp )
          throw status;
       if ( (status = CPXreadcopyprob(env, lp, "file.sav", 0)) )
          throw status;
    
       if ( (status = CPXmipopt(env, lp)) )
          throw status;
    
       if ( (status = CPXfreeprob(env, &lp)) )
          throw status;
    
       if ( (status = CPXcloseCPLEX(&env)) )
          throw status;
    
       return 0;
    }
    

    It produces the exact same output as

    cplex -c 'read file.sav' opt

    Unfortunately, in my case neither the interactive nor the C++ program prove optimality before running out of memory.

    I am using CPLEX 12.6.3 on an 8 core Linux box here.

    Can you try with my simple C++ code? Are you sure the library you use for C++ and the interactive are from the exact same CPLEX version and are running on the exact same machine? Can you double-check library version and version of interactive?


    #CPLEXOptimizers
    #DecisionOptimization