Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Discrepancy in Solving LPs

    Posted 04/13/16 05:22 PM

    Originally posted by: Bolomanonbolo


    Hi, I am coding in C and using CPLEX 12.6.1 for solving LPs.

    I attach an example of LPs I am trying to solve. The issue is that I get different optimal solution values wheter I invoke CPLEX via callable libraries or via interactive optimizer. In particular, if I use the function CPXbaropt for solving it, the optimal solution value is 84.031086,  while the interactive optimizer (baropt) indicates an optimal value of 84.855999 . The correct optimal value shoud be 84.855999.

    Any ideas on how come it could happen?

    Thanks.

    Best.

    Claudio


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Discrepancy in Solving LPs

    Posted 04/13/16 05:41 PM

    The most common "fix" for this is to use SAV format rather than LP format.  With LP files, you can loose precision.  Please try again, but export your model to example.sav instead.

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Discrepancy in Solving LPs

    Posted 04/14/16 04:24 AM

    Originally posted by: Bolomanonbolo


    Thanks for the answer rkersh.

    Maybe it was not clear for my post, but the solution value that I get when solving the .lp file with the interactive optimizer is the correct one. So, changing the export file does not fix the issue.


    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: Discrepancy in Solving LPs

    Posted 04/14/16 10:45 AM

    Maybe it was not clear for my post, but the solution value that I get when solving the .lp file with the interactive optimizer is the correct one. So, changing the export file does not fix the issue.

    Oops, I'm sorry about that.  I read your post too quickly. :-(

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: Discrepancy in Solving LPs

    Posted 04/14/16 09:00 AM

    What CPLEX version are you using and how exactly are you calling baropt in the callable library application. I ran this code

    #include <stdio.h>
    #include <stdlib.h>
    #include <ilcplex/cplexx.h>
    
    #define CPXFUNC(f) do {                         \
          int const s_ = f;                         \
          if ( s_ != 0 ) {                          \
             fprintf (stderr, "%s:%d: %s = %d\n",   \
                      __FILE__, __LINE__, #f, s_);  \
             fflush (stderr);                       \
             abort ();                              \
          }                                         \
       } while (0)
    
    #define CPXPOINTER(f) do {                        \
          void *p_ = (void *)(f);                     \
          if ( p_ == NULL ) {                         \
             fprintf (stderr, "%s:%d: %s = NULL\n",   \
                      __FILE__, __LINE__, #f);        \
             fflush (stderr);                         \
             abort ();                                \
          }                                           \
       } while (0)
    
    int
    main(int argc, char **argv)
    {
       int a;
    
       for (a = 1; a < argc; ++a) {
          char const *model = argv[a];
          CPXENVptr env;
          CPXLPptr lp;
          int status;
          double objval;
    
          CPXPOINTER( env = CPXXopenCPLEX(&status) ); CPXFUNC( status );
          CPXFUNC( CPXXsetintparam(env, CPX_PARAM_SCRIND, CPX_ON) );
          CPXPOINTER( lp = CPXXcreateprob(env, &status, "") ); CPXFUNC( status );
          CPXFUNC( CPXXreadcopyprob(env, lp, model, NULL) );
          CPXFUNC( CPXXbaropt(env, lp) );
          printf("Status: %d\n", CPXXgetstat(env, lp));
          CPXFUNC( CPXXgetobjval(env, lp, &objval) );
          printf("Objective: %.8f\n", objval);
    
          CPXFUNC( CPXXfreeprob(env, &lp) );
          CPXFUNC( CPXXcloseCPLEX(&env) );
       }
       return 0;
    }
    

    and as expected it outputs

    Status: 1
    Objective: 84.85599973

     


    #CPLEXOptimizers
    #DecisionOptimization