Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Evaluating at multidimensional state ? #703

Open
HenriDeh opened this issue Oct 24, 2023 · 3 comments
Open

Evaluating at multidimensional state ? #703

HenriDeh opened this issue Oct 24, 2023 · 3 comments

Comments

@HenriDeh
Copy link

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.

@odow
Copy link
Owner

odow commented Oct 24, 2023

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...

@HenriDeh
Copy link
Author

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.

@odow
Copy link
Owner

odow commented Oct 25, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants