Skip to content

Commit adedb88

Browse files
committed
[UPD] Improve linting in SDDPoptimize.jl
1 parent 3b38adf commit adedb88

File tree

1 file changed

+8
-17
lines changed

1 file changed

+8
-17
lines changed

src/SDDPoptimize.jl

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ fulfilled.
3434
each value function
3535
* `count_callsolver::Int64`:
3636
number of times the solver has been called
37-
37+
3838
"""
3939
function solve_SDDP(model::SPModel, param::SDDPparameters, display=0::Int64)
4040
# initialize value functions:
@@ -180,15 +180,11 @@ function estimate_upper_bound(model::SPModel, param::SDDPparameters,
180180
n_simulation=1000::Int)
181181

182182
aleas = simulate_scenarios(model.noises, n_simulation)
183-
184-
callsolver::Int = 0
185-
costs, stockTrajectories, _ = forward_simulations(model,
186-
param,
187-
problem,
188-
aleas)
189-
183+
costs, stockTrajectories, _ = forward_simulations(model, param, problem, aleas)
190184
return upper_bound(costs), costs
191185
end
186+
187+
192188
function estimate_upper_bound(model::SPModel, param::SDDPparameters,
193189
aleas::Array{Float64, 3},
194190
problem::Vector{JuMP.Model})
@@ -199,13 +195,7 @@ end
199195

200196
"""Build a collection of cuts initialized at 0"""
201197
function get_null_value_functions_array(model::SPModel)
202-
203-
V = Vector{PolyhedralFunction}(model.stageNumber)
204-
for t = 1:model.stageNumber
205-
V[t] = PolyhedralFunction(zeros(1), zeros(1, model.dimStates), 1)
206-
end
207-
208-
return V
198+
return [PolyhedralFunction(zeros(1), zeros(1, model.dimStates), 1) for i in 1:model.stageNumber]
209199
end
210200

211201

@@ -298,7 +288,6 @@ function build_models(model::SPModel, param::SDDPparameters)
298288
end
299289

300290

301-
302291
"""
303292
Initialize value functions along a given trajectory
304293
@@ -461,7 +450,8 @@ Compute optimal control at point xt and time t.
461450
# Return
462451
`Vector{Float64}`: optimal control at time t
463452
"""
464-
function get_control(model::SPModel, param::SDDPparameters, lpproblem::Vector{JuMP.Model}, t::Int, xt::Vector{Float64}, xi::Vector{Float64})
453+
function get_control(model::SPModel, param::SDDPparameters, lpproblem::Vector{JuMP.Model},
454+
t::Int, xt::Vector{Float64}, xi::Vector{Float64})
465455
return solve_one_step_one_alea(model, param, lpproblem[t], t, xt, xi)[2].optimal_control
466456
end
467457

@@ -565,3 +555,4 @@ function is_cut_relevant(model::SPModel, k::Int, Vt::PolyhedralFunction, solver;
565555
sol = getobjectivevalue(m)
566556
return sol < epsilon
567557
end
558+

0 commit comments

Comments
 (0)