[Scip] Adding rows to cutpool

Stefan Vigerske stefan at math.hu-berlin.de
Sat Mar 31 04:12:28 MEST 2012


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#**
>> 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#**
>> 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>
>>>
>>
>>
>
>
>
>
> _______________________________________________
> Scip mailing list
> Scip at zib.de
> http://listserv.zib.de/mailman/listinfo/scip



More information about the Scip mailing list