Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Looking for help on LP problem

    Posted 07/06/10 10:35 AM

    Originally posted by: Joshua_gao


    Hi, I have a problem on using CPLEX 9 to solve an LP problem. There are 300 constraints in the form like a_ix <=b_i, where x in R^2. When I called cplex, there is error. Then I tried following methods,

    1. I tried to catch the error code however it shows nothing. ( cout<<"error code:"<< error <<endl shows nothing after "error code:").

    2. I removed the try and catch part and use debug mod, it gives me "Runtime error!... abnormal program termination".

    Is this problem too big for cplex? Any thoughts will be appreciated.
    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Looking for help on LP problem

    Posted 07/06/10 10:52 AM

    Originally posted by: SystemAdmin


    No, the problem is far from being too big for CPLEX. Beyond that, it's hard to say anything without seeing the portion of the code where the problem occurs. If you do post any code, please be sure to surround it with {code} so that the forum software doesn't gobble up brackets and asterisks.

    /Paul
    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Looking for help on LP problem

    Posted 07/06/10 11:24 AM

    Originally posted by: Joshua_gao


    thanks a lot. The following code may have problem.
    .....
    IloEnv env;
    try
    {
      IloNumVar z(env,0,1,ILOFLOAT);
      IloNumVarArray x(env);//decision variables
      IloModel  mod(env);
      IloCplex  cplex(env);
       
      n=pro.n;
      s=pro.s;
      k=pro.k;
      ns=(n-s)*s;
      nn=n*n;
     
      for (tk=0;tk<k;tk++)
      {
         x.add(IloNumVar(env, par.km_lb[tk], par.km_ub[tk], ILOFLOAT));
      }
     
      for(i=0;i<n-s;i++)
      {
        for(j=0;j<s;j++)
        { 
           ti=min(cdex[i],rdex[j]);
           tj=max(cdex[i],rdex[j]);
           for(o=0;o<2;o++)
           { 
             if( shp[o*ns+j*(n-s)+i]==1)
             {
               IloExpr expr_ineq1(env);
               for(tk=0;tk<k;tk++)  
               {
                 expr_ineq1+=-1*par.Mh[o*nn+tj*n+ti].A[tk]*x[tk];
               }
               expr_ineq1+=-1*par.Mh[o*nn+tj*n+ti].b;
               expr_ineq1+=z;
               mod.add(expr_ineq1<=0);
               expr_ineq1.end();
             }
             else if( shp[o*ns+j*(n-s)+i]==-1)
             {
               IloExpr expr_ineq2(env);
               for(tk=0;tk<k;tk++)  
               {
                 expr_ineq2+=par.Mh[o*nn+tj*n+ti].A[tk]*x[tk];
               }
               expr_ineq2+=par.Mh[o*nn+tj*n+ti].b;
               expr_ineq2+=z;
               mod.add(expr_ineq2<=0);
               expr_ineq2.end();            
             }
             else
             {
              ...   
             }
          }//o 
        }  //j
      } //i
       
      IloObjective obj(env);
      obj.setExpr(z);
      obj.setSense(IloObjective::Maximize);
      mod.add(obj);
        
      cplex.extract(mod);
     
      if(cplex.solve()==IloTrue)
      {  
        .... 
      }
      
     }//try
     
     catch(IloException &ex)
     {
        cerr<<"Error:"<<ex<<endl;
     }
     catch(std::exception &e)
     {
        cerr<<"std exp"<<e.what()<<endl;
     }
     catch(...)
     {
        cerr<<"unknown"<<endl;
     }
     env.end();
    

    joshua
    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: Looking for help on LP problem

    Posted 07/06/10 11:33 AM

    Originally posted by: SystemAdmin


    > Joshua_gao wrote:
    >
    ...
    >       expr_ineq1.end();
    ...
    >            expr_ineq2.end();               
    >
    


    Try deleting those two lines. When you invoke the end() method on an extractable, it is removed from any models containing it.

    /Paul

    Mathematicians are like Frenchmen: whenever you say something to them, they translate it into their own language, and at once it is something entirely different. (Goethe)
    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: Looking for help on LP problem

    Posted 07/06/10 11:43 AM

    Originally posted by: Joshua_gao


    thanks. I removed them, however, still not working.
    Is there any functions in Class IloModel that I can output the model in .LP file?
    #CPLEXOptimizers
    #DecisionOptimization


  • 6.  Re: Looking for help on LP problem

    Posted 07/06/10 12:21 PM

    Originally posted by: SystemAdmin


    cplex.export("your_model_name.lp");

    An advice, due to the truncation of data when exporting to a .lp file, I recommend you to use .lp just for debug and use .sav to solve.
    #CPLEXOptimizers
    #DecisionOptimization


  • 7.  Re: Looking for help on LP problem

    Posted 07/06/10 01:48 PM

    Originally posted by: Joshua_gao


    thanks. However, when I called function cplex.exportModel("mymodel.lp"), it shows "run time error" dialog box.
    Then, I reduce the size the problem, i.e., I reduce the number of constraints from 300 to 290. Amazingly, everything is fine. So I seriously doubt the problem is related to the size of the problem.
    #CPLEXOptimizers
    #DecisionOptimization


  • 8.  Re: Looking for help on LP problem

    Posted 07/06/10 02:08 PM

    Originally posted by: Joshua_gao


    Hi, thanks all you guys above. I finally figure whats going on here. 300 is the upper limit of the constraints. Maybe this version is not a full version. I will contact the technical staff of our department for this problem.
    #CPLEXOptimizers
    #DecisionOptimization


  • 9.  Re: Looking for help on LP problem

    Posted 07/06/10 02:40 PM

    Originally posted by: SystemAdmin


    IBM put out a free student version some months ago that had a 300 constraint (and I think also 300 variable?) limit. They may still be distributing that, but subsequently they released the full version free to academics who join their academic initiative. Students do not qualify, but professors can join, get the free full version, and then give their students access to it.

    /Paul

    Mathematicians are like Frenchmen: whenever you say something to them, they translate it into their own language, and at once it is something entirely different. (Goethe)
    #CPLEXOptimizers
    #DecisionOptimization


  • 10.  Re: Looking for help on LP problem

    Posted 07/06/10 10:36 PM

    Originally posted by: Joshua_gao


    Problem is solved. All the suggestions provided here are helpful. 3x.
    #CPLEXOptimizers
    #DecisionOptimization