Decision Optimization

Expand all | Collapse all

How to read a tuple from excel on cplex

Jump to Best Answer
  • 1.  How to read a tuple from excel on cplex

    Posted Wed August 19, 2020 03:36 PM
    Hi ;
    How can I read a tuple from excel on cplex . i tried to name the ranges on excel but it doesn't work, please what am i doing wrong here:
    /* .mod file*/
    tuple Operation { 
    int id;
    int jobId;
    int pos; };

    /*.data file*/
    SheetConnection datasheet("dataCPbro.xlsx");
    Ops from SheetRead (datasheet,"'data1'!Opstuple");

    "Opstuple" (8 rows and 3 coloumns) defined in "dataCPbro.xlsx" file:


    ------------------------------
    So jana
    ------------------------------


  • 2.  RE: How to read a tuple from excel on cplex
    Best Answer

    Posted Thu August 20, 2020 12:45 AM
    Edited by So jana Thu August 20, 2020 04:05 AM

    Hi

    if Opstuple is your named range you should write

    Ops from SheetRead (datasheet,"Opstuple");

    instead of 

    Ops from SheetRead (datasheet,"'data1'!Opstuple");


    regards

    PS:

    Simple complete example at https://github.com/AlexFleischerParis/zooopl/blob/master/zooexcel.mod



    ------------------------------
    ALEX FLEISCHER
    ------------------------------



  • 3.  RE: How to read a tuple from excel on cplex

    Posted Thu August 20, 2020 03:01 AM
    Hi Alex;
    I tried this : Ops from SheetRead (datasheet,"Opstuple"); but i get this error:

    Exception dans pré-résolution : Interval sequence variable 'mchs(3)': interval variable 'modes({3,2,3,1,40})' appears more than once in the sequence.

    I don't know what iam doing wrong

    Regards


    ------------------------------
    So jana
    ------------------------------



  • 4.  RE: How to read a tuple from excel on cplex

    Posted Thu August 20, 2020 03:27 AM
    Edited by So jana Thu August 20, 2020 04:05 AM
      |   view attached

    ------------------------------
    So jana

    Attachment(s)

    xlsx
    datasheet.xlsx   9 KB 1 version


  • 5.  RE: How to read a tuple from excel on cplex

    Posted Thu August 20, 2020 03:30 AM
    Hi,

    this means you moved forward since now you do not have issues with reading but with presolve.
    The same interval should not be several times in the sequence.

    regards

    ------------------------------
    ALEX FLEISCHER
    ------------------------------



  • 6.  RE: How to read a tuple from excel on cplex

    Posted Thu August 20, 2020 03:51 AM
    Thank you alex , but i have no idea what i'm doing wrong . Could you help me with this please. i've attached the .mod file and the data one.

    Thank you

    Regards



    ------------------------------
    So jana
    ------------------------------



  • 7.  RE: How to read a tuple from excel on cplex

    Posted Thu August 20, 2020 04:04 AM
    Thank you Alex . I resolved the error i  did a mistake in my data  declaration .

    Have a good day

    Best regards

    ------------------------------
    So jana
    ------------------------------