Hi Ylona,
In your case, if IsOpen is a parameter, you could create the sum as follows:
sum( (p,c) | IsOpen(p) , ......)
I suspect however that IsOpen is a decision variable in your problem (i.e. the model will have to decide which centers to open). If this is indeed the case (and you want/need to stay linear), you can't use if statements in the definition of the constraint. You will have to work with additional constraints that limit the amount that can be transported out of a center, for example with a constraint:
OnlyTransportOutWhenOpen(p)
sum( c , Transport(p,c) ) <= MaxAvailableInPlant(p) * IsOpen(p)
If the plant p is closed, this constraint will ensure the value of transport must be 0.
Guido Diepen
AIMMS Specialist
On Friday, January 4, 2013 12:51:44 PM UTC+1, Ylona Meeuwenberg wrote:
Hello,
I want to make a for-loop but don't know how. I want this for loop in a constraint. If this even possible? The for loop i want to make is;
For each p
If ( IsOpen(p) = 1)
Sum[ c, Unittransportcost(p,c) * Transport(p,c)] <= 26400 * Sum[c, Transport(p,c)]
endif
enfor
this is a variant on the beginners tutorial on aimmes.
Alle the customers are plants but it is really expensive to open a plant. So aimms looks for the optimal opening of the plants so all customers get there demand. Now I want that the distance between 1 plant and all his customers is smaller dan 26400.