Skip to content

Commit

Permalink
fix: use subdim indices for GET DIRECT DATA (#164)
Browse files Browse the repository at this point in the history
Fixes #163
  • Loading branch information
ToddFincannon authored Nov 19, 2021
1 parent 44c1202 commit d7b46c6
Show file tree
Hide file tree
Showing 3 changed files with 249 additions and 3 deletions.
234 changes: 234 additions & 0 deletions models/directdata/directdata.dat
Original file line number Diff line number Diff line change
Expand Up @@ -746,6 +746,192 @@ l[A2,B2]
2048 0
2049 0
2050 0
n
1990 21
1991 21.0667
1992 21.1333
1993 21.2
1994 21.2667
1995 21.3333
1996 21.4
1997 21.4667
1998 21.5333
1999 21.6
2000 21.6667
2001 21.7333
2002 21.8
2003 21.8667
2004 21.9333
2005 22
2006 22.1
2007 22.2
2008 22.3
2009 22.4
2010 22.5
2011 22.6
2012 22.7
2013 22.8
2014 22.9
2015 23
2016 23.0667
2017 23.1333
2018 23.2
2019 23.2667
2020 23.3333
2021 23.4
2022 23.4667
2023 23.5333
2024 23.6
2025 23.6667
2026 23.7333
2027 23.8
2028 23.8667
2029 23.9333
2030 24
2031 24.05
2032 24.1
2033 24.15
2034 24.2
2035 24.25
2036 24.3
2037 24.35
2038 24.4
2039 24.45
2040 24.5
2041 24.55
2042 24.6
2043 24.65
2044 24.7
2045 24.75
2046 24.8
2047 24.85
2048 24.9
2049 24.95
2050 25
p
1990 21
1991 21.0667
1992 21.1333
1993 21.2
1994 21.2667
1995 21.3333
1996 21.4
1997 21.4667
1998 21.5333
1999 21.6
2000 21.6667
2001 21.7333
2002 21.8
2003 21.8667
2004 21.9333
2005 22
2006 22.1
2007 22.2
2008 22.3
2009 22.4
2010 22.5
2011 22.6
2012 22.7
2013 22.8
2014 22.9
2015 23
2016 23.0667
2017 23.1333
2018 23.2
2019 23.2667
2020 23.3333
2021 23.4
2022 23.4667
2023 23.5333
2024 23.6
2025 23.6667
2026 23.7333
2027 23.8
2028 23.8667
2029 23.9333
2030 24
2031 24.05
2032 24.1
2033 24.15
2034 24.2
2035 24.25
2036 24.3
2037 24.35
2038 24.4
2039 24.45
2040 24.5
2041 24.55
2042 24.6
2043 24.65
2044 24.7
2045 24.75
2046 24.8
2047 24.85
2048 24.9
2049 24.95
2050 25
r
1990 210
1991 209.333
1992 208.667
1993 208
1994 207.333
1995 206.667
1996 206
1997 205.333
1998 204.667
1999 204
2000 203.333
2001 202.667
2002 202
2003 201.333
2004 200.667
2005 200
2006 199
2007 198
2008 197
2009 196
2010 195
2011 194
2012 193
2013 192
2014 191
2015 190
2016 189.667
2017 189.333
2018 189
2019 188.667
2020 188.333
2021 188
2022 187.667
2023 187.333
2024 187
2025 186.667
2026 186.333
2027 186
2028 185.667
2029 185.333
2030 185
2031 184.75
2032 184.5
2033 184.25
2034 184
2035 183.75
2036 183.5
2037 183.25
2038 183
2039 182.75
2040 182.5
2041 182.25
2042 182
2043 181.75
2044 181.5
2045 181.25
2046 181
2047 180.75
2048 180.5
2049 180.25
2050 180
SAVEPER
1990 1
1991 1
Expand Down Expand Up @@ -886,3 +1072,51 @@ k[A1,B2]
2015 190
2030 185
2050 180
m[M1]
1990 11
2005 12
2015 13
2030 14
2050 15
m[M2]
1990 21
2005 22
2015 23
2030 24
2050 25
m[M3]
1990 31
2005 32
2015 33
2030 34
2050 35
o[M1]
1990 11
2005 12
2015 13
2030 14
2050 15
o[M2]
1990 21
2005 22
2015 23
2030 24
2050 25
o[M3]
1990 31
2005 32
2015 33
2030 34
2050 35
q[M2]
1990 610
2005 600
2015 590
2030 593
2050 583
q[M3]
1990 210
2005 200
2015 190
2030 185
2050 180
7 changes: 7 additions & 0 deletions models/directdata/directdata.mdl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ DimA: A1, A2 ~~|
DimB: B1, B2 ~~|
DimC <-> DimM ~~|
DimM: M1, M2, M3 ~~|
SubM: M2, M3 ~~|

a[DimA] := GET DIRECT DATA('?data', 'A Data', 'A', 'B2') ~~|
b[DimA] = a[DimA] * 10 ~~~:SUPPLEMENTARY|
Expand Down Expand Up @@ -32,6 +33,12 @@ n = m[M2] ~~|
o[DimM] = GET DIRECT DATA( 'mt.csv', ',', 'A', 'B2' ) ~~|
p = o[M2] ~~|

q[SubM] = GET DIRECT DATA('e_data.csv', ',', 'A', 'B2')
~
~ CSV table mapped to a subdimension
|
r = q[M3] ~~|

********************************************************
.Control
********************************************************~
Expand Down
11 changes: 8 additions & 3 deletions src/EquationGen.js
Original file line number Diff line number Diff line change
Expand Up @@ -399,9 +399,14 @@ export default class EquationGen extends ModelReader {
}
let dimName = this.var.separationDims[0]
for (let subscript of this.var.subscripts) {
if (sub(subscript).family === dimName || sub(dimName).value.includes(subscript)) {
let ind = sub(subscript)
indexNum = ind.value
if (sub(subscript).family === dimName) {
// Use the index value in the subscript family when that is the separation dimension.
indexNum = sub(subscript).value
break
}
if (sub(dimName).value.includes(subscript)) {
// Look up the index when the separation dimension is a subdimension.
indexNum = sub(dimName).value.indexOf(subscript)
break
}
}
Expand Down

0 comments on commit d7b46c6

Please sign in to comment.