Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: implement GET DIRECT DATA for CSV #82

Merged
merged 13 commits into from
Jul 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
212 changes: 212 additions & 0 deletions models/directdata/directdata.dat
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,194 @@ d
2048 422
2049 446
2050 470
f[A1]
1990 6100
1991 6093.33
1992 6086.67
1993 6080
1994 6073.33
1995 6066.67
1996 6060
1997 6053.33
1998 6046.67
1999 6040
2000 6033.33
2001 6026.67
2002 6020
2003 6013.33
2004 6006.67
2005 6000
2006 5990
2007 5980
2008 5970
2009 5960
2010 5950
2011 5940
2012 5930
2013 5920
2014 5910
2015 5900
2016 5902
2017 5904
2018 5906
2019 5908
2020 5910
2021 5912
2022 5914
2023 5916
2024 5918
2025 5920
2026 5922
2027 5924
2028 5926
2029 5928
2030 5930
2031 5925
2032 5920
2033 5915
2034 5910
2035 5905
2036 5900
2037 5895
2038 5890
2039 5885
2040 5880
2041 5875
2042 5870
2043 5865
2044 5860
2045 5855
2046 5850
2047 5845
2048 5840
2049 5835
2050 5830
f[A2]
1990 2100
1991 2093.33
1992 2086.67
1993 2080
1994 2073.33
1995 2066.67
1996 2060
1997 2053.33
1998 2046.67
1999 2040
2000 2033.33
2001 2026.67
2002 2020
2003 2013.33
2004 2006.67
2005 2000
2006 1990
2007 1980
2008 1970
2009 1960
2010 1950
2011 1940
2012 1930
2013 1920
2014 1910
2015 1900
2016 1896.67
2017 1893.33
2018 1890
2019 1886.67
2020 1883.33
2021 1880
2022 1876.67
2023 1873.33
2024 1870
2025 1866.67
2026 1863.33
2027 1860
2028 1856.67
2029 1853.33
2030 1850
2031 1847.5
2032 1845
2033 1842.5
2034 1840
2035 1837.5
2036 1835
2037 1832.5
2038 1830
2039 1827.5
2040 1825
2041 1822.5
2042 1820
2043 1817.5
2044 1815
2045 1812.5
2046 1810
2047 1807.5
2048 1805
2049 1802.5
2050 1800
FINAL TIME
1990 2050
h
1990 970
1991 806
1992 642
1993 478
1994 314
1995 150
1996 198
1997 246
1998 294
1999 342
2000 390
2001 450
2002 510
2003 570
2004 630
2005 690
2006 712
2007 734
2008 756
2009 778
2010 800
2011 722
2012 644
2013 566
2014 488
2015 410
2016 512
2017 614
2018 716
2019 818
2020 920
2021 836
2022 752
2023 668
2024 584
2025 500
2026 518
2027 536
2028 554
2029 572
2030 590
2031 580
2032 570
2033 560
2034 550
2035 540
2036 466
2037 392
2038 318
2039 244
2040 170
2041 206
2042 242
2043 278
2044 314
2045 350
2046 374
2047 398
2048 422
2049 446
2050 470
INITIAL TIME
1990 1990
SAVEPER
Expand Down Expand Up @@ -278,3 +464,29 @@ c
2040 17
2045 35
2050 47
e[A1]
1990 610
2005 600
2015 590
2030 593
2050 583
e[A2]
1990 210
2005 200
2015 190
2030 185
2050 180
g
1990 97
1995 15
2000 39
2005 69
2010 80
2015 41
2020 92
2025 50
2030 59
2035 54
2040 17
2045 35
2050 47
14 changes: 11 additions & 3 deletions models/directdata/directdata.mdl
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
{UTF-8}
a[DimA] := GET DIRECT DATA('?data', 'A Data', 'A', 'B2') ~~|
DimA: A1, A2 ~~|
b[DimA] = a[DimA] * 10 ~~|

a[DimA] := GET DIRECT DATA('?data', 'A Data', 'A', 'B2') ~~|
b[DimA] = a[DimA] * 10 ~~~:SUPPLEMENTARY|

c:= GET DIRECT DATA('?data', 'C Data', 'A', 'B2') ~~|
d = c * 10 ~~|
d = c * 10 ~~~:SUPPLEMENTARY|

e[DimA] := GET DIRECT DATA('e_data.csv', ',', 'A', 'B2') ~~|
f[DimA] = e[DimA] * 10 ~~~:SUPPLEMENTARY|

g:= GET DIRECT DATA('g_data.csv', ',', 'A', 'B2') ~~|
h = g * 10 ~~~:SUPPLEMENTARY|

********************************************************
.Control
Expand Down
6 changes: 6 additions & 0 deletions models/directdata/e_data.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Year,A1,A2
1990,610,210
2005,600,200
2015,590,190
2030,593,185
2050,583,180
14 changes: 14 additions & 0 deletions models/directdata/g_data.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
,g
1990,97
1995,15
2000,39
2005,69
2010,80
2015,41
2020,92
2025,50
2030,59
2035,54
2040,17
2045,35
2050,47
2 changes: 1 addition & 1 deletion src/CodeGen.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export let codeGenerator = (parseTree, opts) => {
outputAllVars = true
}
// Function to generate a section of the code
let generateSection = R.map(v => new EquationGen(v, extData, directData, mode).generate())
let generateSection = R.map(v => new EquationGen(v, extData, directData, mode, modelDirname).generate())
let section = R.pipe(generateSection, R.flatten, lines)
function generate() {
// Read variables and subscript ranges from the model parse tree.
Expand Down
Loading