Decision Optimization

Decision Optimization

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

 View Only
Expand all | Collapse all

Duplicates deleted when reading Excel Spreadsheet

  • 1.  Duplicates deleted when reading Excel Spreadsheet

    Posted Wed November 30, 2016 12:50 PM

    Originally posted by: VerenaL


    Hi everyone,

    I want to integrate numbers from an excel spreadsheet into CPLEX Optimization Studio V12.6.3.

    This is my code:

    /* .mod file */

    {float} Numbers=...;

     

    /* .dat file */

    SheetConnection sheet("D:\\Users\\verena\\opl\\ELG Logistics Optimization\\ReadData.xls");

    Numbers from SheetRead(sheet,"B2:F5");

     

    In general it works as I get a string Numbers with the entries of the cells.

    The problem is that numbers which appear more than once are only apparing in the float array once.

    For example [[1,2],[3,2]] would be the array {1 2 3}.

     

    Do you know how I can get all values?

     

    Thanks in advance,

    Verena


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Duplicates deleted when reading Excel Spreadsheet

    Posted Wed November 30, 2016 02:54 PM

    Hi

     

    this is normal since in a set you cannot have the same element twice.

    I would try to use arrays instead.

    regards


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Duplicates deleted when reading Excel Spreadsheet

    Posted Thu December 01, 2016 02:43 AM

    Originally posted by: VerenaL


    Hi Alex,

    when I define

    /* .mod file */

    {float} Numbers[1..4][1..5]=...;

    how would this part have to look like?

    /* .dat file */

    SheetConnection sheet("D:\\Users\\verena\\opl\\ELG Logistics Optimization\\ReadData.xls");

    Numbers from SheetRead(sheet,"B2:F5");

    If I just try ít like this I get: data element "Numbers" of type float[1..4][1..5] not supported by spreadsheets

     

    Best,

    Verena


    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: Duplicates deleted when reading Excel Spreadsheet

    Posted Thu December 01, 2016 10:36 AM

    Hi,

    why do not you write

    float Numbers[1..4][1..5]=...;

    instead of

    {float} Numbers[1..4][1..5]=...;

    ?

    regards


    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: Duplicates deleted when reading Excel Spreadsheet

    Posted Thu December 01, 2016 03:50 PM

    Originally posted by: VerenaL


    So easy...

    Thanks a lot!


    #CPLEXOptimizers
    #DecisionOptimization