Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Memory Leak when making branches

    Posted 05/07/12 04:39 PM

    Originally posted by: clemsonmacrone


    Hi, I am having a memory leak at the makeBranch() lines of my branch callback routine. Is their something fundamentally wrong with my set up that causes this? note: F2Arcs is a vector of the variables I am branching on, and vars_ is a pointer to the variables in the model
    IloExpr e1(getEnv());

    for(int i =0; i < F2Arcs.size(); i++)
    {
    e1 += (*vars_)[F2Arcsi];
    }

    makeBranch( e1 == 0 , getObjValue());
    makeBranch( e1 >= 1, getObjValue());

    e1.end();

    before this set up I also had it set up using range array which gave me a memory leakage at the IloRangeArray portion
    IloRangeArray branches(getEnv());
    branches.add(e1 == 0);
    branches.add(e1 >= 1);

    makeBranch( branches[0], getObjValue());
    makeBranch( branches[1], getObjValue());
    e1.end();

    branches.end();
    Thanks in advance for any help
    Cam
    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Memory Leak when making branches

    Posted 05/07/12 05:27 PM

    Originally posted by: EdKlotz


    > clemsonmacrone wrote:
    > Hi, I am having a memory leak at the makeBranch() lines of my branch callback routine. Is their something fundamentally wrong with my set up that causes this? note: F2Arcs is a vector of the variables I am branching on, and vars_ is a pointer to the variables in the model
    >
    >
    > IloExpr e1(getEnv());
    >
    > for(int i =0; i < F2Arcs.size(); i++)
    > {
    > e1 += (*vars_)[F2Arcsi];
    > }
    >
    > makeBranch( e1 == 0 , getObjValue());
    > makeBranch( e1 >= 1, getObjValue());
    >
    > e1.end();

    Keep in mind that the +=, == and >= operators here are actually functions
    associated with these overloaded operator. I think you are OK regarding
    the use of += in the above code; the results of that function call should
    be updated into the existing IloExpr e1. But, I think your makebranch
    calls create two additional IloRanges:

    e1 == 0
    e1 >= 1
    >
    >
    >
    > before this set up I also had it set up using range array which gave me a memory leakage at the IloRangeArray portion
    >
    >
    > IloRangeArray branches(getEnv());
    > branches.add(e1 == 0);
    > branches.add(e1 >= 1);
    >
    > makeBranch( branches[0], getObjValue());
    > makeBranch( branches[1], getObjValue());
    > e1.end();
    >
    > branches.end();
    >
    >
    > Thanks in advance for any help
    > Cam

    This second approach is on the right track. But, keep in mind that
    branches is an IloRangeArray containing handles to the individual
    IloRanges. So, while the above code frees the memory associated with
    the array of handles, it doesn't free the memory associated with the
    IloRanges to which the handles point to. With that in mind, try
    preceding the call to branches.end() with

    
    branches[0].end(); branches[1].end();
    


    I hope that takes care of any leakage. If not, try systematically simplifying
    your branch callback to help isolate the source of the leakage. For example,
    try making e1 an expression consisting of just a single variable and comment
    out the for loop.

    For additional information regarding the creation and deletion of extractables,
    look in the corresponding subsections of the Concepts section of the CPLEX C++
    Reference Manual. Also, some general debugging tips that may help appear at
    http://www-01.ibm.com/support/docview.wss?uid=swg21400038

    Ed
    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Memory Leak when making branches

    Posted 05/07/12 07:01 PM

    Originally posted by: clemsonmacrone


    branches[1].end();
    branches[0].end();
    branches.end();

    got rid of the leak
    Thanks!
    #CPLEXOptimizers
    #DecisionOptimization