Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Handling memory when restarting a search

    Posted 04/09/08 01:21 AM

    Originally posted by: SystemAdmin


    [Sylvain said:]

    I would like to solve many (~1000) CP problems using different goals on the exact same model.
    To do that I simply create a goal, solve the model using IloSolver::solve(IloGoal goal), end the goal, create a new one, ...
    My problem is that the memory used by the solver keeps increasing in the process.
    It seems that the instance of IloSolver keeps track of previous searches even though I don't need it.
    If I re-extract the model before solving at each step, the memory problem disappears as the solver probably clears its heap before extracing. But it takes much more time for extracting the same model.

    Is there any way to circumvent this problem in a low time/memory consuming way ?


    #CPOptimizer
    #DecisionOptimization


  • 2.  Re: Handling memory when restarting a search

    Posted 04/16/08 09:18 PM

    Originally posted by: SystemAdmin


    [Jean-Charles Regin said:]

    Dear Sylvain,

    From what you describes it seems there is a problem. Normally the goals should be safely and effectively deleted.
    Could you please either send a code here, or contact the support of ILOG?

    Thanks


    #CPOptimizer
    #DecisionOptimization


  • 3.  Re: Handling memory when restarting a search

    Posted 04/17/08 12:06 AM

    Originally posted by: SystemAdmin


    [Sylvain said:]

    Ok here's a small example :

    IloInt n = 100;
    IloIntVarArray vars(env, n, 0, n-1);
    IloIntVarArray cards(env, n, 0, 2);
    IloModel model(env);
    model.add(IloDistribute(env, cards, vars));
    IloSolver solver(model);
    for(i = 0; i < 100000000000000; i++)<br />  solver.solve(IloGenerate(env, vars));
    solver.printInformation();

    The memory keeps increasing while solving the same exact problem in the for loop.
    I am using Ilog Solver 6.3.


    #CPOptimizer
    #DecisionOptimization


  • 4.  Re: Handling memory when restarting a search

    Posted 04/24/08 10:59 AM

    Originally posted by: SystemAdmin


    [shaw said:]

    Hello Sylvian,

    You recreate the goal each time in the loop.  You can do:

    IloGoal g = IloGenerate(env, vars);
    for (...) {
      solver.solve(g);
    }


    Paul
    #CPOptimizer
    #DecisionOptimization


  • 5.  Re: Handling memory when restarting a search

    Posted 05/10/08 03:46 AM

    Originally posted by: SystemAdmin


    [Sylvain said:]

    Ok my mistake for that.
    But I still have this problem of increasing memory and I think it comes from the fact that the goal I am using is different at each step.
    From my experiments, it seems that Solver stores the states it reaches and restores them when it is useful.

    For example, let's say I have two goals, the first one branching on x==1 then y==1, and the second one branching on x==1 then y==0.
    If I executed the two goals successively, when the second one is used, Solver will restore the state reached during the first goal while branching on x==1 (without doing constraint propagation) and then branch on y==0.

    Is it correct ? If so, this would explain why I see the memory increasing when trying different goals and why it does not happen when re-extracting the model at each step.

    #CPOptimizer
    #DecisionOptimization


  • 6.  Re: Handling memory when restarting a search

    Posted 05/13/08 03:25 PM

    Originally posted by: SystemAdmin


    [shaw said:]

    Hello Sylvain,

    Can you post the current code please?



    Paul
    #CPOptimizer
    #DecisionOptimization


  • 7.  Re: Handling memory when restarting a search

    Posted 05/15/08 01:44 AM

    Originally posted by: SystemAdmin


    [Sylvain said:]

    I figured that my problem comes from the following goal that I defined.
    It seems that I need to end the contraints I want to apply.
    How could I do that ?
    Thanks for your help.

    IloGoal IloSetVarsGoal(IloEnv env, IloNumVarArray vars, IloNumArray vals)
    {
    assert(vars.getSize() == vals.getSize());
    assert(vars.getSize() > 0);
    IloConstraint cst = (vars[0] == vals[0]);
    for(IloInt i = 1; i < vars.getSize(); i++)<br /> cst = cst && (vars[i] == vals[i]);
    return IloAddConstraint(cst);
    }


    #CPOptimizer
    #DecisionOptimization


  • 8.  Re: Handling memory when restarting a search

    Posted 05/15/08 01:48 PM

    Originally posted by: SystemAdmin


    [shaw said:]

    The simplest way is to do this in the Ilc world, because then all the
    memory allocation is handled automatically, and you don't need to
    delete everything individually.  See the code below:

    ILCGOAL2(SetVars, IlcIntVarArray, vars, IlcIntArray, vals) {
      IlcInt n = vars.getSize();
      assert(n > 0);
      assert(n == vals.getSize());
      IlcConstraint ct = (vars[0] == vals[0]);
      for (IloInt i = 0; i < n; i++)<br />    ct = ct && (vars[i] == vals[i]);
      return ct;
    }

    ILOCPGOALWRAPPER2(SetVars, solver, IloIntVarArray, vars, IloIntArray, vals) {
      return SetVars(solver, solver.getIntVarArray(vars), solver.getIntArray(vals));
    }

    ...

    IloGoal myGoal = SetVars(env, myVars, myVals);

    #CPOptimizer
    #DecisionOptimization