[Scip] update constraint

Stefan Vigerske stefan at math.hu-berlin.de
Fri Jul 16 16:37:25 MEST 2010


Hi,

Mattia Barbieri wrote:
> On 16 July 2010 11:57, Stefan Vigerske <stefan at math.hu-berlin.de> wrote:
> 
>> Hi,
>>
>>>> A dirty way could be to construct your penalty term as an SCIP_ROW, add
>>>> this one to the LP with the flag that it should not be removed, and then
>>>> modify this row as you like. Changes in the row should be passed to the
>>>> LP.
>>> What does this mean? I understand this:
>>>  create an initial row:
>>>    *SCIPcreateEmptyRow* (...flag it removable..);
>> Better flag it *not* removable, so that it will stay always in the LP.
>>
>>>  add variables and their coefficients (penalty terms):
>>>    *SCIPaddVarsToRow*(...);
>>> then tell the LP this changes:
>>>    *???*
>> If the row is in the LP and then changes, then SCIP passes these changes
>> into the LP, so there is no need to tell the LP.
>>
>> I do this:
> 
> //trickRow
>     SCIP_CALL(SCIPcreateEmptyRow(scip, &sp->*trickRow*, "trickRow", 0.0,
> 0.0, FALSE, TRUE, FALSE));
> 
> *//sp is a struct to mantain some data like penalties, ecc.*
> 
>     SCIP_VAR* transVar;
>     for (int p = 0; p < Qdim; p++) {
> 
> *//z_m[ ], y_m[ ], y_p[ ], z_p[ ] are the variables associated with the
> penalties*
> *//g_m[ ], d.., are the coefficients associated with the penalties*
> 
>         SCIP_CALL(*SCIPtransformVar*(scip, sp->z_m[p], &transVar));

It should be safer to use
   SCIPgetTransformedVar(scip, sp->z_m[p], &transVar)

> *//I suppose SCIP want trasformed variables, because I obtain an error
> passing the original variables *
> *[src/scip/var.c:9329] ERROR: cannot add untransformed original variable
> <_var3_> to LP row <trickRow>*
>         SCIP_CALL(SCIPaddVarToRow(scip, sp->trickRow, transVar,
> -sp->g_m[p]));
>         SCIP_CALL(SCIPtransformVar(scip, sp->y_m[p], &transVar));
>         SCIP_CALL(SCIPaddVarToRow(scip, sp->trickRow, transVar,
> -sp->d_m[p]));
>         SCIP_CALL(SCIPtransformVar(scip, sp->y_p[p], &transVar));
>         SCIP_CALL(SCIPaddVarToRow(scip, sp->trickRow, transVar,
> sp->d_p[p]));
>         SCIP_CALL(SCIPtransformVar(scip, sp->z_p[p], &transVar));
>         SCIP_CALL(SCIPaddVarToRow(scip, sp->trickRow, transVar,
> sp->g_p[p]));
>     }
>     SCIP_CALL(SCIPtransformVar(scip, sp->*trickVa*r, &transVar));
> 
> *//trickVar is a variables add to the objective function of the LP, equal to
> the sum of the penalty variables*
> 
>     SCIP_CALL(SCIPaddVarToRow(scip, sp->trickRow, transVar, -1.0));
> 
> SCIP told me this:
>  *solution violates original bounds of variable <_var43_> [-1e+20,1e+20]
> solution value <-2e+20>
> best solution is not feasible in original problem*

This is hard to say without debugging. I don't know where _var43_
appears in your problem.

> while if I add a linear constraint with the same variables/values the
> solution of the problem is correct (but as you told me in this way I can't
> change the coefficient's values during the LP iterations).
> 
> Perhaps I am missing something...what? (Is that the right way to transform a
> variable?)

Hmm, presolve may just throw out trickVar, since there is no constraint
associated to it. If trickVar is additionally unbounded, then SCIP may
say that the problem is "infeasible or unbounded".
You could add a dummy linear constraint trickVar >= some value and mark
it modifiable, so presolve cannot remove it.

Stefan

>> after each pricer iteration (at each branch), modify the row whit new
>>> coefficients (new penalty values):
>>>    *???*
>> OK, I see that there are no methods in scip.h or pub_lp.h to change row
>> coefficients. :-(
>> You can try with those in lp.h, e.g.
>> SCIP_RETCODE    SCIProwChgCoef (SCIP_ROW *row, BMS_BLKMEM *blkmem,
>> SCIP_SET *set, SCIP_LP *lp, SCIP_COL *col, SCIP_Real val).
>> blkmem you can get via SCIPblkmem(scip).
>> For set and lp, you would need to include struct_scip.h, so you can do
>> scip->set and scip->lp.
>>
>>> Can you give me more details? Forgive me but really I am stuck in this
>>> problem.
>> It may help to send mails to the scip mailing list... :-)
>>
>> Stefan
>>
>>> (I will be in Darmstadt for the COLGEN in August 23-27, but now I
>>> have time to work, so I am trying to solve my problem anyway)
>>>
>>>> (You could even ask your row for its position in the LP by using
>>>> SCIProwGetLPPos, get access to the LP via SCIPgetLPI, and then modify
>>>> the LP there, but that is something one should really not do...)
>>>>
>>>> Stefan
>>>>
>>>> --
>>>> Stefan Vigerske
>>>> Humboldt University Berlin, Numerical Mathematics
>>>> http://www.math.hu-berlin.de/~stefan<http://www.math.hu-berlin.de/%7Estefan>
>> <http://www.math.hu-berlin.de/%7Estefan>
>>>
>>>
>>
>> --
>> Stefan Vigerske
>> Humboldt University Berlin, Numerical Mathematics
>> http://www.math.hu-berlin.de/~stefan<http://www.math.hu-berlin.de/%7Estefan>
>>
> 
> 
> 


-- 
Stefan Vigerske
Humboldt University Berlin, Numerical Mathematics
http://www.math.hu-berlin.de/~stefan


More information about the Scip mailing list