diff options
author | Peter Wu <peter@lekensteyn.nl> | 2017-01-11 18:59:06 +0100 |
---|---|---|
committer | Peter Wu <peter@lekensteyn.nl> | 2017-01-11 18:59:06 +0100 |
commit | e949ba318a979d30932d2938599761505e1c3b38 (patch) | |
tree | 2a29cfc0b987eef9314d74a4492ab6750f106758 /food_delivery/generate-food.py | |
parent | a9a010623c75610cafe67d4ce7accc678f94937b (diff) | |
download | 2IMF25-AR-e949ba318a979d30932d2938599761505e1c3b38.tar.gz |
food: argh, fix typo
Village D has a capacity of 160, not 120...
Diffstat (limited to 'food_delivery/generate-food.py')
-rwxr-xr-x | food_delivery/generate-food.py | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/food_delivery/generate-food.py b/food_delivery/generate-food.py index 0e0295d..0cf954d 100755 --- a/food_delivery/generate-food.py +++ b/food_delivery/generate-food.py @@ -12,7 +12,7 @@ None, 120, 160, 100, -120 +160 ] # Possible transitions from x to y and the travel cost c. @@ -81,19 +81,25 @@ for j in range(1, m + 1): "(= l{jprev} {x})", "(= l{j} {y})", ], vars()) - # Villages other than the next village just lose time - # The new village are additionally restocked. + + # All villages must have sufficient time to make the transition. + for i in range(1, len(states)): + cpreds += fillin([ + "(>= s{i}_{jprev} {cost})", + ], vars()) + + # Calculate new food stock per village. All village lose the cost, but + # the next village can be stocked from the truck. for i in range(1, len(states)): newval = "(- s{i}_{jprev} {cost})" if i == y: + # This is next village, so restock village from truck. drop = "(- s0_{jprev} s0_{j})" newval = "(+ %s %s)" % (newval, drop) cpreds += fillin([ "(>= %s 0)" % drop, ], vars()) cpreds += fillin([ - # Can only do the step if there was sufficient time - "(>= s{i}_{jprev} {cost})", "(= s{i}_{j} %s)" % newval, ], vars()) # If next is truck, restock. |