# Historical simulation in SDDP.jl

Hi,
I did simulation in SDDP.jl using historical data. It works; however, I could not retrieve the optimal solutions anymore by simply putting [:variable] as an argument in SDDP.simulate.
What should we do in historical simulation to obtain the optimal solution?

I could not retrieve the optimal solutions anymore by simply putting [:variable] as an argument in SDDP.simulate

You should be able to.

Do you have a reproducible example?

``````using SDDP, HiGHS
T = Array{Float64,2}[[1.0]', [0.75 0.25], [0.75 0.25; 0.25 0.75]]
Ω = [
(inflow = 0.0, fuel_multiplier = 1.5),
(inflow = 50.0, fuel_multiplier = 1.0),
(inflow = 100.0, fuel_multiplier = 0.75),
]

model = SDDP.MarkovianPolicyGraph(
transition_matrices = Array{Float64,2}[
[1.0]',
[0.75 0.25],
[0.75 0.25; 0.25 0.75],
],
sense = :Min,
lower_bound = 0.0,
optimizer = HiGHS.Optimizer,
) do subproblem, node
# Unpack the stage and Markov index.
t, markov_state = node
# Define the state variable.
@variable(subproblem, 0 <= volume <= 200, SDDP.State, initial_value = 200)
# Define the control variables.
@variables(subproblem, begin
thermal_generation >= 0
hydro_generation >= 0
hydro_spill >= 0
inflow
end)
# Define the constraints
@constraints(
subproblem,
begin
volume.out == volume.in + inflow - hydro_generation - hydro_spill
thermal_generation + hydro_generation == 150.0
end
)
# Note how we can use `markov_state` to dispatch an `if` statement.
probability = if markov_state == 1  # wet climate state
[1 / 6, 1 / 3, 1 / 2]
else  # dry climate state
[1 / 2, 1 / 3, 1 / 6]
end

fuel_cost = [50.0, 100.0, 150.0]
SDDP.parameterize(subproblem, Ω, probability) do ω
JuMP.fix(inflow, ω.inflow)
@stageobjective(
subproblem,
ω.fuel_multiplier * fuel_cost[t] * thermal_generation
)
end
end

SDDP.train(model, time_limit = 10)

simulations = SDDP.simulate(
model,
sampling_scheme = SDDP.Historical([
((1, 1), Ω[1]),
((2, 2), Ω[3]),
((3, 1), Ω[2]),
]), [:hydro_spill])
``````

I took this code from:

, and just put [:hydro_spill] at the end of the code. I just run it and got this error:

``````MethodError: no method matching simulate(::SDDP.PolicyGraph{Tuple{Int64, Int64}}, ::Vector{Symbol}; sampling_scheme::SDDP.Historical{Tuple{Int64, Int64}, NamedTuple{(:inflow, :fuel_multiplier), Tuple{Float64, Float64}}})
``````

`sampling_scheme` is a keyword argument. You need to pass the required positional arguments first:

``````simulations = SDDP.simulate(
model,
1,
[:hydro_spill];
sampling_scheme = SDDP.Historical([
((1, 1), Ω[1]),
((2, 2), Ω[3]),
((3, 1), Ω[2]),
]),
)
``````