Skip to content

Commit

Permalink
Fix bug in MGA code
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jdecarolis committed Jan 9, 2018
1 parent 50deee5 commit 364d5ef
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions temoa_model/temoa_mga.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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-
Expand All @@ -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] )
Expand Down

0 comments on commit 364d5ef

Please sign in to comment.