From e949ba318a979d30932d2938599761505e1c3b38 Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Wed, 11 Jan 2017 18:59:06 +0100 Subject: food: argh, fix typo Village D has a capacity of 160, not 120... --- food_delivery/generate-food.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'food_delivery') 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. -- cgit v1.2.1