[Scip] Memory management (in a column generation method)

Gerald Gamrath gamrath at zib.de
Fri Aug 19 19:24:02 MEST 2011


Hi Luigi,

Am 19.08.2011 15:45, schrieb Luigi Malagò:
> Hi list (again),
> i have a question about how to correctly handle memory allocation in SCIP.
>
> in the binpacking example, i found this code,
>
> SCIP_CALL( SCIPduplicateMemoryArray(scip, &pricerdata->conss, conss, 
> nitems) );
>
> to duplicate data structure from master problem to the pricing problem.
Actually, this does not duplicate the data structure, but just copies an 
array, in this case an array of pointers to constraints. It does 
essentially the same as allocating an array of the right size and 
copying the entries one by one, but is more comfortable and efficient. 
Besides, it does not copy them from the master problem to the pricing 
problems, but just stores them within the pricer data for later use.
> in my code i have to copy just a single conss, not an array.
>
> i tryed something like
>
> SCIP_CALL( SCIPduplicateMemoryscip, &pricerdata->myConss, myConss) );
>
> but i didnt work, i debugged the code and some pointers screwed up.
> so i think i solved with just ana assignment
>
> pricerdata->myConss = myConss;
>
> what is wrong with this? it is safe?
That is exactly what you should do.
> same problem when i moved the datastructures from array and matrix of 
> pointers
> to vectors of pointers and vectors of vectors of pointers.
> is it safe to just copy pointers with an assignment as above?
Yes, you can do that.

> as to good working practice:
> in my pricing datastructure, i have pointers to all variables and 
> constraints of the pricer and also of the master,
> since i need these to create new constraints when the variable is 
> added to the master.
> i suppose this is the correct way and place to modify the master 
> problem in
> SCIP_DECL_PRICERREDCOST(pricerRedcostBinpacking)
> when i new column is added. can somebody confirm this, please?
I do not really get your question. But the redcost callback is (besides 
the farkas callback that is called when the restricted LP is infeasible) 
the only method of the pricer that is called at each node for solving 
the LP. So this is the place where you should add new variables and also 
the new constraints that come along with the new variables. However, 
these constraints will not enter the LP directly, but will be separated 
into the LP when they are violated. We changed this behavior to allow 
forcing a constraint to enter the LP even when it is not violated, this 
will be included in the next release. Please tell us if you have any 
problems with the current behavior.

Best, Gerald


More information about the Scip mailing list