1

I am struggling with a seemingly simple model in MathProg. The model is as follows:

set W;
set V;

param b {W, V} binary;
param p;

var w {j in W} <= 0, >= 1;

minimize obj: 0;

subject to within_radius_of {i in V}:
    sum {j in W} b[i,j] * w[j] >= 1;

subject to p_limit:
    sum {j in W} w[j] <= p;

end;

When I run it, it gives me the error feasibility.glp:11: b[v1,w1] out of domain. I have no idea what is going wrong. Even more strange to me, if I change the relevant line to b[j,i] it keeps giving the exact same error (not b[w1,v1] as I expected).

I inspected the AMPL Diet Example carefully, and despite me seeing no difference in the relevant part of my model it still doesn't work. What is wrong?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Rafael Almeida
  • 10,352
  • 6
  • 45
  • 60

1 Answers1

0

Parameter b is declared as binary so it can only take values 0 or 1. You haven't provided a data file, but the error message suggests that the data for b is out of domain (not 0 or 1), for example:

data;
set W := w1;
set V := v1;
param b := w1 v1 0.5;

AMPL gives a more detailed error message in this case:

error processing param b['w1','v1']:
    failed check: param b['w1','v1'] = 0.5
        is not binary (0 or 1);

The reason why the order of indices doesn't matter in this case is that the data for b is checked completely before the model is actually instantiated. So it seems that w1 and v1 may be swapped in the data file.

vitaut
  • 49,672
  • 25
  • 199
  • 336