@@ -24,10 +24,10 @@ const SOLVER = ClpSolver()
2424# const SOLVER = CplexSolver(CPX_PARAM_SIMDISPLAY=0) # require "using CPLEX"
2525
2626# convergence test
27- const MAX_ITER = 100 # number of iterations of SDDP
27+ const MAX_ITER = 10 # number of iterations of SDDP
2828
2929# ####### Stochastic Model Parameters ########
30- const N_STAGES = 5 # number of stages of the SP problem
30+ const N_STAGES = 6 # number of stages of the SP problem
3131const COSTS = rand (N_STAGES) # generating deterministic costs
3232
3333const CONTROL_MAX = 0.5 # bounds on the control
@@ -65,8 +65,8 @@ println("Model set up")
6565# ######## Solving the problem via SDDP
6666if run_sddp
6767 println (" Starting resolution by SDDP" )
68- paramSDDP = SDDPparameters (SOLVER, 2 , 0 , MAX_ITER) # 2 forward pass, stop at MAX_ITER
69- V, pbs = solve_SDDP (spmodel, paramSDDP, 10 ) # display information every 10 iterations
68+ paramSDDP = SDDPparameters (SOLVER, 10 , 0 , MAX_ITER) # 10 forward pass, stop at MAX_ITER
69+ V, pbs = solve_SDDP (spmodel, paramSDDP, 2 ) # display information every 2 iterations
7070 lb_sddp = StochDynamicProgramming. get_lower_bound (spmodel, paramSDDP, V)
7171 println (" Lower bound obtained by SDDP: " * string (round (lb_sddp,4 )))
7272end
8585
8686if run_ef
8787 println (" Starting resolution by Extensive Formulation" )
88- println ( extensive_formulation (spmodel, paramSDDP))
8988 value_ef = extensive_formulation (spmodel, paramSDDP)[1 ]
9089 println (" Value obtained by Extensive Formulation: " * string (round (value_ef,4 )))
91- println (round (value_sdp/ value_ef,4 ))
92- println (round (lb_sddp/ value_ef,4 ))
90+ println (" Relative error of SDP value: " * string ( 100 * round (value_sdp/ value_ef- 1 ,4 )) * " % " )
91+ println (" Relative error of SDDP lower bound: " * string ( 100 * round (lb_sddp/ value_ef- 1 ,4 )) * " % " )
9392end
9493
9594# ######## Comparing the solutions on simulated scenarios.
@@ -101,6 +100,6 @@ if run_sdp
101100 costsdp, states, stocks = sdp_forward_simulation (spmodel,paramSDP,scenarios,Vs)
102101end
103102if run_sddp && run_sdp
104- println (" Relative difference between sddp and sdp: " * string (2 * round (mean (costsddp- costsdp)/ mean (costsddp+ costsdp),4 )))
103+ println (" Simulated relative difference between sddp and sdp: "
104+ * string (round (200 * mean (costsddp- costsdp)/ mean (costsddp+ costsdp),3 ))* " %" )
105105end
106-
0 commit comments