How to model constraint to send only when facility is open?
AnsweredHi,
How can I implement a constraint so that resources from facility is sent to customer only when that facility is open?
select is a binary variable to send resource r from station s. deploy is a continuous variable (not fractional from 0 to 1). I want to send resources only when s is open. From literature & gurobi example, I formulated the following. But, now the value of deploy is always less than 1. deploy should be equal to demands in customer points, e.g. 45.
model2.addConstrs((deploy[s, o, r] <= select[s, r]
for o in OilSpills for s in Stations for r in ResourcesD),
name='open_facility')
-
Hi Tanmoy,
If select[s, r] is a binary variable, then it can be no larger than 1. Consequently a constraint
deploy[s, o, r] <= select[s, r]
would mean that deploy[s, o, r] could also not be larger than 1 as you have discovered. If you were to instead use the constraint
deploy[s, o, r] <= M*select[s, r]
For some constant value M, then it would allow deploy[s, o, r] to have a value up to M whenever select[s, r]. I will leave it to you to decide what your M values should be, but my advice is not to make them any larger than they need to be.
- Riley
0
Please sign in to leave a comment.
Comments
1 comment