Yes, basically a list of
q = (:a, [:b, :c, :d], :(a = b + c + d))
# if you have all of q[2] you can calculate q[1] with the expression in q[3]
which increases the list of parameters I know or can calculate. I iterate this until everything is either known, calculable or is free (= an optimization variable).
This sounds great but I’m still unsure of how to do this.
From your example
f = let a=2, d=somefunction(a)
x -> cost(a, x[1], a*x[1], d)
end
assuming I know the let
needs to look just like this, how do I create it? I only know I’ll need somefunction
and not otherfunction
at runtime so I can’t just write it down. Somewhere in there the dependencies would need to be resolved (and from that I don’t know what to return other than expressions).
The only option I can think of right now would be along the lines of
function resolve(config)
if config == example_1
a = (x) -> 2
b = (x) -> x[1]
c = (x) -> 2 * x[1]
d = (x) -> 2 / 2
return a, b, c, d
else config == example_2
a = (x) -> 2 * x[1]
b = (x) -> 5
c = (x) -> ((x) -> 2 * x[1])(x) * 5 # not sure yet how to put one value inside another
d = (x) -> x[1]
return a, b, c, d
end
end
f = let
fa, fb, fc, fd = resolve(config)
x -> cost(fa(x), fb(x), fc(x), fd(x))
end
During the resolving I’d look up the functions I have written out here.
Did you mean something like this?