[Scip] Adding rows to cutpool

sheetal murkute shvm11 at gmail.com
Fri Apr 6 04:57:01 MEST 2012


Hello,

I am working on multi-commodity network flow problem. I could solve the
problem with capacity and flow balancing constraints in SCIP.
I now want to add the disaggregation constraints. I was considering adding
these constraints in a global cut pool so that
solver will decide which constraints are violated at each node at the
runtime, and will add only the violated constraints. For
this, I am using SCIPaddPoolCut to add constraints in a global cutpool (as
in CPLEX/GLPK), before the solving starts.

I store the indices and coefficients of xijk and yj variables for each
disaggregation constraint in cutind and cutval respectively.

I have gone through the SCIP documentation and examples.
I wanted to ask which will be the appropriate method for adding these cuts
- constraint handler/ separator/ or is there any particular
method (such as SCIPcreateConsLinear) which can be used instead of adding
constraint handler or separator?

Thank you for your help.

- Sheetal


On Tue, Apr 3, 2012 at 5:10 AM, Gerald Gamrath <gamrath at zib.de> wrote:

>  Dear Sheetal,
>
> how do you get the indices stored in cutind and why do you think that
> taking just the variable at this position in the SCIP variable array should
> be the variable you want to have?
>
> You do not need to alloc memory if SCIPgetVars(scip) just returns the
> pointer to the internal variable array of SCIP. Please assert, that
> scipvars[cutind[i]] <= SCIPgetNVars(scip).
>
> Where do you do the generation of the cuts? It seems, that you do it
> before the solving started, which is not allowed. What you could do then is
> to add linear constraints, for which you set the initial flag to FALSE and
> the separate flag to TRUE, so that they are only separated, if needed. You
> can then also set the check and propagate flags to FALSE, because the
> constraints are additional, redundant constraints.
>
> Please, also have a look at the SCIP documentation (e.g.
> http://scip.zib.de/doc/html/SEPA.html) and the examples coming with SCIP
> (directory examples/ in the SCIP main folder), for example the TSP example,
> which is also written in C++ and features a Subtour constraint handler that
> also generates cuts. Furthermore the SCIP online documentation (
> http://scip.zib.de/doc/html/index.html) provides a search feature that
> allows you to look up the definition of methods and their parameters.
>
> Best,
> Gerald
>
> Am 02.04.2012 19:05, schrieb sheetal murkute:
>
> 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#**
>>>> 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
>>>
>>
>>
>
>
>  --
> Thanks with Best Regards,
> Sheetal
>
> :)
>
>
> _______________________________________________
> Scip mailing listScip at zib.dehttp://listserv.zib.de/mailman/listinfo/scip
>
>
>
> _______________________________________________
> Scip mailing list
> Scip at zib.de
> 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/20120406/02472b68/attachment.html


More information about the Scip mailing list