Skip to content

Commit

Permalink
Merge branch 'main' into todd/318-numeric-range
Browse files Browse the repository at this point in the history
  • Loading branch information
chrispcampbell committed Oct 18, 2023
2 parents 3742400 + a032779 commit 3d9b8e6
Show file tree
Hide file tree
Showing 6 changed files with 304 additions and 79 deletions.
226 changes: 161 additions & 65 deletions models/directlookups/directlookups.dat
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
b[A1]
b
2020 0
2021 0.033333
2022 0.066667
Expand Down Expand Up @@ -30,72 +30,168 @@ b[A1]
2048 0.933333
2049 0.966667
2050 1
b[A2]
2020 0
2021 0
2022 0.034483
2023 0.068966
2024 0.103448
2025 0.137931
2026 0.172414
2027 0.206897
2028 0.241379
2029 0.275862
2030 0.310345
2031 0.344828
2032 0.37931
2033 0.413793
2034 0.448276
2035 0.482759
2036 0.517241
2037 0.551724
2038 0.586207
2039 0.62069
2040 0.655172
2041 0.689655
2042 0.724138
2043 0.758621
2044 0.793103
2045 0.827586
2046 0.862069
2047 0.896552
2048 0.931034
2049 0.965517
2050 1
b[A3]
2020 0
2021 0.008492
2022 0.011317
2023 0.015069
2024 0.020039
2025 0.026606
2026 0.03525
2027 0.04657
2028 0.0613
2029 0.080307
2030 0.104569
2031 0.135111
2032 0.172899
2033 0.218658
2034 0.272653
2035 0.33445
2036 0.402756
2037 0.475409
2038 0.549591
2039 0.622244
2040 0.69055
2041 0.752347
2042 0.806342
2043 0.852101
2044 0.889889
2045 0.920431
2046 0.944693
2047 0.9637
2048 0.97843
2049 0.98975
2050 0.998394
c
2020 2035
2021 2035
2022 2035
2023 2035
2024 2035
2025 2035
2026 2035
2027 2035
2028 2035
2029 2035
2030 2035
2031 2035
2032 2035
2033 2035
2034 2035
2035 2035
2036 2035
2037 2035
2038 2035
2039 2035
2040 2035
2041 2035
2042 2035
2043 2035
2044 2035
2045 2035
2046 2035
2047 2035
2048 2035
2049 2035
2050 2035
d
2020 0.3
2021 0.3
2022 0.3
2023 0.3
2024 0.3
2025 0.3
2026 0.3
2027 0.3
2028 0.3
2029 0.3
2030 0.3
2031 0.3
2032 0.3
2033 0.3
2034 0.3
2035 0.3
2036 0.3
2037 0.3
2038 0.3
2039 0.3
2040 0.3
2041 0.3
2042 0.3
2043 0.3
2044 0.3
2045 0.3
2046 0.3
2047 0.3
2048 0.3
2049 0.3
2050 0.3
e
2020 0.266667
2021 0.266667
2022 0.266667
2023 0.266667
2024 0.266667
2025 0.266667
2026 0.266667
2027 0.266667
2028 0.266667
2029 0.266667
2030 0.266667
2031 0.266667
2032 0.266667
2033 0.266667
2034 0.266667
2035 0.266667
2036 0.266667
2037 0.266667
2038 0.266667
2039 0.266667
2040 0.266667
2041 0.266667
2042 0.266667
2043 0.266667
2044 0.266667
2045 0.266667
2046 0.266667
2047 0.266667
2048 0.266667
2049 0.266667
2050 0.266667
f
2020 0.269999
2021 0.269999
2022 0.269999
2023 0.269999
2024 0.269999
2025 0.269999
2026 0.269999
2027 0.269999
2028 0.269999
2029 0.269999
2030 0.269999
2031 0.269999
2032 0.269999
2033 0.269999
2034 0.269999
2035 0.269999
2036 0.269999
2037 0.269999
2038 0.269999
2039 0.269999
2040 0.269999
2041 0.269999
2042 0.269999
2043 0.269999
2044 0.269999
2045 0.269999
2046 0.269999
2047 0.269999
2048 0.269999
2049 0.269999
2050 0.269999
FINAL TIME
2020 2050
h
2020 1
2021 1
2022 1
2023 1
2024 1
2025 1
2026 1
2027 1
2028 1
2029 1
2030 1
2031 1
2032 1
2033 1
2034 1
2035 1
2036 1
2037 1
2038 1
2039 1
2040 1
2041 1
2042 1
2043 1
2044 1
2045 1
2046 1
2047 1
2048 1
2049 1
2050 1
INITIAL TIME
2020 2020
SAVEPER
Expand Down
41 changes: 39 additions & 2 deletions models/directlookups/directlookups.mdl
Original file line number Diff line number Diff line change
@@ -1,8 +1,45 @@
{UTF-8}
DimA: A1, A2, A3 ~~|

