Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
odow committed Jul 25, 2024
1 parent 2b19b17 commit a003431
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 13 deletions.
2 changes: 0 additions & 2 deletions docs/src/examples/air_conditioning_forward.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ SDDP.train(
forward_pass = SDDP.AlternativeForwardPass(non_convex),
post_iteration_callback = SDDP.AlternativePostIterationCallback(non_convex),
iteration_limit = 10,
# TODO(odow): bug with Threaded?
parallel_scheme = SDDP.Serial(),
)
Test.@test isapprox(SDDP.calculate_bound(non_convex), 62_500.0, atol = 0.1)
Test.@test isapprox(SDDP.calculate_bound(convex), 62_500.0, atol = 0.1)
8 changes: 8 additions & 0 deletions src/algorithm.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1026,6 +1026,14 @@ function train(
forward_pass_callback::Function = (x) -> nothing,
post_iteration_callback = result -> nothing,
)
if any(node -> node.objective_state !== nothing, values(model.nodes))
# FIXME(odow): Threaded is broken for objective states
parallel_scheme = Serial()
end
if forward_pass isa AlternativeForwardPass
# FIXME(odow): Threaded is broken for AlternativeForwardPass
parallel_scheme = Serial()
end
if log_frequency <= 0
msg = "`log_frequency` must be at least `1`. Got $log_frequency."
throw(ArgumentError(msg))
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/forward_passes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ function forward_pass(
# incoming state is more than δ away from the other states, add it
# as a possible starting state.
if distance(starting_states, incoming_state_value) >
options.cycle_discretization_delta
options.cycle_discretization_delta
push!(starting_states, incoming_state_value)
end
# TODO(odow):
Expand Down
2 changes: 0 additions & 2 deletions test/plugins/stopping_rules.jl
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,6 @@ function test_FirstStageStoppingRule()
model;
print_level = 0,
stopping_rules = [SDDP.FirstStageStoppingRule()],
parallel_scheme = SDDP.Serial(),
),
)
graph = SDDP.Graph(0, [1, 2], [(0 => 1, 0.5), (0 => 2, 0.5)])
Expand All @@ -338,7 +337,6 @@ function test_FirstStageStoppingRule()
model;
print_level = 0,
stopping_rules = [SDDP.FirstStageStoppingRule()],
parallel_scheme = SDDP.Serial(),
),
)
return
Expand Down
2 changes: 1 addition & 1 deletion test/user_interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ function test_objective_state()
end
@test_throws(
ErrorException("No objective state defined."),
SDDP.simulate(model, 1; parallel_scheme = SDDP.Serial()),
SDDP.simulate(model, 1),
)
@test_throws(
ErrorException("add_objective_state can only be called once."),
Expand Down
8 changes: 1 addition & 7 deletions test/visualization/value_functions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,7 @@ function test_ValueFunction_objective_state()
@stageobjective(sp, price * x.out)
end
end
SDDP.train(
model;
iteration_limit = 10,
print_level = 0,
# TODO(odow): FIXME: SDDP.Threaded() gets the wrong answer?
parallel_scheme = SDDP.Serial(),
)
SDDP.train(model; iteration_limit = 10, print_level = 0)
V1 = SDDP.ValueFunction(model[1])
@test_throws AssertionError SDDP.evaluate(V1, Dict(:x => 1.0))
@test SDDP.evaluate(V1, Dict(:x => 1.0); objective_state = 1) ==
Expand Down

0 comments on commit a003431

Please sign in to comment.