Decision Optimization

 View Only
  • 1.  Set of Tuples Assignment

    Posted Mon January 26, 2009 03:43 PM

    Originally posted by: SystemAdmin


    [shadi said:]

    hi,

    i have the following two sets of tuples :
    tuple pairCst_T {
      int i;
      int v;
      int bc;
      int DrivingTime;
      int DrivingDistance;
      int BreakTime;
      int DutyPeriod;

    };
    {pairCst_T} pairCst = {};
    {pairCst_T} pairCstTemp = {};

    How to implement the following pseudo code in opl:
    pairCst.clear;
    pairCst=pairCstTemp;

    so the pairCst will have exactly the same tuples as pairCst.

    thanks in advanced
    kshieboun shadi




    #ConstraintProgramming-General
    #DecisionOptimization


  • 2.  Re: Set of Tuples Assignment

    Posted Tue January 27, 2009 12:57 PM

    Originally posted by: SystemAdmin


    [Didier Vidal said:]

    Shadi,

    If your problem is to empty a tupleset in a loop, you might have a look at some code I posted to the forum for a similar situation.
    The code is at http://forums.ilog.com/optimization/index.php/topic,773.msg2451.html#msg2451

    See how the tupleset 'forcedresult' is handled.
    The idea is to have two separate datasources for the second model. One is fixed. The second is built each time you need to recreated the set forcedresult.

    Didier.
    #ConstraintProgramming-General
    #DecisionOptimization


  • 3.  Re: Set of Tuples Assignment

    Posted Tue January 27, 2009 02:59 PM

    Originally posted by: SystemAdmin


    [shadi said:]

    Didier,
    i did the following steps:

    1.  I create a new model file dummy.mod
    tuple pairCst_T {
      int i;
      int v;
      int bc;
      int DrivingTime;
      int DrivingDistance;
      int BreakTime;
      int DutyPeriod;
    };
    {pairCst_T} pairCst = ...;

    2. i create a new data file EmptyTupleSets.dat
        pairCst = {};

    3. in the main block I added the following code:
          var dummy = new IloOplRunConfiguration("dummy.mod");
          dummy.oplModel.addDataSource(new IloOplDataSource("EmptyTupleSets.dat"));
          dummy.oplModel.generate();
    for (var PairCstTempElement in thisOplModel.pairCstTemp) {
    dummy.oplModel.pairCst.add(PairCstTempElement);
        }


    My question now is how to implement the following peudo code:
    thisOplModel.pairCst=dummy.oplModel.pairCst;
    I still have the same problem.

    i dont know why there is no simple function that can empty a tupleset without all this process? i think this process use a lot of time becuase i will need to empty  the tupleset millions times.

    maybe a good solution for my problem if there is way to delete a tuple from a tupleset
    i mean, how I can delete the last tuple from pairCst???
    Thanks in advanced
    Kshieboun shadi

    #ConstraintProgramming-General
    #DecisionOptimization


  • 4.  Re: Set of Tuples Assignment

    Posted Tue January 27, 2009 04:32 PM

    Originally posted by: SystemAdmin


    [Didier Vidal said:]


    My question now is how to implement the following peudo code:
    thisOplModel.pairCst=dummy.oplModel.pairCst;
    I still have the same problem.


    You should have two datasources in your main model. And one for 'pairCst' that is shared with the dummy model. In the example on the other thread, the model "draftcp.mod" has two datasources.



    #ConstraintProgramming-General
    #DecisionOptimization


  • 5.  Re: Set of Tuples Assignment

    Posted Wed January 28, 2009 12:40 PM

    Originally posted by: SystemAdmin


    [Didier Vidal said:]

    i dont know why there is no simple function that can empty a tupleset without all this process?

    I learnt that this function has been introduced in OPL 6.1.1.  It is

    pairCst.clear();


    Hope this helps.

    Didier.
    #ConstraintProgramming-General
    #DecisionOptimization


  • 6.  Re: Set of Tuples Assignment

    Posted Wed January 28, 2009 01:52 PM

    Originally posted by: SystemAdmin


    [shadi said:]

    Dear Didier,
    Thank you so much for your help. It works good now.
    but i see that i have another problem now, i notice that there is memory Consumption while generating and ending the dummy model.
    when i end the dummy configuration it has to end all the object related to this configuration, so it has to free all the memory that used in this configuration.
    but in my case i see that the memory consumption is increasing...
    what i have to do in order to free all the objects used in the dummy configuration.

    thanks in advanced
    Kshieboun Shadi

    #ConstraintProgramming-General
    #DecisionOptimization


  • 7.  Re: Set of Tuples Assignment

    Posted Wed January 28, 2009 06:42 PM

    Originally posted by: SystemAdmin


    [Didier Vidal said:]

    Do you measure the memory usage with
    oplrun -deploy ?

    (the -deploy option activates a minimal memory consumption mode).

    Didier.
    #ConstraintProgramming-General
    #DecisionOptimization


  • 8.  Re: Set of Tuples Assignment

    Posted Fri January 30, 2009 05:46 PM

    Originally posted by: SystemAdmin


    [Didier Vidal said:]

    Shadi,

    Quick follow up.

    It is possible that the creation of an 'IloOplRunConfiguration' uses memory that is not always released in some versions of OPL.

    If this is a case, a workaround would be to decompose the model creation. Here is a code extract from the 'cutstock' example of the OPL distribution that shows this. You will have to adapt the code if you do not use a cplex engine but a cp engine. Unfortunately, I will not have the time to adapt the code before long... I hope anyway that this hint can be useful to you.


      var masterDef = thisOplModel.modelDefinition;
      var masterCplex = cplex;
      var masterOpl = thisOplModel;
      var subSource = new IloOplModelSource("cutstock-sub.mod");
      var subCplex = new IloCplex();
      var subDef = new IloOplModelDefinition(subSource);
      var subOpl0 = new IloOplModel(subDef,subCplex);
      var subData0 = new IloOplDataSource("cutstock-sub.dat");
      subOpl0.addDataSource(subData0);
      subOpl0.generate();

    #ConstraintProgramming-General
    #DecisionOptimization