Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  CPLEX ingnoring constraints problem

    Posted 08/14/19 05:16 PM

    Originally posted by: mido199


    Hello,

    I am using CPLEX 12.8 to solve a MIP. My model includes constraints of time windows like the ones in the classical transportation problems. In my model, I create time variables (corresponding to arrival times at customer nodes) then add time windows constraints on each variable. When I solve the model with CPLEX and check the lp (output model), I find that not all time windows constraints are added to the model. Constraints on some variables are ignored. Here is the code that I use to set the bounds of time variables:

    t = IloNumVarArray(env, (int)prob->GetNodeCount(),0, depot->tw_end,ILOFLOAT);

    for(int i=0; i< s.GetDriverCount(); i++)
        {
            Driver * d= s.GetDriver(i);
            Node * prev = s.GetNode( d->StartNodeID );
            while(prev != NULL)
            {
                t[prev->id].setBounds(prev->tw_start, prev->tw_end);
                char name[40];
                sprintf(name,"t%d",prev->id);
                t[prev->id].setName(name);
                Node * next = s.Next[ prev->id ];
                prev = next;
            }       
        }        

        for(int i = 0; i<request_to_insert->GetNodeCount(); i++)
        {
            Node * n = request_to_insert->GetNode(i);
            t[n->id].setBounds(n->tw_start, n->tw_end);
            char name[40];
            sprintf(name,"t%d",n->id);
            t[n->id].setName(name);
        }

     

    Could you please help in this situation ?.


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: CPLEX ingnoring constraints problem

    Posted 08/14/19 11:48 PM

    Originally posted by: EdKlotz


    If you are not seeing all the constraints you expect, you probably should include the code that creates the constraints as well.   But what is the difference between the request_to_insert list of nodes in the second loop and the linked list in the first loop above?

     

    However, before posting more code, please export an LP file and check which constraints are ignored, and whether they consecutive constraints, or interleaved among legitimate constraints.   And if you haven't already done so, be sure to create names for your constraints to help identify which ones are intended and which ones aren't.

     

    And finally, if it's modest in size, you can actually print out the IloModel object in your C++ program as well, e.g. env.out() << mymodel << endl; 

    That may help as well.


    #CPLEXOptimizers
    #DecisionOptimization