Skip to content

Commit

Permalink
Implement supporting the RAMP function from xmile specification.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexprey committed Sep 21, 2017
1 parent b18e118 commit 6f72dd2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
15 changes: 9 additions & 6 deletions pysd/py_backend/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -744,9 +744,9 @@ def _integrate(self, time_steps, capture_elements, return_timestamps):
return outputs


def ramp(slope, start, finish):
def ramp(slope, start, finish=0):
"""
Implements vensim's RAMP function
Implements vensim's and xmile's RAMP function
Parameters
----------
Expand All @@ -755,7 +755,7 @@ def ramp(slope, start, finish):
start: float
Time at which the ramp begins
finish: float
Time at which the ramo ends
Optional. Time at which the ramp ends
Returns
-------
Expand All @@ -770,10 +770,13 @@ def ramp(slope, start, finish):
t = time()
if t < start:
return 0
elif t > finish:
return slope * (finish - start)
else:
return slope * (t - start)
if finish <= 0:
return slope * (t - start)
elif t > finish:
return slope * (finish - start)
else:
return slope * (t - start)


def step(value, tstep):
Expand Down
3 changes: 1 addition & 2 deletions pysd/py_backend/xmile/SMILE2Py.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@

"pulse": "functions.pulse_magnitude",
"step": "functions.step",

# "ramp" !TODO!
"ramp" "functions.ramp",

# ===
# 3.5.5 Time Functions
Expand Down

0 comments on commit 6f72dd2

Please sign in to comment.