Decision Optimization

Decision Optimization

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

 View Only
  • 1.  Sheetread tuple

    Posted Thu July 05, 2018 10:35 AM

    Originally posted by: -3300-


    Hey,

    I try to sheetread data from Excel to CPLEX. The datas are three-dimensional-Array. I created a tuple to import the datas. But I get a lot of errors and I don't know how I can solve the problems. 

     

    Concrete I would like to sheetread the parameters maxLKWKap and minLKWKap.

     

    I enclosed the files. 

     

    I hope you can help me. 


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Sheetread tuple



  • 3.  Re: Sheetread tuple

    Posted Thu July 05, 2018 12:10 PM

    Originally posted by: -3300-


    Hey Alex, 

    thank you for your answer. Is there no possibility to do it with a tuple?

     

    At first I tried the other opportunity of the link. But I got the error operator Range*Range it not allowed. 


    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: Sheetread tuple

    Posted Thu July 05, 2018 12:17 PM

    Hi,

    you first read a tuple set and then you could turn that into a 3D array

    regards


    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: Sheetread tuple

    Posted Thu July 05, 2018 12:34 PM

    Originally posted by: -3300-


    Hey,

    I'm not sure how you mean this one. 

    I tired to change the mod.-file to that answer. But I have also an error. 

    Perhaps you can look on my new mod-file?


    #CPLEXOptimizers
    #DecisionOptimization


  • 6.  Re: Sheetread tuple

    Posted Thu July 05, 2018 02:12 PM

    What error do you get? What looks odd at first glance is this:

            tuple LKW{
                 int i;
             int j;
             int r;
             float values;  
            };
            
                setof (LKW) MinLKWKap = (<i,j,r> | i in source, j in destination, r in MinTransportkap );

    The tuple LKW has 4 elements but you initialize only 3.

    Concerning your array initialization, from glancing at your model (I did not check that), I think you need something like that

    tuple LKWKapazitaet {
       int source;
       int destination;
       int kap;
       float value;
    }
    {LKWKapazitaet} MaxLKWKapData = ...;
    MaxLKWKapData                       from SheetRead (my_sheet,"'Transportkapazitaet'!F2:I481"); // this in the .dat

    This should get the data directly into the .mod. Then, to create the 3D array from that:

    float MaxLKWKap[source][destination][MaxTransportkap];
    execute {
       for (var lkw in MaxLKWKapData) MaxLKWKap[lkw.source][lkw.destination][lkw.kapa] = lkw.value;
    }

    Similarly for the minimal capacity. Not sure this is the best approach, but I think it works :-)


    #CPLEXOptimizers
    #DecisionOptimization


  • 7.  Re: Sheetread tuple

    Posted Fri July 06, 2018 01:50 AM

    Originally posted by: -3300-


    Tank you! The answer helps me a lot.


    #CPLEXOptimizers
    #DecisionOptimization