Skip to content

Commit 364d5ef

Browse files
committed
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.
1 parent 50deee5 commit 364d5ef

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

Diff for: temoa_model/temoa_mga.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,7 @@ def SlackedObjective_rule ( M, prev_cost, mga_slack ):
4444
def PreviousAct_rule ( instance, mga_weight, prev_activity_t ):
4545
# The version below weights each technology by its previous cumulative
4646
# activity. However, different sectors may be tracked in different units and
47-
# have activities of very different magnitudes. Can also modify the code
48-
# changing 'val' to 1 to implement a integer-based weight to address this non-uniform
49-
# weighting issue.
47+
# have activities of very different magnitudes.
5048

5149
epsilon=1e-6
5250

@@ -55,7 +53,7 @@ def PreviousAct_rule ( instance, mga_weight, prev_activity_t ):
5553
if t in instance.tech_mga:
5654
val = value( instance.V_ActivityByTech[t] )
5755
if abs(val) < epsilon: continue
58-
prev_activity_t[ t ] += 1.0 #val
56+
prev_activity_t[ t ] += 1.0
5957
return prev_activity_t
6058

6159
# The version below calculates activity by sector and normalized technology-
@@ -76,7 +74,7 @@ def PreviousAct_rule ( instance, mga_weight, prev_activity_t ):
7674
for S_t in techs[s]
7775
)
7876

79-
for t in instance_1.V_ActivityByTech:
77+
for t in instance.V_ActivityByTech:
8078
for s in sectors:
8179
if t in techs[s]:
8280
val = value( instance.V_ActivityByTech[t] )

0 commit comments

Comments
 (0)