Search code examples
ampl

Variable in lower/upper bound error AMPL


I have a problem when I try to make a sum with variable limits, when i execute in AMPL, it returns the error "Variable in Lower Bound" and "Variable in Upper Bound" in the final line, but I really don't get it, thats the exact idea of using min and max! WTF thanks a lot

var Y{i in Dias,j in Bloques} binary;
var B{i in Dias,j in Bloques}= Y[i,j]*j;
var L{i in Dias}=min{n in Bloques}if B[i,n]>0 then B[i,n];
var M{i in Dias}=max{n in Bloques}if B[i,n]>0 then B[i,n];

#this line gives error
var V{i in Dias}= sum{z in (L[i]..M[i])}1-Y[i,z];

Solution

  • You can't use decision variables to specify the range bounds a and b in a..b (L[i]..M[i] in your code). If the range bounds are known in advance rather than as an outcome of an optimization process, then you should use parameters instead of variables.

    param L{i in Dias} = ...
    param M{i in Dias} = ...
    

    Otherwise you'll have to reformulate your model.