[FlopCpp] Deleting a model

Christian Wolf kalmar at uni-paderborn.de
Tue Sep 14 02:47:29 EDT 2010


  Hi Gregory,

you could define a new MP_model for every loop.
If you do it like this, you can not use the MP_model::getDefaultModel 
anymore to get access to the MP_model, but either the loopModel defined 
below or MP_model::getCurrentModel, which points to the last MP_model 
created.


for (int i=1; i<100000 ; i++)
{
    MP_model loopModel(new OsiCbcSolverInterface() );

    enum {nw,ne,se,sw,numK};
    MP_set l(4);  // identfiers for level row and column labels  / 1*4 /;
    MP_index i,j;
    MP_data conc(l,l,l);

... etc ...

    maximize( sum(d(l,i,j), (conc(l,i,j)*value/100 - cost(l))*x(l,i,j)) );
    cout<<"Test mine "<<  i<<  " passed."<<endl;
   }


Please let me know if this helps,
Christian


Am 13.09.2010 23:25, schrieb gemiel at impa.br:
> Hi,
>
> I have a question regarding memory management in FlopCPP.
> Basically I am defining and solving many LPs in a loop and I would
> like to be sure that everything is deleted after each loop iteration.
> It does not seem to be the case since the memory used by the program
> keeps increasing.
>
> I reproduced this behavior with the 'mine.cpp' example:
> _____________________________________________________
> for (int i=1; i<100000 ; i++)
> {
>     MP_model::getDefaultModel().setSolver(new OsiCbcSolverInterface);
>
>     enum {nw,ne,se,sw,numK};
>     MP_set l(4);  // identfiers for level row and column labels  / 1*4 /;
>     MP_index i,j;
>     MP_data conc(l,l,l);
>
> ... etc ...
>
>     maximize( sum(d(l,i,j), (conc(l,i,j)*value/100 - cost(l))*x(l,i,j)) );
>     cout<<"Test mine "<<  i<<  " passed."<<endl;
> }
> ________________________________________________________
>
> I tried to add ' MP_model::getDefaultModel().detach(); ' but it did not help.
> What should I do to be sure to delete all objects that are
> instantiated in the loop ?
>
> Thanks.
>
> Regards.
>
> Gregory
>
> ----------------------------------------------------------------
> This message was sent using IMP, the Internet Messaging Program.
>
>
>
> _______________________________________________
> FlopCpp mailing list
> FlopCpp at list.coin-or.org
> http://list.coin-or.org/mailman/listinfo/flopcpp



More information about the FlopCpp mailing list