Decision Optimization

Decision Optimization

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

 View Only
Expand all | Collapse all

Flow Balance

  • 1.  Flow Balance

    Posted Mon June 22, 2020 05:16 PM
    Hi all,

    I am writing a flow balance constraints for a multicommodity flow problem. devision variable is x-kst, representing flow or order k arrive at the destination of service s at time t by service s.

    forall(k in orders, j in orders_nodes[k])
    sum (<n,<i,j>,dt,c,tt,dist,cap,f> in services:<i,j> in orders_arcs[k],t in time) x[k][<n,<i,j>,dt,c,tt,dist,cap,f>][t]
    - sum (<n,<j,i>,dt,c,tt,dist,cap,f> in services:<j,i> in orders_arcs[k],t in time) x[k][<n,<j,i>,dt,c,tt,dist,cap,f>][t] == k.SupDem[j];

    However, some arcs which are not belonging to order k (not in the set of orders_arcs[k]) ,  are also selected. I mean that flow should not pass by those arcs not in its possible arcs. How to deal with it?

    ------------------------------
    Dario Pisinger
    ------------------------------

    #DecisionOptimization


  • 2.  RE: Flow Balance

    Posted Tue June 23, 2020 12:53 AM
    What exactly do you mean by "selected"? Do you mean that the arcs appear in the constraint even though <i,j> is not in order_arcs[k]? Or do you mean that in the solution some arcs have non-zero values although they should not?

    The former would sound like a bug, could you provide a short example that reproduces the issue?

    The latter seems easy to fix: add an explicit constraints that sets arcs to 0 for all arcs that are not in order_arcs[k].

    ------------------------------
    Daniel Junglas
    ------------------------------



  • 3.  RE: Flow Balance

    Posted Wed June 24, 2020 07:24 AM
    Hi Daniel,
    The arcs of each order are defined as followed.
    orders_arcs=[
    {<"Yinchuan","Lanzhou">,<"Lanzhou","AlatawShankou">,<"AlatawShankou","Hamburg">,
    <"Yinchuan","Tianjin">,<"Tianjin","Pireas">,<"Pireas","Hamburg">},

    {<"Shanghai","Manzhouli">,<"Manzhouli","Hamburg">,
    <"Shanghai","Pireas">,<"Pireas","Hamburg">},

    {<"Zhengzhou","Erenhot">,<"Erenhot","Hamburg">,
    <"Zhengzhou","Lianyungang">,<"Lianyungang","Pireas">,<"Pireas","Hamburg">}];

    Services includes:
    services = {
    < 1,<"Yinchuan","Lanzhou">, 0, 316, 3, 346,45,1>, 
    < 2,<"Yinchuan","Lanzhou">, 0, 212, 2, 370, 1000, 1>, 
    < 3,<"Lanzhou","AlatawShankou">,5,1380,3,2057,45,2>, 
    < 4,<"AlatawShankou","Hamburg">,10,3220,8,5107,45,2>, 
    < 5,<"Yinchuan","Tianjin">,0,761,6,1074,45,1>, 
    < 6,<"Tianjin","Pireas">,7,924,26,15790,20000,7>, 
    < 7,<"Shanghai","Manzhouli">,0,1843,4,2881,45,3>,
    < 8,<"Manzhouli","Hamburg">,5,5957,10,6873,45,3>, 
    < 9,<"Shanghai","Pireas">,1,721,20,14390,20000,7>, 
    < 10,<"Shanghai","Pireas">,8,721,20,14390,20000,7>,
    < 11,<"Zhengzhou","Erenhot">,0,828,5,1364,45,3>, 
    < 12,<"Erenhot","Hamburg">,6,5622,10,7553,45,3>, 
    < 13,<"Zhengzhou","Lianyungang">,0,481,2,525,1000,1>,
    < 14,<"Zhengzhou","Lianyungang">,0,367,5,525,45,1>, 
    < 15,<"Lianyungang","Pireas">,6,952,22,603,20000,7>, 
    < 16,<"Pireas","Hamburg">,30,230,6,5850,20000,7>, 
    < 17,<"Pireas","Hamburg">,36,300,2,2025,45,1> }; 

    Result of order 3 consists of:
    x-kst is:
    via arc <"Lanzhou" "AlatawShankou"> time is 34
    via arc <"Zhengzhou" "Lianyungang"> time is 5
    via arc <"Lianyungang" "Pireas"> time is 28
    via arc <"Pireas" "Hamburg"> time is 38

    Where arc  <"Lanzhou" "AlatawShankou"> can only be selected by order 2, since it only appears in order_arcs[2]. Do you know how to solve it?


    ------------------------------
    Dario Pisinger
    ------------------------------



  • 4.  RE: Flow Balance

    Posted Thu June 25, 2020 06:18 AM
    It seems you have to add a constraint that forces x to 0 for any k and any arc that is not in order_arcs[k]? Something like
    forall(k in orders, a in arcs : !(a in order_arcs[k])) forall(/* here all the other index sets */) x[...] == 0;

    ------------------------------
    Daniel Junglas
    ------------------------------



  • 5.  RE: Flow Balance

    Posted Thu June 25, 2020 09:38 AM
    Hi Daniel,

    After adding constraints, there are some conflicts like these. Can you tell me how to find the conflict? How to find which costraints have conflict? 


    ------------------------------
    Dario Pisinger
    ------------------------------



  • 6.  RE: Flow Balance

    Posted Fri June 26, 2020 04:44 AM
    Conflicts are displayed in a dedicated view.
    It works only if the model does not have a main() block.



    ------------------------------
    Frederic Delhoume
    ------------------------------



  • 7.  RE: Flow Balance

    Posted Fri June 26, 2020 09:49 AM
    Hi Frederic,

    Thanks for your answer. How to find these information? Why is it empty in my view?


    ------------------------------
    Dario Pisinger
    ------------------------------



  • 8.  RE: Flow Balance

    Posted Fri June 26, 2020 10:07 AM
    Edited by System Admin Fri January 20, 2023 04:31 PM
    Some OPL features such as  conflicts or relaxations relies on named constraints, so you may uncomment line 89 or name your individual constraints just like in the sched_conflict model.

    You can also use oplrun -conflicts that should give the same output as the IDE.

    ------------------------------
    Frederic Delhoume
    ------------------------------



  • 9.  RE: Flow Balance

    Posted Fri June 26, 2020 10:34 AM
    Hi Frederic,

    Thanks for your suggestion. I will name my constraints.

    I find CP language is different with CPLEX language. I use CP to solve a model writen by CPLEX language and get some "correct" results. Is it correct? Would mind sharing some links to study CP language?

    ------------------------------
    Dario Pisinger
    ------------------------------



  • 10.  RE: Flow Balance

    Posted Fri June 26, 2020 10:43 AM
    Edited by System Admin Fri January 20, 2023 04:34 PM
    I can only point to the IDE online help, accessible through menu Help / Help Contents.
    There you will find info on CPO and CPO in OPL.

    You will also find lots of OPL CPO sample models, available in File / Import / Example then tab "Sorted by technique" and "Constraint Programming"

    ------------------------------
    Frederic Delhoume
    ------------------------------



  • 11.  RE: Flow Balance

    Posted Fri June 26, 2020 10:48 AM
    Great!   Thanks a lot, especially for your quick and patient reply.  Have a good day!

    ------------------------------
    Dario Pisinger
    ------------------------------