Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
Expand all | Collapse all

Accessing an array element based on dvar value

  • 1.  Accessing an array element based on dvar value

    Posted 10/11/12 08:32 AM

    Originally posted by: salais


    Hello all,

    I am working on implementing a model for the TSPTW (Travelling salesman problem with time windows) and am having trouble accomplishing the following:

    I have a distance array indexed with tuples if int i and int j as follows (according to the tsp example)

    int N = 4;
    range Nodes = 1..N;

    tuple edge {int i; int j;}
    setof(edge) Edges = {<i,j> | i,j in Nodes};
    int distEdges = ...;

    After these the array "dist" contains the appropriate values. Additionally, i have a vector of integers+ as a decision variable as follows:

    range Vd = 2..(N+1);
    dvar int+ SNodes in Vd;

    The problem is when i try and define the objective function
    minimize sum (i in Nodes) dist[<i, Si]>;

    However this yields a "cannot extract expression" error.
    CP cannot extract expression: minimize sum(i in 1..4) dist[<i,S(i)]>. MyModel.mod

    What am I missing?

    Also, seems like my last post was deleted for some reason. If this was because of violation of rules of the forum etc. please let me know so I can correct this.
    #CPOptimizer
    #DecisionOptimization


  • 2.  Re: Accessing an array element based on dvar value

    Posted 10/11/12 08:42 AM

    Originally posted by: SystemAdmin


    Hello.

    Your post is not deleted, it is just on a different forum (OPL using CP Optimizer). You can find it on the following address:
    http://www.ibm.com/developerworks/forums/thread.jspa?messageID=14896389

    You can find there also my response.

    Best regards, Petr
    #CPOptimizer
    #DecisionOptimization