Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  lastIndexOf

    Posted 04/19/16 02:43 PM

    Originally posted by: JPatrick


    Hi,  

    When I try to define a int parameter value using:

    int Blanks [Tests,Days]=...;

     

    string NumberOfWeeks = Blanks[1,Days];
    int W = NumberOfWeeks.lastIndexOf("10");

    Blanks is a matrix with zeros and ones and I am trying to find the index of the highest value d in  "Days" for which Blanks[1,d] contains a 1 in it.  The error message I get is

    "sytnax error, unexpected '(', expecting ';'

    I also tried using last-index-of instead and go the message

    "expecting a tuple and got a string"

    JP


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: lastIndexOf

    Posted 04/20/16 03:38 AM

    Hi,

    let me give you an example :

    range Tests=1..4;
    range Days=1..3;

    int Blanks [Tests,Days]=[[0, 0, 1],[1, 1, 0],[0, 0 ,0],[1,1,1]];

    int maxOfDaysWith1[t in Tests]=max(d in Days:Blanks[t,d]==1) d;

    execute
    {
    writeln(Blanks);
    writeln(maxOfDaysWith1);
    }

    which gives

    [[0 0 1]
             [1 1 0]
             [0 0 0]
             [1 1 1]]
     [3 2 -9007199254740991 3]

    regards

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: lastIndexOf

    Posted 04/20/16 09:34 AM

    Originally posted by: JPatrick


    That works.  Thanks.


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 4.  Re: lastIndexOf

    Posted 04/20/16 10:27 AM

    Originally posted by: JPatrick


    On a separate question....  when a constraint is violated OPL will tell me by giving me something like 

     

    Constraint#0#1#2 

    I understand that the numbers refer to the indices of the constraint.  What I am wondering about is the ordering if the indices are not numbers. For instance, I have indices that consist of a list of initials.  Does OPL maintain the order in which the list was read into it from Excel?  Does it order them alphabetically so that #0 would refer to the first initials in an alphabetized list?


    #DecisionOptimization
    #OPLusingCPLEXOptimizer