[Scip] SCIPgetTransformedCons
Jose Walteros
jl.walteros at gmail.com
Thu May 17 04:42:19 MEST 2012
Hi,
Thanks for the early response, here is the deal. I have a set of constraints named triaCons that are associated with the triplet (i,j,k). The way I created those is:
SCIP_CALL( SCIPallocBufferArray(scip, &triaCons, num_nodes) );
for( i = 0; i < num_nodes; i++)
{
SCIP_CALL( SCIPallocMemoryArray(scip, &(triaCons[i]), i) );
for ( j = 0; j<i; j++)
{
SCIP_CALL( SCIPallocMemoryArray(scip, &(triaCons[i][j]), j) );
for ( k = 0; k<j; k++)
{
(void) SCIPsnprintf(name, SCIP_MAXSTRLEN, "triplet%d_%d_%d_", i, j, k);
SCIP_CALL( SCIPcreateConsLinear(scip, &triaCons[i][j][k], name, 0, NULL, NULL,
-SCIPinfinity(scip), /* lhs */
1.0, /* rhs */
TRUE, /* initial */
TRUE, /* separate */
TRUE, /* enforce */
TRUE, /* check */
TRUE, /* propagate */
FALSE, /* local */
TRUE, /* modifiable */
FALSE, /* dynamic */
FALSE, /* removable */
FALSE) ); /* stickingatnode */
SCIP_CALL( SCIPaddCons(scip, triaCons[i][j][k]) );
… etc.
I am freeing the buffer as follows (assume the lines are not commented):
// for (i=0; i<num_nodes; ++i) {
// for (j=0; j<i; ++j) {
// SCIPfreeBufferArray(scip, &triaCons[i][j]);
// }
//
// SCIPfreeBufferArray(scip, &triaCons[i]);
// }
SCIPfreeBufferArray(scip, &triaCons);
If I delete the comments I get the assertion fail:
Assertion failed: (bufnum >= 0), function SCIPbufferFreeMem, file src/scip/buffer.c, line 301.
Clearly, I am not freeing the buffer correctly. I have tried other stuff but it does not work. Could you help me please.
I generally code in Java, I used to code in C a long time ago, but definitely, as you can see most of that knowledge is gone.
By the way, the code works perfectly now when I compile it normally, although, I want to make it work in debug mode just in case. SCIP is awesome!!!!!!!!!!!!!!!!!!!!!!!!!!!! I am not a fan of C but I find SCIP that good, that I don't mind going through the pain of doing it in C.
Thanks.
-Jose
On May 16, 2012, at 10:19 PM, michael.winkler at zib.de wrote:
> Hi,
>
>> Assertion failed: (SCIPbufferGetNUsed(scip->set->buffer) == 0), function
>> initPresolve, file src/scip/scip.c, line 6309.
>>
>
> this comes up if in some initpre callback the allocated buffer
> memory(SCIPallocBuffer*/SCIPduplicateBuffer*) was not
> freed(SCIPfreeBuffer*). Maybe you can check your implemented initpre
> callbacks for that.
>
> If you need memory that will be used in different other callback calls you
> should use the SCIPallocMemory* or SCIPallocBlockMemory* methods.
>
> Best, Michael
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://listserv.zib.de/mailman/private/scip/attachments/20120517/1c9492df/attachment.html
More information about the Scip
mailing list