odow / SDDP.jl

Stochastic Dual Dynamic Programming in Julia

Home Page:https://sddp.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Evaluating at multidimensional state ?

HenriDeh opened this issue · comments

Hello,

I'm pretty sure this is a documentation issue and that the functionality exists internally, but I can't figure out how to evaluate a DecisionRule with a state that's not a scalar.

The example at https://sddp.dev/stable/apireference/#SDDP.evaluate only shows the case with the scalar :volume variable. But what if volume is a variable declared as multidimensional? The incoming_state argument of evaluate expects Symbol => Float64 pairs.

I can contribute to improve the documentation with the answer if you want.

Yeah, this is one part of the API that needs fixing. But I could never decide the right thing to do.

The answer is that you need to use Symbol(n) where n is the string returned by JuMP.name(x). For example, with the state:

@variable(sp, x[1:2], SDDP.State, initial_value = 0)

you'd need:
incoming_state = Dict(Symbol("x[1]") => 0.0, Symbol("x[2]") => 0.0).

But this is complicated, confusing, and not at all nice. I need a better way...

Thank you, this will do for me. I suppose the difficulty is to keep a Symbol to Float dictionary to preserve type stability, which would not be possible if the values were sometimes arrays and sometimes floats. I don't know if you want this issue closed or to keep it open. I'll let you decide.

One reason I haven't made this nicer is that, in general, I find that in most cases you want to use SDDP.simulate instead of querying particular values of the decision rule.