[Scip] Adding rows to cutpool

sheetal murkute shvm11 at gmail.com
Mon Apr 2 19:05:04 MEST 2012


Hi,

I added some asserts, and noticed that the assertions (xCol != NULL) and
(yCol != NULL) fail.
The assertions (xVar != NULL) and (yVar != NULL) do not fail.

*I tried adding variables instead of columns:*
*( I want to add two variables, indices are stored in cutind, and
coefficient values are stored in *
*cutval)*

SCIP_CALL_EXC( SCIPcreateEmptyRow(scip, &newrow,
namebuf.str().c_str(),-SCIPinfinity(scip), 0.0, FALSE,FALSE,FALSE) );
SCIP_VAR** scipvars = (SCIP_VAR**) malloc( (A*K+A) * sizeof(SCIP_VAR*));
scipvars = SCIPgetVars(scip);
for(i=0;i<=1;i++){
   SCIP_CALL_EXC( SCIPaddVarToRow(scip, newrow, scipvars[cutind[i]],
cutval[i]) );
}
SCIP_CALL_EXC( SCIPaddPoolCut(scip, newrow));

*
*
*I get the error: *

[src/scip/var.c:11655] ERROR: cannot add untransformed original variable
<y#351> to LP row <row_1>
[src/scip/scip.c:15535] ERROR: Error <-9> in function call
terminate called after throwing an instance of 'SCIPException'
  what():  method cannot be called with this type of data


Instead of using "scipvars = SCIPgetVars(scip);" , I also tried using
'_vars' vector where I store my scip variables for later use. This also
gives the same error -   "cannot add untransformed original variable"



-Sheetal

On Fri, Mar 30, 2012 at 10:12 PM, Stefan Vigerske
<stefan at math.hu-berlin.de>wrote:

> Hi,
>
> try adding some asserts and compile in debug mode (g++ -g):
>
> SCIP_Var* xVar=_vars[cutind[0]];
> assert(xVar != NULL);
>
> SCIP_COL * xCol = SCIPvarGetCol(xVar);
> assert(xCol != NULL);
> SCIP_Var* yVar=_vars[cutind[1]];
> assert(yVar != NULL);
>
> SCIP_COL * yCol = SCIPvarGetCol(yVar);
> assert(yCol != NULL);
>
> SCIP_COL** cols= (SCIP_COL**) malloc( 2 * sizeof(SCIP_COL*));
> cols[0]=xCol;
> cols[1]=yCol;
>
> SCIP_CALL_EXC( SCIPcreateRow(scip,&newrow, namebuf.str().c_str(), 2, cols,
> cutval, -SCIPinfinity(scip), 0, FALSE,FALSE,FALSE));
>
>
> Columns are only available for variables that are still active in the
> problem, i.e., have not been fixed or aggregated. For inactive variables,
> you would get a NULL from SCIPvarGetCol (I guess).
>
> It may be safer to add the variables to the row instead of the columns,
> since this is also possible for fixed variables:
> SCIP_CALL_EXC( SCIPcreateEmptyRow(scip, &newrow, namebuf.str().c_str(),
>   -SCIPinfinity(scip), 0.0, FALSE,FALSE,FALSE) );
> SCIP_CALL_EXC( SCIPaddVarToRow(scip, newrow, _vars[5],     1.0) );
> SCIP_CALL_EXC( SCIPaddVarToRow(scip, newrow, _vars[351], -10.0) );
>
>
> Stefan
>
> sheetal murkute wrote:
>
>> Hi,
>>
>> I tried using  SCIPvarGetCol()  and  SCIPaddPoolCut() methods.
>> I am getting segmentation fault at the SCIPcreateRow() line.
>>
>> I am now adding cuts as follows:
>> _vars is a vector where I store my SCIP variables.
>> cutind[0] = 5 ; cutind[1] = 351;    // indices of nonzero row variables
>> cutval[0] = 1; cutval[1] = -10;    // coefficients of nonzero row
>> variables
>>
>> SCIP_ROW * newrow;
>>
>> SCIP_Var* xVar=_vars[cutind[0]];
>> SCIP_COL * xCol = SCIPvarGetCol(xVar);
>> SCIP_Var* yVar=_vars[cutind[1]];
>> SCIP_COL * yCol = SCIPvarGetCol(yVar);
>> SCIP_COL** cols= (SCIP_COL**) malloc( 2 * sizeof(SCIP_COL*));
>> cols[0]=xCol;
>> cols[1]=yCol;
>>
>> SCIP_CALL_EXC( SCIPcreateRow(scip,&newrow, namebuf.str().c_str(), 2, cols,
>>
>> cutval, -SCIPinfinity(scip), 0, FALSE,FALSE,FALSE));
>> SCIP_CALL_EXC( SCIPaddPoolCut(scip, newrow));
>>
>>
>> Please let me know if anything is incorrect.
>>
>>
>> -Sheetal
>>
>> On Wed, Mar 28, 2012 at 8:51 PM, Stefan Heinz<heinz at zib.de>  wrote:
>>
>>  Hi,
>>>
>>> The creation of your cut is not correct. The SCIP_COL* array is *not* an
>>> array of indices. You should use the method SCIPvarGetCol()
>>>
>>> http://scip.zib.de/doc/html/****pub__var_8h.html#**<http://scip.zib.de/doc/html/**pub__var_8h.html#**>
>>> a75111eed912d3f76ec076b787f7a0****b12<http://scip.zib.de/doc/**
>>> html/pub__var_8h.html#**a75111eed912d3f76ec076b787f7a0**b12<http://scip.zib.de/doc/html/pub__var_8h.html#a75111eed912d3f76ec076b787f7a0b12>
>>> >
>>>
>>>
>>> to get for a variable to corresponding column. To add your cut into the
>>> cut pool of SCIP  you should use the method SCIPaddPoolCut()
>>>
>>>
>>> http://scip.zib.de/doc/html/****scip_8h.html#**<http://scip.zib.de/doc/html/**scip_8h.html#**>
>>> a14b5af5c0722ae6284b2a2d2eb0b3****d5b<http://scip.zib.de/doc/**
>>> html/scip_8h.html#**a14b5af5c0722ae6284b2a2d2eb0b3**d5b<http://scip.zib.de/doc/html/scip_8h.html#a14b5af5c0722ae6284b2a2d2eb0b3d5b>
>>> >
>>>
>>>
>>> Best Stefan
>>>
>>>
>>>
>>> On 03/27/2012 06:46 PM, sheetal murkute wrote:
>>>
>>>  Hello,
>>>>
>>>> I want to add rows to cutpool.
>>>> For this, I have written the code mentioned below:
>>>>
>>>> cutval = (double *) malloc((3) * sizeof(double *));
>>>> SCIP_CUTPOOL * cutpool;
>>>> SCIP_ROW * newrow;
>>>> SCIP_COL * cutind;
>>>> namebuf.str("");
>>>> namebuf<<"row_"<<k;
>>>> cutind[0] = 22 ; cutind[1] = 34;   ( 22 and 34 are column numbers with
>>>> nonzero values, there are total 2 non-zero coefficients in a row)
>>>>
>>>> SCIPcreateRow(scip,&newrow, namebuf.str().c_str(), 2,&cutind, cutval,
>>>>
>>>> -SCIPinfinity(scip), 0, FALSE,FALSE,FALSE);
>>>> SCIPaddRowCutpool(scip, cutpool, newrow);
>>>>
>>>> *I am getting error saying:*
>>>>
>>>> /home/sxm4946/SCIP/****ziboptsuite-2.1.1/scip-2.1.1/****
>>>>
>>>> src/scip/scip/type_lp.h:73:
>>>> error: forward declaration of āstruct SCIP_Colā
>>>> scipmcfv2.cpp:308: error: invalid use of incomplete type āstruct
>>>> SCIP_Colā
>>>>
>>>>
>>>>
>>>> Can you please help me with this?
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> ______________________________****_________________
>>>> Scip mailing list
>>>> Scip at zib.de
>>>> http://listserv.zib.de/****mailman/listinfo/scip<http://listserv.zib.de/**mailman/listinfo/scip>
>>>> <http://**listserv.zib.de/mailman/**listinfo/scip<http://listserv.zib.de/mailman/listinfo/scip>
>>>> >
>>>>
>>>>
>>>
>>>
>>
>>
>>
>> ______________________________**_________________
>> Scip mailing list
>> Scip at zib.de
>> http://listserv.zib.de/**mailman/listinfo/scip<http://listserv.zib.de/mailman/listinfo/scip>
>>
>
>


-- 
Thanks with Best Regards,
Sheetal

:)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://listserv.zib.de/mailman/private/scip/attachments/20120402/8a9929de/attachment.html


More information about the Scip mailing list