Why can't I set the `initial_value` to a matrix value when using `SDDP.jl`?

The syntax is:

volume_start = [200 200; 200 200]
@variable(subproblem, 0 <= volume[i=1:2, j=1:2] <= 200, SDDP.State, initial_value = volume_start[i,j])

This syntax is not specific to SDDP. It applies to all JuMP variables.

julia> model = Model();

julia> @variable(model, x[1:2], start = [1, 2])
ERROR: At REPL[68]:1: `@variable(model, x[1:2], start = [1, 2])`: Passing arrays as variable starts without indexing them is not supported.

Instead of:
```julia
@variable(model, x[1:2], start = x0)
```
use
```julia
@variable(model, x[i=1:2], start = x0[i])
```
or
```julia
@variable(model, x[1:2])
set_start_value.(x, x0)
```

I guess I should improve the error message in SDDP.jl.

is there any better method to querying the out / in field from a matrix type state variable

getfield.(volume, :out) should work.

1 Like