Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  About the Optimization problem and The custom search

    Posted 04/13/16 11:09 PM

    Originally posted by: Jacky W


    Hello guys:

                I have some questions about the custom search of optimization in the cp engine.

                First the problem is an optimization problem not a satisfication problem. I have used the IlcOr and IlcAnd construct the search tree (that can be regarded as all feasible solution for any leaf node). What i should do is finding a optimal solution by traversing all leaf node. But the problem I meet is the property of IlcOr. for the choice point of subgoals, only if the one point of subgoal is fails, the other point  of subgoal is extracted and executed. but for every subgoal, it's actual succeed (because it's a feasible solution) so it will not traverse another subgoal. so the optimal solution isn't obtained. So any reply for me? I'm very grateful.

               The extended question is if the subgoal is fail, but i want to restore its some information such as some values of variables in that status, what i can do for this purpose?


    #ConstraintProgramming-General
    #DecisionOptimization


  • 2.  Re: About the Optimization problem and The custom search

    Posted 04/15/16 10:10 AM

    Originally posted by: ChrisBr


    Hello Jacky,

    To help you, we need to better know your process:
    How did you launch the resolution?
    Have you set an objective?
    Did you call solve? next?
    Regards,

    Chris.

     


    #ConstraintProgramming-General
    #DecisionOptimization


  • 3.  Re: About the Optimization problem and The custom search

    Posted 04/19/16 10:52 PM

    Originally posted by: Jacky W


    Yes, my problem consists of a set of items with width and length and some precedence constraint.  My basic logic idea of solving problem is that select sequencely (random) an unpacked item, and then construct a set of "admissible point", select sequencely (random) an untried admissible point. an item and a point chosen is a branch node, In the next, we duplicate the action above untill all items are packed. Because the problem is optimization problem(I have set an objective). so at every node, except for searching in deeper,  I also have use the IlcOr to search for all possible condition.That is traverse. I call the solve() method.


    #ConstraintProgramming-General
    #DecisionOptimization


  • 4.  Re: About the Optimization problem and The custom search

    Posted 04/19/16 11:04 PM

    Originally posted by: Jacky W


    The problem maybe is solved by me using an unsophisticated method. If you have any idea about that, please kindly tell me. Appreciate.

    But there is a new question worried me that is the memory use. Even if there is only 10 items, there is a question about the overflow of memory use when running the programming. Check over it, i think it's possible that I had use Some IloIntArray and IloIntArray2 to construct and addmissible point introduced in the previous reply and don't free the memory after use them. So how can i free the memory of IloIntArray or IloIntArray2 in the IlcGoal defined by myself of cp engine. use the member function end()? It seems don't work.


    #ConstraintProgramming-General
    #DecisionOptimization


  • 5.  Re: About the Optimization problem and The custom search

    Posted 04/20/16 12:12 PM

    Originally posted by: Petr Vilím


    Hello,

    yes, end() function deletes the object and frees the memory. Maybe you have another memory leak somewhere else?

    Ideally, custom IlcGoal should not create a new data structures otherwise the memory can easily overflow. If you need some data structure, maybe you can share it and pass it around as one of the parameters?

    Best regards, Petr


    #ConstraintProgramming-General
    #DecisionOptimization


  • 6.  Re: About the Optimization problem and The custom search

    Posted 04/20/16 09:29 PM

    Originally posted by: Jacky W


    Yes, i know it's not a better action that creat a data structure especially the creation happened at every branch node. But  the reality is the data is produced dynamically during the search and the size of data is not known in advance. so i can't share it and pass it around as one of the parameters. Meeting this kind of problem, any good suggestion for me? For the member function end(), i'm sure about i indeed use them after the data structure. but it seems not works. Maybe you are right. have another memory leak somewhere, but except for the data structure created during search, i think no other place can cause the memory leak. 


    #ConstraintProgramming-General
    #DecisionOptimization


  • 7.  Re: About the Optimization problem and The custom search

    Posted 04/21/16 03:40 AM

    Originally posted by: Petr Vilím


    Hello Jacky,

    thinking about it, there is one more catch. Maybe you do in your goal something like this:

    IloIntArray array(env);
    ...
    someVariable.setMax(...);
    ...
    array.end();
    

    The problem is that someVariable.setMax triggers constraint propagation that may end up by fail (i.e. the problem is found infeasible). In that case the function setMax never returns. Instead CP Optimizer backtracks and go into a different branch. As the result array.end() is never called and the memory is leaking. Since you say that end() function doesn't work for you, this could be the reason.

    So, if you really have to allocate some memory in the goal, the best solution is to free it before affecting the first decision variable. All the other memory should be shared. So, for example, you may allocate your data structure(s), compute what you're going to do, but instead of doing it immediately, store those actions in a shared array. Then destroy your local data structures and only then execute the planned actions from the shared array. When fail occurs then the shared array will remain dirty, but the memory doesn't leak. You just have to keep in mind that the shared array may be dirty each time when the goal starts, so you need to clear it first every time.

    Maybe you don't even need the shared array. If you affect only one variable in your goal then just postpone the setMax/Min/StartMin etc until the memory is freed.

    Petr


    #ConstraintProgramming-General
    #DecisionOptimization


  • 8.  Re: About the Optimization problem and The custom search

    Posted 04/21/16 05:04 AM

    Originally posted by: Jacky W


    Hello Petr,

    Thank your reply. It seems to give me a epiphany. I think i have at least two method to solve my problem. But for the purpose of better execution, i have to ask for what's the shared array? how to define it? use the global IloIntArray?

    Even if talk about the memory, i have additional question after i have learn about the cp.getHeap of tutorial in ILOG CPLEX. It introduces to me that if i use the IloInt* a=new (cp.getHeap) IloInt[size] in the choice point, i can't use the delete []a to free the memory as a result of the automatic free when the backtracking. If i use the IloInt* a=new IloInt[size] in the cp engine, i alse can't use the delete as a result of the automatic free when the env.end(). Is it right? if i want to creat (new ) and delete this by myself, what can i do?


    #ConstraintProgramming-General
    #DecisionOptimization


  • 9.  Re: About the Optimization problem and The custom search

    Posted 04/21/16 05:35 AM

    Originally posted by: Petr Vilím


    Yes, what I meant by a shared array is an array you can pass by parameter between the goals. And yes, it could be IloArray. Just add it as an additional parameter to ILCGOALn macro.

    Allocation on cp.getHeap() are automatically freed during backtracking. So when fail occurs, the memory is freed automatically. It could be another way to solve your problem. On the other hand, memory allocated on cp.getHeap() cannot be freed any other way then by backtracking. If your search tree isn't deep then it is probably not a problem. But if it is deep or the arrays are very large then you shouldn't use cp.getHeap(). You may just try and see since this change is not very hard to implement.

    Petr


    #ConstraintProgramming-General
    #DecisionOptimization