Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Declaring Arrays on Sets in ILOG Script

    Posted 06/13/10 03:57 AM

    Originally posted by: UDOPS


    How do I declare an array on a set, in ILOG script? I see the example in the documentation, but it is only for one dimensional arrays.

    I want to declare an array on a two element tuple, as:

    var LambdaBlock = new Array(relaxinstance.BlockOccupied);

    Then I want to update data values indexed on the set:

    for (updatelambdablockoccupied in relaxinstance.BlockOccupied) {
    deriveddata.LambdaBlockupdatelambdablockoccupied = LambdaBlockupdatelambdablockoccupied;
    }

    The error is "unknown property".
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: Declaring Arrays on Sets in ILOG Script

    Posted 06/14/10 04:17 AM

    Originally posted by: SystemAdmin


    I didn't get the point!
    Can you set up a small standalone model to point out
    the problem?

    Regards
    Norbert
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: Declaring Arrays on Sets in ILOG Script

    Posted 06/14/10 01:36 PM

    Originally posted by: UDOPS


    Model elements:

    tuple blocktime {int block; int time;}

    {blocktime} BlockOccupied=...;

    float LambdaBlockBlockOccupied=...;

    The index is a tuple, dimension 2.

    If I wish to pass this information to another model in ILOG Script, following the Lagrangian example in the distribution, then my problem is that I see no way to define array variables with a tuple index.

    My workaround has been to script the writing of a .dat file at each iteration and then to re-read the data from the .dat file.
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 4.  Re: Declaring Arrays on Sets in ILOG Script

    Posted 06/14/10 01:38 PM

    Originally posted by: UDOPS


    I just noted that when I copy and paste into this message, all of my square bracket characters disappear. In the samples I posted, there were square brackets around the indices [].
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 5.  Re: Declaring Arrays on Sets in ILOG Script

    Posted 06/15/10 06:28 AM

    Originally posted by: SystemAdmin


    Talking in code ...

    tuple blocktime {int block; int time;}
    {blocktime} BlockOccupied={<1,2>, <2,12>};
    float LambdaBlock[BlockOccupied]=[12.0, 3.0];
     
    execute{
        var arrLambdaBlock = new Array(BlockOccupied);
     
        for (var i in BlockOccupied) {
          arrLambdaBlock[i] = LambdaBlock[i];
        }
        writeln("arrLambdaBlock = ");
        for(var j in BlockOccupied)
          writeln(j, " --> ", arrLambdaBlock[j]);
    }
    


    Is that what you want to do?
    The snippet works fine ...

    Regards
    Norbert
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 6.  Re: Declaring Arrays on Sets in ILOG Script

    Posted 06/15/10 05:40 PM

    Originally posted by: UDOPS


    Is it possible your example will behave differently if executed in ILOG Script, instead of within OPL statement?

    I have not tried to debug it further today.
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 7.  Re: Declaring Arrays on Sets in ILOG Script

    Posted 06/16/10 01:48 AM

    Originally posted by: SystemAdmin


    In case I change it to
    tuple blocktime {int block; int time;}
    {blocktime} BlockOccupied={<1,2>, <2,12>};
    float LambdaBlock[BlockOccupied]=[12.0, 3.0];
     
    minimize 0;
    subject to{
    }
     
    main{
      thisOplModel.generate();
      var arrLambdaBlock = new Array(thisOplModel.BlockOccupied);
     
      for (var i in thisOplModel.BlockOccupied) {
          arrLambdaBlock[i] = thisOplModel.LambdaBlock[i];
      }
      writeln("arrLambdaBlock = ");
      for(var j in thisOplModel.BlockOccupied)
          writeln(j, " --> ", arrLambdaBlock[j]);
    }
    

    It works as well...
    Is that what you had in mind?

    Regards
    Norbert
    #DecisionOptimization
    #OPLusingCPLEXOptimizer