Decision Optimization

Decision Optimization

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

 View Only
  • 1.  Solving TSP with CP Optimizer

    Posted Tue June 27, 2017 09:30 AM

    Originally posted by: c-c-blum


    Hello everyone!

    I would need to know how to solve the TSP with CP Optimizer using C++. Can someone point me to an efficient model please?

    Best regards!


    #CPOptimizer
    #DecisionOptimization


  • 2.  Re: Solving TSP with CP Optimizer

    Posted Tue June 27, 2017 10:19 AM

    Hi,

    could https://www.ibm.com/developerworks/community/forums/html/topic?id=5efb1db1-c642-4877-af60-b330f959a534&ps=25

    help ?

    This shows you some ideas in OPL but you could do the same with C++

    regards


    #CPOptimizer
    #DecisionOptimization


  • 3.  Re: Solving TSP with CP Optimizer

    Posted Wed June 28, 2017 03:34 AM

    Originally posted by: c-c-blum


    Hi! Thanks for your answer. Yes, this could definitely help.

    Is there a way to translate OPL models into the corresponding C++ code? (I only know how to program CP optimizer in C++). Otherwise, I will have to learn OPL.

    Thanks in advance!


    #CPOptimizer
    #DecisionOptimization


  • 4.  Re: Solving TSP with CP Optimizer

    Posted Wed June 28, 2017 07:17 AM

    Hi,

    all OPL objects hide concert objects so you could either translate to C++ or call OPL from C++.

    You have some examples in

    CPLEX_Studio1271\opl\examples\opl_interfaces\cpp

    regards


    #CPOptimizer
    #DecisionOptimization


  • 5.  Re: Solving TSP with CP Optimizer

    Posted Tue July 11, 2017 10:07 AM

    Originally posted by: JorisK


    The common way to implement this problem is as follows:

    1. Define an interval variable for every city. Designate one of the cities the 'starting city'. Introduce a copy of this city as the 'ending city'. So a tsp solution would be: [start_city, 3,2,4,5, end_city]. In this example, the distance from city 5 to end_city would be equal to the distance from 5 to the start_city.

    2. Create a no-overlap sequence of the interval variables. This constraint also takes a matrix containing the distances between every city. Use 'first(start_city,seq)' and 'last(start_city,seq)' constraints to enforce that these 2 interval variables are resp the first and last in your sequence.

    3. Specify the objective function: minimize endOf(end_city)


    #CPOptimizer
    #DecisionOptimization