a[DimA] = GET DIRECT LOOKUPS('lookup_data.csv', ',', '1', 'E2') ~~|
b[DimA] = a[DimA](Time) ~~~:SUPPLEMENTARY|
a[DimA] = GET DIRECT LOOKUPS('lookup_data.csv', ',', '1', 'E2')
~
~ subscript currently required for GET DIRECT LOOKUPS
|

b = a[A1](Time)
~
~ access the lookup
|

c = LOOKUP INVERT(a[A1], 0.5)
~
~ look up y for an x value (returns 2035)
|

d = LOOKUP FORWARD(a[A1], 2028.1)
~
~ look up using the next x without interpolation (returns 0.3)
|

e = LOOKUP FORWARD(a[A1], 2028)
~
~ no effect when the x value exists in the lookup (returns 0.266667)
|

f = a[A1](2028.1)
~
~ regular lookups extrapolate by default
|

g((0,0),(1,1),(2,2))
~
~ lookup definition
|

h = LOOKUP FORWARD(g, 1)
~
~ non-subscripted look up
|

********************************************************
.Control
Expand Down
18 changes: 18 additions & 0 deletions models/gamma_ln/gamma_ln.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
a
0 12.8018
1 12.8018
b
0 0.572365
1 0.572365
c
0 -3.41362e-11
1 -3.41362e-11
FINAL TIME
0 1
INITIAL TIME
0 0
SAVEPER
0 1
1 1
TIME STEP
0 1
60 changes: 60 additions & 0 deletions models/gamma_ln/gamma_ln.mdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{UTF-8}
a = GAMMA LN(10) ~~|
b = GAMMA LN(0.5) ~~|
c = GAMMA LN(1) ~~|

********************************************************
.Control
********************************************************~
Simulation Control Parameters
|

INITIAL TIME = 0 ~~|
FINAL TIME = 1 ~~|
TIME STEP = 1 ~~|
SAVEPER = TIME STEP ~~|

\\\---/// Sketch information - do not modify anything except names
V300 Do not put anything below this section - it will be ignored
*View 1
$-1--1--1,0,|12||-1--1--1|-1--1--1|-1--1--1|-1--1--1|-1--1--1|96,96,100,0
///---\\\
:L<%^E!@
1:gamma_ln.vdfx
4:Time
5:FINAL TIME
9:gamma_ln
19:100,0
24:0
25:1
26:1
15:0,0,0,0,0,0
27:2,
34:0,
42:1
72:0
73:0
35:Date
36:YYYY-MM-DD
37:2000
38:1
39:1
40:2
41:0
95:0
96:0
97:0
77:0
78:0
102:0
93:0
94:0
92:0
91:0
90:0
87:0
75:
43:
103:8,8,8,3,8
105:0,0,0,0,0,0,0,0,0,0
104:Courier|12||0-0-0|0-0-0|-1--1--1|0-0-255|192-192-192|-1--1--1
3 changes: 2 additions & 1 deletion packages/cli/src/c/vensim.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ extern "C" {
//
// Vensim functions
// See the Vensim Reference Manual for descriptions of the functions.
// http://www.vensim.com/documentation/index.html?22300.htm
// https://www.vensim.com/documentation/22300.html
//
#define _ABS(x) fabs(x)
#define _COS(x) cos(x)
#define _EXP(x) exp(x)
#define _GAME(x) (x)
#define _GAMMA_LN(x) lgamma(x)
#define _IF_THEN_ELSE(c, t, f) (bool_cond(c) ? (t) : (f))
#define _INTEG(value, rate) ((value) + (rate) * _time_step)
#define _INTEGER(x) trunc(x)
Expand Down
Loading

0 comments on commit 3d9b8e6

Please sign in to comment.