Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  error in loop

    Posted 12/21/11 09:16 AM

    Originally posted by: SystemAdmin


    hi:
    I need call cplex12.3 in C++ to solve a LP problem repeatedly in a loop. First all is OK. But after about 1 hour, an error occurs.
    error: cplex error 12: unknown error code.
    what this problem caused by? beacese of memory leak? Part of program in the loop like this. Is it leak the memory in somewhere? thank you.

    IloEnv env;
    IloModel model(env);
    IloNumVarArray x(env, x_length, 0, 1);
    IloNumVarArray z(env, z_length, 0, 1);
    IloNumVarArray w(env, w_length, 0, IloInfinity);

    try {
    model.add(IloMinimize(env, IloSum(x)
    ));

    for(i = 0; i < z_length; i++) {

    nc=fdcc(i);
    dc=*(nc+LC);
    IloExpr v1(env);
    for(j=0;j<dc;j++)
    {
    v1+=x*(nc+j);
    }
    model.add(v1 == 2*w[i]+z[i]);
    v1.end();

    }

    for(i = 0; i < x_length; i++) {
    nv=fdvv(i);
    dv=*(nv+LE);
    IloExpr v2(env);
    for(j=0;j<dv;j++)
    {
    v2+=z*(nv+j);
    }
    model.add(v2 <=floor(double(dv/2)));
    v2.end();
    }
    model.add(IloSum(x) >= 1);
    model.add(IloSum(z) <=tmax);
    IloCplex cplex(env);
    cplex.extract(model);
    cplex.solve();
    cout << "Obj " << cplex.getObjValue() << endl;

    cplex.end();
    cout << endl;
    cout << "----------------------------------------" << endl;
    }
    catch (IloException& ex) {
    cerr << "Error: " << ex << endl;

    }

    x.end();
    w.end();
    z.end();
    model.end();
    env.end();
    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: error in loop

    Posted 12/21/11 11:43 AM

    Originally posted by: SystemAdmin


    Do I understand correctly that you have the statements 'IloEnv env;' and 'env.end()' in the loop? This should be enough to avoid memory leaks from CPLEX. Are you running on Windows or Linux? Can you monitor memory usage with Task Manager or the 'top' command while your application is running? Does memory usage increase? Could you show us the screen output of your application?
    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: error in loop

    Posted 12/22/11 01:11 AM

    Originally posted by: SystemAdmin


    Yes,I have the statements 'IloEnv env;' and 'env.end()' in the loop. I run on windows. I monitor memory usage with Task Manager.find it doesn't grow significantly. but after a period of time there is sudden drop in system cache, Is it caused by cplex? screen output of your application like this:

    Error: CPLEX Error 12: Unknown error code.

    Error: CPLEX Error 1809: Could not create synchronization primitive.

    Error: CPLEX Error 12: Unknown error code.

    Error: CPLEX Error 12: Unknown error code.

    Error: CPLEX Error 12: Unknown error code.

    Error: CPLEX Error 12: Unknown error code.

    Error: CPLEX Error 12: Unknown error code.

    Error: CPLEX Error 12: Unknown error code.

    Error: CPLEX Error 12: Unknown error code.

    Error: CPLEX Error 12: Unknown error code.

    what lead to this error?
    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: error in loop

    Posted 12/22/11 03:05 AM

    Originally posted by: SystemAdmin


    Could you please also monitor 'Handle Count' and 'Thread Count' in the task manager? These columns are not enabled by default and you may have to enable them via View->Select Columns.
    Does either handle or thread count increase over time?
    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: error in loop

    Posted 12/22/11 03:41 AM

    Originally posted by: SystemAdmin


    yes, handle count increase over time, thread count does't. Is it normal?
    #CPLEXOptimizers
    #DecisionOptimization


  • 6.  Re: error in loop

    Posted 12/22/11 04:12 AM

    Originally posted by: SystemAdmin


    I'm afraid an increasing handle count may eventually cause the error 1809.
    I will try to reproduce the problem here. Can you tell what the handle count is when you observe the error 1809?
    #CPLEXOptimizers
    #DecisionOptimization


  • 7.  Re: error in loop

    Posted 12/22/11 04:56 AM

    Originally posted by: SystemAdmin


    about 300000, because handle is not closed?
    #CPLEXOptimizers
    #DecisionOptimization


  • 8.  Re: error in loop

    Posted 12/22/11 05:02 AM

    Originally posted by: SystemAdmin


    Yes, it looks like handles are not closed properly. There is a known issue with that in CPLEX 12.3 that was fixed in CPLEX 12.4.
    Could you please try switching to a single thread by doing
    cplex.setParam(IloCplex::Threads, 1)
    

    before doing cplex.solve() in the loop. Does this fix the problem?
    #CPLEXOptimizers
    #DecisionOptimization


  • 9.  Re: error in loop

    Posted 12/22/11 05:16 AM

    Originally posted by: SystemAdmin


    Ok, I try it again
    #CPLEXOptimizers
    #DecisionOptimization


  • 10.  Re: error in loop

    Posted 12/22/11 09:13 AM

    Originally posted by: SystemAdmin


    oh,it is OK. thank you very much.
    #CPLEXOptimizers
    #DecisionOptimization


  • 11.  Re: error in loop

    Posted 12/22/11 05:14 AM

    Originally posted by: SystemAdmin


    about 370000
    #CPLEXOptimizers
    #DecisionOptimization