fixed a bug allowing storing of overwork charge
This commit is contained in:
parent
6ebfeddf81
commit
4f115d9289
1 changed files with 10 additions and 5 deletions
15
solve.py
15
solve.py
|
|
@ -676,9 +676,11 @@ class _Builder:
|
||||||
falls on.
|
falls on.
|
||||||
|
|
||||||
The flow equation ``pending' = pending + arm - overwork`` over 0/1
|
The flow equation ``pending' = pending + arm - overwork`` over 0/1
|
||||||
variables is what ties this together; because ``pending`` is a Bool it
|
variables is what ties this together. Charges never stack: the Planner
|
||||||
also rules out arming a City that is already holding a charge (unless
|
is not placed on a City that is already holding one (``arm + pending
|
||||||
that Turn's Collection spends it), which would be wasted anyway.
|
<= 1``), even on a Turn whose Collection would spend that charge - the
|
||||||
|
Collection is doubled once either way, so the placement would buy
|
||||||
|
nothing while quietly banking a second charge.
|
||||||
"""
|
"""
|
||||||
m = self.m
|
m = self.m
|
||||||
overwork_agents = [ai for ai, a in enumerate(agents) if a.overwork]
|
overwork_agents = [ai for ai, a in enumerate(agents) if a.overwork]
|
||||||
|
|
@ -711,8 +713,11 @@ class _Builder:
|
||||||
m.Add(ow <= pend + arm)
|
m.Add(ow <= pend + arm)
|
||||||
# A carried charge is not optional: Collecting spends it.
|
# A carried charge is not optional: Collecting spends it.
|
||||||
m.Add(ow >= pend + collect - 1)
|
m.Add(ow >= pend + collect - 1)
|
||||||
# Charge flow. ``ow_pending`` being a Bool caps this at one
|
# No stacking: don't arm a City that already holds a charge.
|
||||||
# charge per City at a time.
|
# Without this the Planner could arm a City on the very Turn
|
||||||
|
# its held charge fires, spending one and banking another.
|
||||||
|
m.Add(arm + pend <= 1)
|
||||||
|
# Charge flow.
|
||||||
m.Add(self.ow_pending[(ci, t + 1)] == pend + arm - ow)
|
m.Add(self.ow_pending[(ci, t + 1)] == pend + arm - ow)
|
||||||
# An Overworked Collection locks the next Turn's Collect.
|
# An Overworked Collection locks the next Turn's Collect.
|
||||||
if t + 1 < self.T:
|
if t + 1 < self.T:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue