Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  mutidimensional arrays for tuple

    Posted 04/01/10 01:18 PM

    Originally posted by: mhoang


    Hi all,
    I want to read data of a 2-dimensional array named coverArcsCustomer: one dimension for arcs represented by two nodes, and other for customers. I coded in OPL IDE like following:

    int NumNodes = ...;//number of nodes
    range Nodes = 0..NumNodes;
    int NumCus = ...;//number of customers
    range Cus=1..Numcus;

    tuple arc {
    key int fromnode;
    key int tonode;
    fload cost;
    }
    {arc} Arcs with fromnode in Nodes, tonode in Nodes = ...;
    int coverArcs, Cus=...;

    But an error was noticed "Data tuple unexepected for intArcsCus.

    I think this error is due to "multidimensional arrays are not supported in tuples". But i don't know how to solve this problem.

    Thanks for your hepl.

    Minh Hoang.
    #ConstraintProgramming-General
    #DecisionOptimization


  • 2.  Re: mutidimensional arrays for tuple

    Posted 04/02/10 04:36 AM

    Originally posted by: GGR


    Hi

    Actually, you're right, array cannot be a field of a tuple, a tuple field can only by based type, tuple and tupleset.

    You must adapt the content if the .dat files to that convention.

    Notice you can eventually use the access to excell sheets.

    Cheers
    #ConstraintProgramming-General
    #DecisionOptimization


  • 3.  Re: mutidimensional arrays for tuple

    Posted 04/02/10 06:51 AM

    Originally posted by: Didier Vidal


    I believe it should work. Here is an example of code and dat file that runs. Maybe the issue in the input data ?

    
    
    
    int NumNodes = 3;
    //number of nodes range Nodes = 0..NumNodes; 
    
    int NumCus = 2;
    //number of customers range Cus=1..NumCus;   tuple arc 
    { key 
    
    int fromnode; key 
    
    int tonode; 
    
    float cost; 
    }; 
    {arc
    } Arcs with fromnode in Nodes, tonode in Nodes = 
    {<2,1, 1.5>, <3,3, 2.6>
    }; 
    
    int cover [Arcs][Cus]= ...;   execute 
    { writeln(cover); 
    }
    


    And the data
    
    cover = #[ <2,1> : [0, 1], <3,3> : [1,2] ]#;
    


    Didier.
    #ConstraintProgramming-General
    #DecisionOptimization


  • 4.  Re: mutidimensional arrays for tuple

    Posted 04/02/10 07:48 AM

    Originally posted by: mhoang


    Thank you so much, GGR and Didier.

    So, it works with data type:

    cover = #[
    <2,1> : 0, 1,
    <3,3> : 1,2] #;

    and doesn't work with data tpye:
    cover = [
    0, 1,
    1,2] ;

    My problem was solved. Thank you once again.
    #ConstraintProgramming-General
    #DecisionOptimization