Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # get!(f::Function, collection, key)
- #
- # Return the value stored for the given key, or if no mapping for the key is present, store key =>
- # f(), and return f().
- #
- # This is intended to be called using do block syntax:
- #
- # get!(dict, key) do
- # # default value calculated here
- # time()
- # end
- # code from https://stackoverflow.com/q/54244661/1346276
- function V2(t, K)
- if t >= T
- return 0.0
- else
- get!(V2dict, (t, K)) do
- opt = optimize(K′ -> -(log(K - K′) + β * V2(t+1, K′)), eps(), K, iterations = 100_000)
- Optim.minimum(opt)
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement