[Scip] Constraints which involve two variables

Tobias Achterberg achterberg at zib.de
Thu Apr 22 15:52:06 MEST 2010


You can also directly use the AND constraint, which is supported by SCIP, see cons_and.h:

    SCIP_VAR***** z;  /* 4-dim SCIP_VAR* array */
    SCIP_VAR*** w;    /* 2-dim SCIP_VAR* array */
    SCIP_VAR* vars[2];

    vars[0] = w[i][j];
    vars[1] = w[l][h];
    retcode = SCIPcreateConsAnd(scip, &cons, "myname", z[i][l][j][h], 2, vars, ...);

This constraint would automatically add the three linear rows to the LP relaxation, and it 
could be slightly faster for domain propagation and the like.


Tobias


Ambros Gleixner wrote:
> Hi Marty,
>
> to have
>
>> z[i][l][j][h]<= w[i][j]
>> z[i][l][j][h]<= w[l][h]
>> z[i][l][j][h]>= w[i][j] + w[l][h] -1
>
> in form of a linear constraint, you need to rewrite it as
>
>> -SCIPinfinity(scip)<= z[i][l][j][h] - w[i][j]<= 0
>> -SCIPinfinity(scip)<= z[i][l][j][h] - w[l][h]<= 0
>> -1<= z[i][l][j][h] - w[i][j] - w[l][h]<= SCIPinfinity(scip)
>
> Then you can use SCIPcreateConsLinear.
>
> For the first two constraints you could alternatively create a so called
> "variable bound constraint" with SCIPcreateConsVarbound.  See the
> documentation for more details.  (Since SCIP will detect this structure
> automatically, it is perfectly ok to use SCIPcreateConsLinear, though.)
>
> ambros
>
>
>
> Am 22.04.2010 15:21, schrieb Martina Astegno:
>> Hi all!
>>
>> I'm modelling a clustering problem and it requires to use a binary
>> variable for each element and for each cluster. w[i][j] = 1 if
>> element i is in cluster j; 0 otherwise.
>>
>> I have to define another binary variable, z[i][l][j][h], that is
>> equal to 1 if (w[i][j] and w[l][h]) = 1; 0 otherwise.
>>
>> AND logic operator is implemented introducing 3 new constraints in
>> the problem: z[i][l][j][h]<= w[i][j] z[i][l][j][h]<= w[l][h]
>> z[i][l][j][h]>= w[i][j] + w[l][h] -1
>>
>> So, when I have to create the solver, to define the constraint on z
>> variable, in function SCIPcreateConsLinear(), I don't know how to fix
>> the lb/ub equal to the value of the w variable, because it's
>> SCIP_VAR* type. It's possible to know the value associated to a
>> variable with the function SCIPgetSolVal() only after solve method
>> and not during the solver  construction.
>>
>> Any idea what's going on?
>>
>>
>> Thanks!
>>
>> Marty
>>
>>
>>
>>
>>
>>
>>
>> _______________________________________________
>> Scip mailing list
>> Scip at zib.de
>> http://listserv.zib.de/mailman/listinfo/scip
>


More information about the Scip mailing list