Skip to content

Commit ae519cf

Browse files
committed
[FIX] n in stopping criterion and some documentation
1 parent 93eacff commit ae519cf

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

src/SDDPoptimize.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ function run_SDDP!(model::SPModel,
153153
####################
154154
# Stopping test
155155
stopping_test = test_stopping_criterion(param,stats)
156+
stats.niterations += 1
156157
end
157158

158159
##########

src/objects.jl

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,9 @@ Test compatibility of parameters.
186186
* `param::SDDPparameters`:
187187
Parameters of SDDP
188188
* `verbose:Int64`:
189+
190+
# Return
191+
`Bool`
189192
"""
190193
function check_SDDPparameters(model::SPModel,param::SDDPparameters,verbose=0::Int64)
191194
if model.IS_SMIP && isa(param.MIPSOLVER, Void)
@@ -256,9 +259,22 @@ end
256259

257260
SDDPStat() = SDDPStat(0, [], [], [], 0)
258261

262+
"""
263+
Update the SDDPStat object with the results of current iterations.
264+
265+
# Arguments
266+
* `stats::SDDPStat`:
267+
statistics of the current algorithm
268+
* `call_solver_at_it::Int64`:
269+
number of time a solver was called during the current iteration
270+
* `lwb::Float64`:
271+
lowerbound obtained
272+
* `upb::Float64`:
273+
upperbound estimated
274+
* `time`
275+
"""
259276
function updateSDDPStat!(stats::SDDPStat,callsolver_at_it::Int64,lwb::Float64,upb::Float64,time)
260277
stats.ncallsolver += callsolver_at_it
261-
stats.niterations += 1
262278
push!(stats.lower_bounds, lwb)
263279
push!(stats.upper_bounds, upb)
264280
push!(stats.exectime, time)

src/stoppingtest.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Return true if |upper_bound - lower_bound|/lower_bound < epsilon
1616
or iteration_count > maxItNumber
1717
1818
# Arguments
19-
*`SDDPparameters`:
19+
*`param::SDDPparameters`:
2020
stopping test type defined in SDDPparameters
2121
* `stats::SDDPStat`:
2222
statistics of the current algorithm
@@ -28,7 +28,7 @@ function test_stopping_criterion(param::SDDPparameters, stats::SDDPStat)
2828
lb = stats.lower_bounds[end]
2929
ub = stats.upper_bounds[end]
3030
check_gap = (abs((ub-lb)/lb) < param.gap)
31-
check_iter = stats.niterations > param.maxItNumber
31+
check_iter = stats.niterations >= param.maxItNumber
3232
return check_gap || check_iter
3333
end
3434

0 commit comments

Comments
 (0)