Question:
I’m encountering an issue with the following code in GAMSPy when trying to define savings (sav0
). The error occurs in the assignment:
sav0= Parameter(m, name="sav0", domain=[investment,privateNAT], description="Savings for IS")
sav0["CAP", "HH1"] = RA_out["HH1"] - Sum([goods], nom_Cons_sett0[goods, "HH1"])
The privateNAT
set is defined as follows:
privateNAT = Set(
m,
name="privateNAT",
domain=consumers,
records=["NPI", "HH1", "HH2", "HH3", "HH4", "HH5", "HH6", "HH7", "HH8", "HH9", "HH10", "FC", "NFC"],
description="Private national consumers."
)
Additionally, my RA_out
data looks like this:
RA_out | privateNAT | value |
---|---|---|
0 | NPI | 16313.000000 |
1 | HH1 | 18715.049444 |
2 | HH2 | 36038.742059 |
3 | HH3 | 44861.449646 |
4 | HH4 | 51341.579784 |
5 | HH5 | 59656.793666 |
6 | HH6 | 70199.779479 |
7 | HH7 | 80968.845735 |
8 | HH8 | 89095.610764 |
9 | HH9 | 107862.395621 |
10 | HH10 | 183805.753366 |
11 | FC | 30164.000000 |
12 | NFC | 202360.000000 |
However, I receive the following error:
=============
Error Summary
=============
3028 sav0(investment,"HH1") = (RA_out("HH1") - sum(goods,nom_Cons_sett0(goods,"HH1")));
**** $170 $170
**** LINE 3 INPUT
**** 170 Domain violation for element
**** 2 ERROR(S) 0 WARNING(S)
Strangely, similar assignments for savg
and savrow
work perfectly:
savg = Parameter(m, name="savg", domain=[investment, public], description="Savings for GOV")
savg["CAP", "GOV"] = RA_PA_out["GOV"] - Sum(goods, nom_PubExp_sett0[goods, "GOV"])
savrow = Parameter(m, name="savrow", domain=[investment, PRIVATEnoNAT], description="Savings for ROW")
savrow["CAP", "ROW"] = RA_ROW_out["ROW"] - Sum(goods, Exp_Sett0[goods, "ROW"])
Given that privateNAT
includes "HH1"
, why is GAMSPy throwing a domain violation error when using RA_out["HH1"]
in the sav0
assignment? Any insights on what could be causing this discrepancy would be greatly appreciated!