Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  stating forall statement

    Posted 07/17/08 06:09 AM

    Originally posted by: SystemAdmin


    [agus said:]

    Hi,

    I have a problem in stating the forall statement in my constraints.
    Here is my model:


    {string} Nodes = ...;

    tuple link {
    key int id;
      string p1;
      string p2;
    }

    {link} links = ...;

    tuple flight {
    key string ID;
      string destination;
      string origin;
      string status;
      int OBT;
      int TTD;
      int ETA;
    }

    {flight} Flights = ...;

    tuple linkRelation {
        flight f;
        link l;
    }

    {linkRelation} linkRelations with f in Flights, l in links = ...;

    dvar int+ y[Flights][Flights][Nodes] in 0..1;

    subject to {
    //Overtaking #16
    forall (i, j in Flights: i.ID != j.ID, u, v in ???)
    y[i][j][v] - y[i][j][u] == 0;
    }



    And here is my data file:

    Nodes = {"a", "b", "c", "d"};

    links = {<1, "a", "b">, <2, "b", "c">, <3, "c", "d">};

    Flights = {
    <", "c", "a", "dept", 1, 30, 0>,
    <", "c", "b", "dept", 1, 10, 0>
    };

    linkRelations = {<",1>, <",2>, <",3>, <",2>, <",3>};



    For constraint “Overtaking  #16” I would like “u and v” to be the nodes in the common link between flight i and flight j, where u != v.

    With my data file, the common link between flight “x” and flight “y” are:
    link #2: nodes “b” and “c” --> v = “c” and u = “b” and
    link #3: nodes “c” and “d” --> v = “d” and u = “c”

    The constraints I would like generate from the constraint are the following:
    Y[sub]xyc[/sub] - Y[sub]xyb[/sub] = 0
    Y[sub]yxc[/sub] - Y[sub]yxb[/sub] = 0
    Y[sub]xyd[/sub] - Y[sub]xyc[/sub] = 0
    Y[sub]yxd[/sub] - Y[sub]yxc[/sub] = 0

    How do I state the u and v in the forall statement so that I could generate the preceding constraints?


    subject to {
    //Overtaking #16
    forall (i, j in Flights: i.ID != j.ID, u, v in ???)
    y[i][j][v] - y[i][j][u] == 0;
    }



    Thank you

    Agus

    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: stating forall statement

    Posted 07/17/08 07:48 PM

    Originally posted by: SystemAdmin


    [Didier Vidal said:]

    Assuming you had a flat structures for your links (for instance, <flightId, Node, Node> )

    you could write something like


    forall (<f1, n, x> in Links, <f2, n,y> in links : f1 != f2 )
    y[i][j][v] - y[i][j][u] == 0;
    // and all the combinations that are relevant for you
    orall (<f1, n, x> in Links, <f2, y,n> in links : f1 != f2 )
    y[i][j][v] - y[i][j][u] == 0;



    I think that your model would be easier to write if you tried to limit your tuples to one level of data. At least you can use that kind of implicit matching...


    Now, with your data structure, one can imagine


    forall (i, j in Flights, l1, l2 in linkRelation : i.ID != j.ID && 1l.flight == i && l2.flight == j && l1.p1 == l2.p2)
    y[i][j][l1.p1] - y[i][j][l2.p2] == 0;


    Didier.
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: stating forall statement

    Posted 07/18/08 02:37 AM

    Originally posted by: SystemAdmin


    [agus said:]

    Thanks Didier,

    You gave me an inspiration.

    Here is my final model:

    {string} Nodes = ...;

    tuple link {
    string flightID;
    string p1;
      string p2;
    }

    {link} links = ...;

    tuple flight {
    key string flightID;
      string destination;
      string origin;
      string status;
      int OBT;
      int TTD;
      int ETA;
    }

    {flight} Flights = ...;

    dvar int+ y[Flights][Flights][Nodes] in 0..1;

    subject to {
    //Overtaking #16
    A:
    forall (u, v in Nodes, i,j in Flights, a,b in links: i.flightID != j.flightID
    && a.flightID == i.flightID && b.flightID == j.flightID &&
    u == a.p1 && v == b.p1 && a.p1 == b.p1 && a.p2 == b.p2)
    y[i][j][v] - y[i][j][u] == 0;
    }


    and it works perfectly

    agus
    #DecisionOptimization
    #OPLusingCPLEXOptimizer