Decision Optimization

Decision Optimization

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

 View Only
Expand all | Collapse all

arc capacity with tuple

  • 1.  arc capacity with tuple

    Posted Mon December 09, 2019 10:21 AM

    Originally posted by: xinzhangandy


    Hi, I have some questions about multi-commodity network optimization. Here is the service capacity of arcs, which are identified as tuple.
    tuple Arc { 
      string fromnode; 
      string tonode;
      }//arcs between any two nodes
      
     tuple Order{   OD pairs with origin and destination
     {string} st_node;
     {string} ed_node;
     {string} m_nodes;
     float volume;
     float due_time;
     }
     
     Order orders[q]=...;// multi-commodity
    {Arc} arc_orders[q]=...;// possible arcs of every order
     
    tuple Service {  
       Arc a;    
       float dept_time;
       float cost;
       float traveling_time; 
       float distance;
       float transport_capacity;
       float frequency;}
    Service services[f] = ...;
     
    The service capacity of arc(i,j) is the number of containers of all orders that can be transited by a transport service.
    forall(s in f)// services tuple
      forall(k in q)//orders tuple
        forall(<i,j> in arc_orders[k])
    sum(k in q)orders[k].volume*x[k][i][j] <= services[s].transport_capacity *y[s];
     
    Errors include:
    CPLEX(default) forall(s in 1..17) (forall(k in 1..3) (forall(<i,j> in arc_orders[k]) sum(k in 1..3) orders[k].volume*x[k][i][j] <= services[s].transport_capacity*y[s])) 
     
    CPLEX(default) sum(k in 1..3) orders[k].volume*x[k][i][j] <= services[s].transport_capacity*y[s] 
     
    OPL forall(<i,j> in arc_orders[k]) sum(k in 1..3) orders[k].volume*x[k][i][j] <= services[s].transport_capacity*y[s] 
     
    OPL forall(s in 1..17) (forall(k in 1..3) (forall(<i,j> in arc_orders[k]) sum(k in 1..3) orders[k].volume*x[k][i][j] <= services[s].transport_capacity*y[s])) 


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: arc capacity with tuple

    Posted Mon December 09, 2019 01:42 PM

    Hi,

    let me help you with the syntax

    range q=1..1;
    range f=2..2;

    tuple Arc {
      string fromnode;
      string tonode;
      }//arcs between any two nodes
     
     tuple Order{   
     {string} st_node;
     {string} ed_node;
     {string} m_nodes;
     float volume;
     float due_time;
     }
     
     Order orders[q]=[<{"A"},{"B"},{"C"},1,2>];// multi-commodity
    {Arc} arc_orders[q]=[{<"A","B">}];// possible arcs of every order
     
    tuple Service {  
       Arc a;    
       float dept_time;
       float cost;
       float traveling_time;
       float distance;   float transport_capacity;
       float frequency;};
    Service services[f] = [<<"A","B">,1,2,3,4,5,6>];

    {string} se={"A","B"};
     
     dvar int x[q][se][se];
     dvar int y[f];
     
    subject to
    {
    forall(s in f)// services tuple
      forall(k in q)//orders tuple
        forall(<i,j> in arc_orders[k])
    sum(k in q)orders[k].volume*x[k][i][j] <= services[s].transport_capacity *y[s];

    }

    works fine

    So do not hesitate to post your .mod and .dat so that other users can help you

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer