[Scip] Elements of a subset

Julio Rojas jcredberry at gmail.com
Tue Sep 27 12:08:44 MEST 2011


Dear all. I have made my ZIMPL model, based on the advice by Stefan
Vigerske. The problem is that it now is unfeasible. I will copy it here for
anybody who can help me find the problem.

set F :={1..4};
set C :={1..2};
set FC := F*C;

param xf[F]:= <1> 1.5, <2> 4, <3> 4.5, <4> 1.5;
param yf[F]:= <1> 4,<2> 4,<3> 1.5,<4> 2;
param xc[C]:= <1> 3,<2> 3;
param yc[C]:= <1> 4,<2> 2;
param d[FC] :=
  |    1,    2|
|1| 1.50, 2.50|
|2| 1.00, 2.24|
|3| 2.92, 1.58|
|4| 2.50, 1.50|;
param beta:=.5;

var X[C] binary;
var P[FC] binary;
var ax[C] real >= 0;
var ay[C] real >= 0;
var ax1[C] real >= 0;
var ax2[C] real >= 0;
var ay1[C] real >= 0;
var ay2[C] real >= 0;
var A[C] real >= 0;

minimize bs: sum <c> in C: X[c];

subto maxdist:
  forall <f,c> in FC do d[f,c]*P[f,c] <= 2;

subto onlyone:
  forall <f> in F do sum <c> in C: P[f,c]==1;

subto ac:
  forall <f,c> in FC do P[f,c] <= X[c];

### Density bigger than a threshold
subto dens1:
  forall <c> in C do
    -beta*A[c] + (sum <f> in F: P[f,c]) >= 0;

### Definition of the area of an square
subto dens2:
  forall <c> in C do
    A[c] >= ax[c]*ay[c];

### Definition of the x side of the square
subto dens3:
  forall <c> in C do
    ax[c] >= ax1[c]-ax2[c];

### Reformulation for the maximum x coordinate
### of the points that belong to a center
subto dens3_1:
  forall <c> in C do
    forall <f> in F do
      ax1[c] >= xf[f]*P[f,c];

### Reformulation for the minimum x coordinate
### of the points that belong to a center
subto dens3_2:
  forall <c> in C do
    forall <f> in F do
      ax2[c] <= xf[f]*P[f,c];

### Definition of the y side of the square
subto dens4:
  forall <c> in C do
    ay[c] >= ay1[c]-ay2[c];

### Reformulation for the maximum y coordinate
### of the points that belong to a center
subto dens4_1:
  forall <c> in C do
    forall <f> in F do
      ay1[c] >= yf[f]*P[f,c];

### Reformulation for the minimum y coordinate
### of the points that belong to a center
subto dens4_2:
  forall <c> in C do
    forall <f> in F do
      ay2[c] <= yf[f]*P[f,c];

Thanks in advance!
-------------------------------------------------
Julio Rojas
jcredberry at gmail.com



On Tue, Sep 27, 2011 at 9:53 AM, Julio Rojas <jcredberry at gmail.com> wrote:
> Thx Ambros. One question, would this give me all <f,c> for which
> P[f,c]==1? P[f,c] is a decision variable, so the number of constraints
> will be constantly changing. I guess this is not possible, is it?
>
> Regards.
> -------------------------------------------------
> Julio Rojas
> jcredberry at gmail.com
>
>
>
> On Mon, Sep 26, 2011 at 8:56 PM, Ambros Gleixner <gleixner at zib.de> wrote:
>> Dear Julio.
>>
>> First, you need to use the "with" keyword as described in Section 4.7 of
>> the Zimpl manual. Something like
>>
>>   forall <f,c> in FC with P[f,c]==1 do
>>      ax[f] >= max(xf[f]) - min_j(xf[f]);
>>
>>
>> should do.
>>
>> Second, examples on how to get maximum and minimum values can be found
>> on page 10 of the Zimpl manual.
>>
>> Hope that helps,
>> ambros
>>
>>
>>
>>
>> Am 26.09.2011 17:53, schrieb Julio Rojas:
>>> Dear all. Stefan Vigerske helped me with the reformulation of a
>>> constraint I had, but latter on I saw that I originally exposed it
>>> badly. I had:
>>>
>>>    ax[f] >= max(xf[f]*P[f,c]) - min(xf[f]*P[f.c])
>>>
>>> when I reality I need:
>>>
>>> forall <c> in C and forall P[f,c]==1:  ax[f] >= max(xf[f]) -
min_j(xf[f])
>>>
>>> How can I write these constraints in ZIMPL? Until now, I have this:
>>>
>>> set F :={1..4};
>>> set C :={1..2};
>>> set FC := F*C;
>>> param xf[F]:= <1> 1.5, <2> 4, <3> 4.5, <4> 1.5;
>>> param yf[F]:= <1> 4,<2> 4,<3> 1.5,<4> 2;
>>> param xc[C]:= <1> 3,<2> 3;
>>> param yc[C]:= <1> 4,<c> 2;
>>> param d[FC] :=
>>>   |    1,    2|
>>> |1| 1.50, 2.50|
>>> |2| 1.00, 2.24|
>>> |3| 2.92, 1.58|
>>> |4| 2.50, 1.50|;
>>> var X[C] binary;
>>> var P[FC] binary;
>>> minimize bs: sum <c> in C: X[c];
>>> subto maxdist:
>>>   forall <f,c> in FC do d[f,c]*P[f,c] <= 2;
>>> subto onlyone:
>>>   forall <f> in F do sum <c> in C: P[f,c]==1;
>>>
>>> Thanks.
>>>
>>> -------------------------------------------------
>>> Julio Rojas
>>> jcredberry at gmail.com
>>> _______________________________________________
>>> Scip mailing list
>>> Scip at zib.de
>>> http://listserv.zib.de/mailman/listinfo/scip
>>
>> --
>> ____________________________________________________________
>> Ambros M. Gleixner
>> Zuse Institute Berlin - Matheon - Berlin Mathematical School
>> http://www.zib.de/gleixner
>> _______________________________________________
>> Scip mailing list
>> Scip at zib.de
>> http://listserv.zib.de/mailman/listinfo/scip
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://listserv.zib.de/mailman/private/scip/attachments/20110927/1591f5b4/attachment.html


More information about the Scip mailing list