Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  three dimensional data entry

    Posted 05/29/11 02:34 PM

    Originally posted by: behi


    Dear
    I'm beginner for using CPLEX, could you please help me how can I define the data for more than two dimensional arrays

    I have several input data, I could not get them from spreadsheets and it give an error and emphasized for more than two dimension is impossible, Now I want to give the data from data.file
    as follows:
    mod.file
    range pro=1..3;
    range sup=1..4;
    range cus=1..4;
    float cmprosupdisc=...;
    data.file
    cm= [ 1 2 3 4, 1 2 3 4 ,1 2 3 4, 1 2 3 4
    1 2 3 4, 1 2 3 4 ,1 2 3 4, 1 2 3 4
    1 2 3 4, 1 2 3 4 ,1 2 3 4, 1 2 3 4] ;
    but this syntax leads to an error like this: "Data item () unexpected for float ][[]"

    please help me for data entry

    btw another question, is there any compiler that could compile syntax from LINGO to CPLEX?
    Regards
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: three dimensional data entry

    Posted 05/30/11 05:09 PM
    Hi

    maybe you should write

    .mod

    range pro=1..3;
    range sup=1..4;
    range disc=1..4;
    float cm[pro][sup][disc]=...;
    


    and

    .dat

    cm= [[ [1 2 3 4][ 1 2 3 4] [1 2 3 4][ 1 2 3 4]]
    [[1 2 3 4][ 1 2 3 4] [1 2 3 4][ 1 2 3 4]]
    [[1 2 3 4][ 1 2 3 4 ][1 2 3 4][ 1 2 3 4] ]];
    


    Alex
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: three dimensional data entry

    Posted 10/31/17 09:16 AM

    Originally posted by: Kamran_Sr


    Hi,

    I have a parameter as follows which I am not sure how I should write the associated data in .dat file:

     

    int Cost[Commodities][Modes][Arcs] = ...;

    where:

    {string} Commodities = ...;

    {string} Modes = ...;

    tuple

     

    arcs

    {

    string i;

    string j;

    }

    {

    arcs} Arcs= {<i,j> | <k,m,i,j> in Links};

     So how should I write the data for Cost in .dat file.

     

    I would be appreciated if anyone can help.

    Thanks,

    Kamran

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 4.  Re: three dimensional data entry

    Posted 10/31/17 12:09 PM

    Hi,

    .mod

    {string} Commodities = ...;

    {string} Modes = ...;

    tuple link
    {
    string k;
    string m;
    string i;
    string j;
    }

    {link} Links=...;

    tuple

     

    arcs

    {

    string i;

    string j;

    }

    {

    arcs} Arcs= {<i,j> | <k,m,i,j> in Links};

    int Cost[Commodities][Modes][Arcs] = ...;

    .dat

    Commodities={"A","B"};
    Modes={"T"};

    Links={<"A","T","Paris","London">};

    Cost=[[[2]][[3]]];

    works fine

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 5.  Re: three dimensional data entry

    Posted 10/31/17 12:22 PM

    Originally posted by: Kamran_Sr


    Hi Alex,

     

    Thanks for your answer. I am not sure about Cost=[[[2]][[3]]];

    Because in my model I will need to have one value for Cost [A][T][<Paris,London]. It shows the transport cost from Paris to London for Commodity A by transport mode T which means it should be on value.

     

    So how the 2 and 3 will interpret in Cost=[[[2]][[3]]]?

     

    Regards,

    Kamran


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 6.  Re: three dimensional data entry

    Posted 10/31/17 12:28 PM

    Hi,

    so if you turn your ;mod into

     

    {string} Commodities = ...;

    {string} Modes = ...;

    tuple link
    {
    string k;
    string m;
    string i;
    string j;
    }

    {link} Links=...;

    tuple

     

    arcs

    {

    string i;

    string j;

    }

    {

    arcs} Arcs= {<i,j> | <k,m,i,j> in Links};

    int Cost[Commodities][Modes][Arcs] = ...;

    int costA=Cost["A"]["T"][<"Paris","London">];
    int costB=Cost["B"]["T"][<"Paris","London">];

    execute
    {
    writeln(costA);
    writeln(costB);
    }

    then you get

    2
    3

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 7.  Re: three dimensional data entry

    Posted 10/31/17 01:29 PM

    Originally posted by: Kamran_Sr


    Thank you very much.

    But this is difficult to follow the data structure regarding to indices as the number of Commodities or Modes increases. Assume for this .dat file?

     

    Commodities = {first second};

    Modes = { truck, train};

     

    Links = {

    <first,truck,one,two>

    <first,truck,one,three>

    <first,truck,three,four>

    <first,truck,four,two>

     

    <second,truck,three,four>

    <second,truck,five,three>

    <second,truck,four,six>

    <second,truck,five,six>

    <first,train,one,two>

    <first,train,one,three>

    <first,train,three,four>

    <first,train,four,two>

     

    <second,train,three,four>

    <second,train,five,three>

    <second,train,four,six>

    <second,train,five,six>

    };

    Then the Cost [Commodity][Modes][Arcs] would be difficult to follow in .dat file. In other words, How can I write the Cost in .dat for this problem?

     

    Regards,

    Kamran

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 8.  Re: three dimensional data entry

    Posted 10/31/17 01:43 PM

    Hi,

    .mod

     

    {string} Commodities = ...;

    {string} Modes = ...;

    tuple link
    {
    string k;
    string m;
    string i;
    string j;
    }

    {link} Links=...;

    tuple

     

    arcs

    {

    string i;

    string j;

    }

    {

    arcs} Arcs= {<i,j> | <k,m,i,j> in Links};

    int Cost[Commodities][Modes][Arcs] =...;

     

    int costA=Cost["first"]["truck"][<"one","three">];


    execute
    {
    writeln(costA);

    }

    .dat

     Commodities = {first second};

    Modes = { truck, train};

     

    Links = {

    <first,truck,one,two>

    <first,truck,one,three>

    <first,truck,three,four>

    <first,truck,four,two>

     

    <second,truck,three,four>

    <second,truck,five,three>

    <second,truck,four,six>

    <second,truck,five,six>

    <first,train,one,two>

    <first,train,one,three>

    <first,train,three,four>

    <first,train,four,two>

     

    <second,train,three,four>

    <second,train,five,three>

    <second,train,four,six>

    <second,train,five,six>

    };

    Cost=[[[1,2,3,4,5,6][11,2,3,4,5,6]][[1,2,34,4,5,6]]];

     

    works fine

    If you find this difficult, you could write cost in a tuple set with the "#" way:

    
    tuple point
    {
    int x;
    int y;
    }
    point p1=...;
    point p2=...;
    

    In the .dat file, you write:

    
    p1=#<y:1,x:2>#;
    p2=<2,1>;
    

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 9.  Re: three dimensional data entry

    Posted 11/01/17 10:32 AM

    Originally posted by: Kamran_Sr


    Thank you very much Alex. It is solved.


    #DecisionOptimization
    #OPLusingCPLEXOptimizer