Asset management
Taken from the book J.R. Birge, F. Louveaux, Introduction to Stochastic Programming, Springer Series in Operations Research and Financial Engineering, Springer New York, New York, NY, 2011
using SDDP, HiGHS, Test
function asset_management_simple()
model = SDDP.PolicyGraph(
SDDP.MarkovianGraph(
Array{Float64,2}[
[1.0]',
[0.5 0.5],
[0.5 0.5; 0.5 0.5],
[0.5 0.5; 0.5 0.5],
],
),
lower_bound = -1_000.0,
optimizer = HiGHS.Optimizer,
) do subproblem, index
(stage, markov_state) = index
rstock = [1.25, 1.06]
rbonds = [1.14, 1.12]
@variable(subproblem, stocks >= 0, SDDP.State, initial_value = 0.0)
@variable(subproblem, bonds >= 0, SDDP.State, initial_value = 0.0)
if stage == 1
@constraint(subproblem, stocks.out + bonds.out == 55)
@stageobjective(subproblem, 0)
elseif 1 < stage < 4
@constraint(
subproblem,
rstock[markov_state] * stocks.in +
rbonds[markov_state] * bonds.in == stocks.out + bonds.out
)
@stageobjective(subproblem, 0)
else
@variable(subproblem, over >= 0)
@variable(subproblem, short >= 0)
@constraint(
subproblem,
rstock[markov_state] * stocks.in +
rbonds[markov_state] * bonds.in - over + short == 80
)
@stageobjective(subproblem, -over + 4 * short)
end
end
SDDP.train(model, iteration_limit = 25, log_frequency = 5)
@test SDDP.termination_status(model) == :iteration_limit
@test SDDP.calculate_bound(model) ≈ 1.514 atol = 1e-4
return
end
asset_management_simple()------------------------------------------------------------------------------
SDDP.jl (c) Oscar Dowson and SDDP.jl contributors, 2017-23
Problem
Nodes : 7
State variables : 2
Scenarios : 8.00000e+00
Existing cuts : false
Subproblem structure : (min, max)
Variables : (5, 7)
VariableRef in MOI.LessThan{Float64} : (1, 1)
VariableRef in MOI.GreaterThan{Float64} : (3, 5)
AffExpr in MOI.EqualTo{Float64} : (1, 1)
Options
Solver : serial mode
Risk measure : SDDP.Expectation()
Sampling scheme : SDDP.InSampleMonteCarlo
Numerical stability report
Non-zero Matrix range [1e+00, 1e+00]
Non-zero Objective range [1e+00, 4e+00]
Non-zero Bounds range [1e+03, 1e+03]
Non-zero RHS range [6e+01, 8e+01]
No problems detected
Iteration Simulation Bound Time (s) Proc. ID # Solves
5 2.747392e+01 -1.170596e+00 9.867907e-03 1 55
10 -8.924811e+00 1.508277e+00 1.725101e-02 1 110
15 -1.428571e+00 1.514085e+00 2.552390e-02 1 165
20 4.864000e+01 1.514085e+00 3.406692e-02 1 220
25 -2.479988e+01 1.514085e+00 4.418898e-02 1 275
Terminating training
Status : iteration_limit
Total time (s) : 4.418898e-02
Total solves : 275
Best bound : 1.514085e+00
Simulation CI : -3.247455e+00 ± 7.939847e+00
------------------------------------------------------------------------------This page was generated using Literate.jl.