-
Notifications
You must be signed in to change notification settings - Fork 35
Closed
Labels
Description
We may want to add versions of adder
that allow for missing
values, or that allow first
and last
bounds.
examples (need better names):
@defcomp adder2 begin
add = Parameter(index=[time])
input = Parameter(index=[time])
output = Variable(index=[time])
function run_timestep(p, v, d, t)
v.output[t] = Mimi.@allow_missing(p.input[t]) + p.add[t]
end
end
or
@defcomp adder3 begin
add = Parameter(index=[time])
input = Parameter(index=[time])
output = Variable(index=[time])
first::Int = Parameter(default=0)
last::Int = Parameter(default=typemax(Int))
function run_timestep(p, v, d, t)
if first < getindex(t) < last
v.output[t] = p.input[t] + p.add[t]
end
end
end
Note that in this version of adder3
, we would need to decide if first
and last
are index values, in which case we need to add a getindex(t)
function, or if they refer to actual year values, in which case we would need to use gettime(t)
and this would only work for time indexes that are Ints.