Skip to content

Commit aa58cc4

Browse files
dhenslejuangacosta
andauthored
Fix for zones reopening in simulation-based constraint mechanism for work/school location choice (#1028)
* addresses issue with zones reopening after being closed in shadow_pricing * addresses issue with zones reopening after being closed in shadow_pricing * adding shadow price regression values * updating change log --------- Co-authored-by: juangacosta <juan.acosta@rsginc.com>
1 parent 6266ce4 commit aa58cc4

3 files changed

Lines changed: 601 additions & 1 deletion

File tree

activitysim/abm/tables/shadow_pricing.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -860,10 +860,20 @@ def update_shadow_prices(self, state):
860860
sprice.replace([np.inf, -np.inf], 0, inplace=True)
861861

862862
# shadow prices are set to -999 if overassigned or 0 if the zone still has room for this segment
863-
self.shadow_prices[segment] = np.where(
863+
old_shadow_prices = self.shadow_prices[segment].values
864+
new_shadow_prices = np.where(
864865
(sprice <= 1 + percent_tolerance / 100), -999, 0
865866
)
866867

868+
# the conditions above allow for zones to be reopened, but we want to prevent such behavior
869+
new_shadow_prices = np.where(
870+
(old_shadow_prices == -999) & (new_shadow_prices != -999),
871+
old_shadow_prices,
872+
new_shadow_prices,
873+
)
874+
875+
self.shadow_prices[segment] = new_shadow_prices
876+
867877
zonal_sample_rate = 1 - sprice
868878
overpredicted_zones = self.shadow_prices[
869879
self.shadow_prices[segment] == -999

0 commit comments

Comments
 (0)