Decision Optimization

 View Only
  • 1.  index is a sub tuple

    Posted Mon July 26, 2021 02:42 AM
    Hi all,

    I am working on the multicommodity flow problem. 
    tuple Order{   
     	 key int no;
    	 string origin;
    	 string dest;
    	 int volume;     
    	  }
    	  
    {Order} orders =...;
    
    tuple Path {
    	key int id;
    	int price;
    	{int} sequence;
    }
    
    {Path} paths = ...;
    {Path} orders_paths[k in orders] = ...;


    1. I want to define a int+ variable q[k in orders][p in orders_paths[k]].  Do you know how to define q? The size of orders_paths[k] is different.


    2. I also want to get an matrix a[s in S][p in paths]. S is a set. if  s belongs to p.sequence, then a[s][p] = 1, 0 otherwise. Do you know how to get this matrix automatically?  

    Many thanks.

    ------------------------------
    Ying Qi
    ------------------------------

    #DecisionOptimization


  • 2.  RE: index is a sub tuple

    Posted Tue July 27, 2021 03:57 AM
    Edited by System Fri January 20, 2023 04:36 PM
    Hi,

    in

    Making Decision Optimization Simple


    you could have a look at array variable indexer size - 3 ways : union , tuple set, decision expression

    and for your second question

    {int} S={1,2,3};
     tuple path
     {
       int i;
       {int} Sequence;
     }
     
     {path} paths={<1,{1}>,<3,{3}>};
     
     int a[s in S][p in paths]=(s in p.Sequence);
     
     execute
     {
       writeln(a);
     }​


    gives

    [[1 0]
             [0 0]
             [0 1]]​


    ------------------------------
    [Alex] [Fleischer]
    [EMEA CPLEX Optimization Technical Sales]
    [IBM]
    ------------------------------



  • 3.  RE: index is a sub tuple

    Posted Wed July 28, 2021 04:00 AM
    Hi Alex,

    Thanks for your help! We really appreciate your sharing in LinkedIn and GitHub. These posts do help a lot!!


    The new problem is: Dual infeasible due to empty column 'q({2})({1})'.



    I am working on a bi-level programming problem with the KKT condition actually. I guess the reason for error is because there are different number of paths available for different  orders. 

    For instance, there are two orders and three paths. Order A could select one path from three alternatives (p1, p2 and p3), while Order B could select p2 or p3 only. 
    So decision variables are  q[1][1], q[1][2], q[1][3], q[2][2] and q[2][3]. Then CPLEX can't get a feasible dual formulation.

    Do you have any idea to express q[k][p] more tight?



    ------------------------------
    Ying Qi
    ------------------------------