Decision Optimization

Decision Optimization

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

 View Only
  • 1.  Guide to write CP code for the model of the TSPTW

    Posted Mon January 21, 2019 11:23 AM

    Originally posted by: Lessi


     

    Hi CPers,

    I am familiar with writing MIP models using Concert technology. However, I am totally new with the constraint programming. I want to write the following model using CP.

    The model is attached below since it displays "spam" when I try to attach it here.


    I am not sure how to write the code for constraints (3) and (7). Which part of the manual I should read to do that? This is how I code at the moment.

     

        IloEnv envCP;
        int nbPOIs = candidatePOIs.size();
        try {
            IloModel modelCP(envCP);

            IloIntVarArray pSlaveCP(envCP, nbPOIs, 0, nbPOIs-1); //constraint (6).
            
            modelCP.add(IloAllDiff(envCP, pSlaveCP, "alldifference")); //this is constraint (2)
            modelCP.add(pSlaveCP[0] == 0); //constraint (4)
            modelCP.add(pSlaveCP[nbPOIs - 1] == nbPOIs - 1); //constraint (5) 

            I am not sure how to write the code for constraints (3) and (7)

            }
            
             
        }
        catch (IloException& ex) {
            env.out() << "Error: " << ex << std::endl;
        }
        env.end();

    Thanks,


    /Lessi


    #CPOptimizer
    #DecisionOptimization


  • 2.  Re: Guide to write CP code for the model of the TSPTW

    Posted Mon January 21, 2019 11:31 AM

    Originally posted by: Lessi


     

    This is the model 


    #DecisionOptimization


  • 3.  Re: Guide to write CP code for the model of the TSPTW



  • 4.  Re: Guide to write CP code for the model of the TSPTW

    Posted Mon January 21, 2019 04:45 PM

    Originally posted by: Lessi



    Thank you for your inputs.

    I know those models are equivalent. However, I would like to know if it is possible to write 2*|V| constraints (3) and (7) using CP code instead of writing O(|V|^2) time order constraint as in MIP formulation.


    #CPOptimizer
    #DecisionOptimization


  • 5.  Re: Guide to write CP code for the model of the TSPTW