From 364d5ef5db8751b2335b106f25e0bef6196e51bf Mon Sep 17 00:00:00 2001 From: jdecarolis Date: Mon, 8 Jan 2018 22:07:05 -0500 Subject: [PATCH] Fix bug in MGA code Normalized sector MGA algorithm did not work previously because the instance name was incorrect. Now fixed. Also updated the comment related to the integer weighting method. --- temoa_model/temoa_mga.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/temoa_model/temoa_mga.py b/temoa_model/temoa_mga.py index 32d7ef9f..1c74a1a6 100644 --- a/temoa_model/temoa_mga.py +++ b/temoa_model/temoa_mga.py @@ -44,9 +44,7 @@ def SlackedObjective_rule ( M, prev_cost, mga_slack ): def PreviousAct_rule ( instance, mga_weight, prev_activity_t ): # The version below weights each technology by its previous cumulative # activity. However, different sectors may be tracked in different units and - # have activities of very different magnitudes. Can also modify the code - # changing 'val' to 1 to implement a integer-based weight to address this non-uniform - # weighting issue. + # have activities of very different magnitudes. epsilon=1e-6 @@ -55,7 +53,7 @@ def PreviousAct_rule ( instance, mga_weight, prev_activity_t ): if t in instance.tech_mga: val = value( instance.V_ActivityByTech[t] ) if abs(val) < epsilon: continue - prev_activity_t[ t ] += 1.0 #val + prev_activity_t[ t ] += 1.0 return prev_activity_t # The version below calculates activity by sector and normalized technology- @@ -76,7 +74,7 @@ def PreviousAct_rule ( instance, mga_weight, prev_activity_t ): for S_t in techs[s] ) - for t in instance_1.V_ActivityByTech: + for t in instance.V_ActivityByTech: for s in sectors: if t in techs[s]: val = value( instance.V_ActivityByTech[t] )