Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
Expand all | Collapse all

Error Message when Iteratively Creating Cpx problems from OsiCpxSolverInterface

  • 1.  Error Message when Iteratively Creating Cpx problems from OsiCpxSolverInterface

    Posted 05/15/09 08:49 PM

    Originally posted by: SystemAdmin


    [annam said:]

    Hi,
    I am quite new to Cplex but I am familiar with the OsiSolverInterfaces.

    I want to iteratively solve MIPs with Cplex.
    I write the instances with the OsiCpxSolverInterface and then, in order to access the CPLEX environment,
    I get the pointer to the CPLEX problem and environment in this way:

    lp =  OsiS->getLpPtr();
    env = OsiS->getEnvironmentPtr();

    solve the problem with:

    status = CPXlpopt (env, lp);

    and free the Cplex environment with:

    status = CPXcloseCPLEX (&env);

    If I do this only once everything is fine, I get an optimal solution.

    The problem arises when I put this optimization block inside a bigger program for which I have to run different instances of the optimization problem iteratively.

    The first run of the optimization block works fine but then, when the second optimization run starts,
    I get the following error message:

    ERROR: CPXcreateprob returned error 1002 (getMutableLpPtr in OsiCpxSolverInterface)
    terminate called after throwing an instance of 'CoinError'
    Abort

    It seems that there is problem with the interaction of Cplex with the Coin Osi libraries.
    I don't know how to manage it.
    I've looked for a solution to this problem throughout the web and Cplex Help but couldn't manage to do it.

    Does anyone have any suggestion?

    Thanks in advance

    anna

    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Error Message when Iteratively Creating Cpx problems from OsiCpxSolverInterface

    Posted 05/16/09 05:52 AM

    Originally posted by: SystemAdmin


    [prubin said:]

    I haven't looked at how OSI manages a CPLEX environment, but my best guess is that once you execute CPXcloseCPLEX (which deletes the environment), it is never recreated.

    My suggestion would be to do the first two statements (lp = ..., env = ...) and the last statement (status = ...) outside the loop.  Inside the loop, you should be able to repopulate the same model each time (deleting anything that does not carry over), or alternatively perhaps delete one model and create a new one using the same environment.

    /Paul
    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Error Message when Iteratively Creating Cpx problems from OsiCpxSolverInterface

    Posted 05/18/09 01:35 PM

    Originally posted by: SystemAdmin


    [annam said:]

    Dear Paul,

    Your suggestion did work!
    Simply putting outside the loop the CPXcloseCPLEX (&env) command solved the problem!

    Thank you very much for the help.

    anna
    #CPLEXOptimizers
    #DecisionOptimization