# SDDP: type Array has no field out

**URL:** <https://discourse.julialang.org/t/sddp-type-array-has-no-field-out/82731>\
**Category:** Optimization (Mathematical)\
**Created:** [June 14, 2022, 8:22am UTC](https://discourse.julialang.org/t/sddp-type-array-has-no-field-out/82731 "2022-06-14T08:22:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![chenr86](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chenr86/32/36785_2.png) [@chenr86](https://discourse.julialang.org/u/chenr86)\
**Post date:** [June 14, 2022, 8:22am UTC](https://discourse.julialang.org/t/sddp-type-array-has-no-field-out/82731/1 "2022-06-14T08:22:29Z")

</div>

Hello,

I’m using SDDP to solve my problem. Now I want to print the result of stage variable `level`, which is an array with 4 components. For loop structure is used to show the result:

```julia
model = SDDP.LinearPolicyGraph(
    stages = numtime,
    sense = :Min,
    lower_bound = 0.0,
    optimizer = Ipopt.Optimizer,
) do sp, node
    # State variables
    @variable(
        sp, 
        min_level[i] <= level[i = 1:4] <= max_level[i], 
        SDDP.State, 
        initial_value = initial_level[i]
    )
...
end
...
# Show results
for stage in simulations[1]
    println("level = $(stage[:level].out)")
end

```

But when I run the code, it tells me `type Array has no field out`

If I write `println("level = $(stage[:level])")`, I get the following result:

```julia
level = SDDP.State{Float64}[SDDP.State{Float64}(273.0, 273.6889607972534), SDDP.State{Float64}(225.0, 225.08061916277788), SDDP.State{Float64}(267.0, 267.3945072693355), SDDP.State{Float64}(267.0, 267.5107715473515)]

```

How can I get the out\_state result of level like this one:

```julia
flow = [5.7101953228017096e-5, 2.6717931469687598e-5, 4.8417835777304285e-5, 3.3381189977914406e-5]

```

---

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [June 14, 2022, 9:22am UTC](https://discourse.julialang.org/t/sddp-type-array-has-no-field-out/82731/2 "2022-06-14T09:22:58Z")

</div>

You need `[x.out for x in stage[:level]]`.

> `level = SDDP.State{Float64}[SDDP.State{Float64}(273.0, 273.6889607972534), SDDP.State{Float64}(225.0, 225.08061916277788), SDDP.State{Float64}(267.0, 267.3945072693355), SDDP.State{Float64}(267.0, 267.5107715473515)]`

Let’s break this down:

- The Julia syntax. `T[... stuff ...]` means an `Array` of stuff with element type `T`.
- So `SDDP.State{Float64}[...]` means you have an array, with element type `SDDP.State{Float64}`
- So you have an array of state variables, not a state variable that is an array (if that makes sense)
- `[x.out for x in stage[:level]]` says "create a new array, which is built by looping over each `x` in `stage[:level]`, and returning `x.out`.
