@@ -305,7 +305,8 @@ function test_parameterize()
305
305
end
306
306
node = model[2 ]
307
307
@test length (node. noise_terms) == 3
308
- @test JuMP. upper_bound (node. subproblem[:x ]) == 1
308
+ # SDDP is allowed to call `parameterize` during construction
309
+ # @test JuMP.upper_bound(node.subproblem[:x]) == 1
309
310
node. parameterize (node. noise_terms[2 ]. term)
310
311
@test JuMP. upper_bound (node. subproblem[:x ]) == 2
311
312
node. parameterize (3 )
@@ -486,20 +487,19 @@ function test_numerical_stability_report()
486
487
end
487
488
488
489
function test_objective_state ()
489
- model = SDDP. LinearPolicyGraph (;
490
- stages = 2 ,
491
- lower_bound = 0 ,
492
- optimizer = HiGHS. Optimizer,
493
- ) do subproblem, t
494
- @variable (subproblem, x, SDDP. State, initial_value = 0 )
495
- SDDP. parameterize (subproblem, [1 , 2 ]) do ω
496
- price = SDDP. objective_state (subproblem)
497
- @stageobjective (subproblem, price * x. out)
498
- end
499
- end
500
490
@test_throws (
501
491
ErrorException (" No objective state defined." ),
502
- SDDP. simulate (model, 1 ; parallel_scheme = SDDP. Serial ()),
492
+ SDDP. LinearPolicyGraph (;
493
+ stages = 2 ,
494
+ lower_bound = 0 ,
495
+ optimizer = HiGHS. Optimizer,
496
+ ) do subproblem, t
497
+ @variable (subproblem, x, SDDP. State, initial_value = 0 )
498
+ SDDP. parameterize (subproblem, [1 , 2 ]) do ω
499
+ price = SDDP. objective_state (subproblem)
500
+ @stageobjective (subproblem, price * x. out)
501
+ end
502
+ end ,
503
503
)
504
504
@test_throws (
505
505
ErrorException (" add_objective_state can only be called once." ),
@@ -911,6 +911,71 @@ function test_print_problem_statistics()
911
911
return
912
912
end
913
913
914
+ function test_incoming_state_bounds ()
915
+ graph = SDDP. Graph (0 )
916
+ SDDP. add_node .((graph,), 1 : 4 )
917
+ SDDP. add_edge (graph, 0 => 4 , 1.0 )
918
+ SDDP. add_edge (graph, 4 => 1 , 0.5 )
919
+ SDDP. add_edge (graph, 4 => 2 , 0.5 )
920
+ SDDP. add_edge (graph, 1 => 2 , 1.0 )
921
+ SDDP. add_edge (graph, 2 => 3 , 0.5 )
922
+ SDDP. add_edge (graph, 3 => 1 , 0.5 )
923
+ SDDP. add_edge (graph, 3 => 4 , 0.5 )
924
+ model = SDDP. PolicyGraph (graph; lower_bound = 0.0 ) do sp, node
925
+ @variable (sp, x, Int, SDDP. State, initial_value = 0 )
926
+ @variable (sp, y, SDDP. State, initial_value = - 1 )
927
+ @variable (sp, z, SDDP. State, initial_value = 1 )
928
+ if node == 1
929
+ set_binary (z. out)
930
+ SDDP. parameterize (sp, 1 : 2 ) do w
931
+ JuMP. set_lower_bound (x. out, - w)
932
+ JuMP. set_upper_bound (y. out, w)
933
+ return
934
+ end
935
+ elseif node == 2
936
+ SDDP. parameterize (sp, 1 : 2 ) do w
937
+ if w == 1
938
+ set_upper_bound (y. out, 1.0 )
939
+ elseif w == 2 && has_upper_bound (y. out)
940
+ delete_upper_bound (y. out)
941
+ end
942
+ return
943
+ end
944
+ elseif node == 3
945
+ set_lower_bound (x. out, 1 )
946
+ set_upper_bound (x. out, 2 )
947
+ fix (y. out, 3 )
948
+ elseif node == 4
949
+ fix (x. out, 0 )
950
+ fix (y. out, - 1 )
951
+ fix (z. out, 1 )
952
+ end
953
+ @stageobjective (sp, 0 )
954
+ return
955
+ end
956
+ @test model[1 ]. incoming_state_bounds == Dict (
957
+ :x => (0.0 , 2.0 , true ),
958
+ :y => (- 1.0 , 3.0 , false ),
959
+ :z => (- Inf , Inf , false ),
960
+ )
961
+ @test model[2 ]. incoming_state_bounds == Dict (
962
+ :x => (- 2.0 , Inf , true ),
963
+ :y => (- Inf , 2.0 , false ),
964
+ :z => (0.0 , 1.0 , false ),
965
+ )
966
+ @test model[3 ]. incoming_state_bounds == Dict (
967
+ :x => (- Inf , Inf , true ),
968
+ :y => (- Inf , Inf , false ),
969
+ :z => (- Inf , Inf , false ),
970
+ )
971
+ @test model[4 ]. incoming_state_bounds == Dict (
972
+ :x => (- Inf , Inf , false ),
973
+ :y => (- Inf , Inf , false ),
974
+ :z => (- Inf , Inf , false ),
975
+ )
976
+ return
977
+ end
978
+
914
979
end # module
915
980
916
981
TestUserInterface. runtests ()
0 commit comments