@@ -21,7 +21,7 @@ fulfilled.
2121 the stochastic problem we want to optimize
2222* `param::SDDPparameters`:
2323 the parameters of the SDDP algorithm
24- * `display::Int64) `:
24+ * `display::Int64`:
2525 Default is `0`
2626 If non null, display progression in terminal every
2727 `n` iterations, where `n` is number specified by display.
@@ -32,20 +32,24 @@ fulfilled.
3232* `problems::Array{JuMP.Model}`:
3333 the collection of linear problems used to approximate
3434 each value function
35+ * `count_callsolver::Int64`:
36+ number of times the solver has been called
37+
3538"""
3639function solve_SDDP (model:: SPModel , param:: SDDPparameters , display= 0 :: Int64 )
3740 # initialize value functions:
3841 V, problems = initialize_value_functions (model, param)
3942 # Run SDDP upon example:
40- run_SDDP! (model, param, V, problems, display)
41- return V, problems
43+ count_callsolver = run_SDDP! (model, param, V, problems, display)
44+ return V, problems, count_callsolver
4245end
4346
47+
4448function solve_SDDP (model:: SPModel , param:: SDDPparameters , V:: Vector{PolyhedralFunction} , display= 0 :: Int64 )
4549 # First step: process value functions if hotstart is called
4650 problems = hotstart_SDDP (model, param, V)
47- run_SDDP! (model, param, V, problems, display)
48- return V, problems
51+ count_callsolver = run_SDDP! (model, param, V, problems, display)
52+ return V, problems, count_callsolver
4953end
5054
5155
@@ -56,6 +60,9 @@ function run_SDDP!(model::SPModel,
5660 problems:: Vector{JuMP.Model} ,
5761 display= 0 :: Int64 )
5862
63+ # Initialization of the counter
64+ count_callsolver:: Int = 0
65+
5966 if display > 0
6067 println (" Initialize cuts" )
6168 end
@@ -80,20 +87,23 @@ function run_SDDP!(model::SPModel,
8087 noise_scenarios = simulate_scenarios (model. noises, param. forwardPassNumber)
8188
8289 # Forward pass
83- stockTrajectories = forward_simulations (model,
90+ _, stockTrajectories,_,callsolver_forward = forward_simulations (model,
8491 param,
8592 problems,
86- noise_scenarios)[2 ]
93+ noise_scenarios)
94+
8795
8896 # Backward pass
89- backward_pass! (model,
97+ callsolver_backward = backward_pass! (model,
9098 param,
9199 V,
92100 problems,
93101 stockTrajectories,
94102 model. noises,
95103 false )
96104
105+ # Update the number of call
106+ count_callsolver += callsolver_forward + callsolver_backward
97107
98108 iteration_count += 1
99109
@@ -138,6 +148,8 @@ function run_SDDP!(model::SPModel,
138148 println (" Estimation of cost of the solution (fiability 95\% ):" ,
139149 round (mean (costs),4 ), " +/- " , round (1.96 * std (costs)/ sqrt (length (costs)),4 ))
140150 end
151+
152+ return count_callsolver
141153end
142154
143155
@@ -169,6 +181,7 @@ function estimate_upper_bound(model::SPModel, param::SDDPparameters,
169181
170182 aleas = simulate_scenarios (model. noises, n_simulation)
171183
184+ callsolver:: Int = 0
172185 costs, stockTrajectories, _ = forward_simulations (model,
173186 param,
174187 problem,
@@ -328,7 +341,7 @@ function initialize_value_functions(model::SPModel,
328341 end
329342
330343
331- backward_pass! (model,
344+ callsolver = backward_pass! (model,
332345 param,
333346 V,
334347 solverProblems,
@@ -552,4 +565,3 @@ function is_cut_relevant(model::SPModel, k::Int, Vt::PolyhedralFunction, solver;
552565 sol = getobjectivevalue (m)
553566 return sol < epsilon
554567end
555-
0 commit comments