Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev sdp search spaces #143

Merged
merged 19 commits into from
Apr 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ script:
- if [[ -a .git/shallow ]]; then git fetch --unshallow; fi
- julia -e 'Pkg.clone(pwd()); Pkg.build("StochDynamicProgramming"); Pkg.test("StochDynamicProgramming"; coverage=true)'
before_script:
- julia -e 'Pkg.clone("https://github.com/StructJuMP/StructJuMP.jl.git")'
- julia -e 'Pkg.clone("https://github.com/JuliaPolyhedra/CutPruners.jl")'
- julia -e 'Pkg.clone("https://github.com/blegat/StochasticDualDynamicProgramming.jl")'
after_success:
Expand Down
4 changes: 2 additions & 2 deletions examples/battery_storage_parallel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,10 @@ println("library loaded")
controlSteps, infoStruct)
end

Vs = StochDynamicProgramming.solve_DP(spmodel,paramSDP, 1)
Vs = StochDynamicProgramming.solve_dp(spmodel,paramSDP, 1)

lb_sdp = StochDynamicProgramming.get_bellman_value(spmodel,paramSDP,Vs)
println("Value obtained by SDP: "*string(lb_sdp))
costsdp, states, stocks = StochDynamicProgramming.sdp_forward_simulation(spmodel,paramSDP,scenarios,Vs)
costsdp, states, stocks = StochDynamicProgramming.forward_simulations(spmodel,paramSDP,Vs,scenarios)
println(mean(costsdp))

4 changes: 2 additions & 2 deletions examples/multistock-example.jl
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ if run_sdp
spmodel_sdp = StochDynamicProgramming.build_sdpmodel_from_spmodel(spmodel)
spmodel_sdp.constraints = constraints_dp

Vs = solve_DP(spmodel_sdp, paramSDP, 1)
Vs = solve_dp(spmodel_sdp, paramSDP, 1)
value_sdp = StochDynamicProgramming.get_bellman_value(spmodel,paramSDP,Vs)
println("Value obtained by SDP: "*string(round(value_sdp,4)))
toc(); println();
Expand All @@ -113,7 +113,7 @@ end
if run_sddp && run_sdp && test_simulation
scenarios = StochDynamicProgramming.simulate_scenarios(xi_laws,1000)
costsddp, stocks = forward_simulations(spmodel, paramSDDP, sddp.solverinterface, scenarios)
costsdp, states, controls = sdp_forward_simulation(spmodel,paramSDP,scenarios,Vs)
costsdp, states, controls = forward_simulations(spmodel,paramSDP, Vs, scenarios)
println("Simulated relative gain of sddp over sdp: "
*string(round(200*mean(costsdp-costsddp)/abs(mean(costsddp+costsdp)),3))*"%")
end
Expand Down
26 changes: 13 additions & 13 deletions examples/stock-example.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,26 @@ test_simulation = true # false if you don't want to test your strategies

######## Optimization parameters ########
# choose the LP solver used.
const SOLVER = ClpSolver() # require "using Clp"
SOLVER = ClpSolver() # require "using Clp"
#const SOLVER = CplexSolver(CPX_PARAM_SIMDISPLAY=0) # require "using CPLEX"

# convergence test
const MAX_ITER = 10 # number of iterations of SDDP
const step = 0.1 # discretization step of SDP
MAX_ITER = 10 # number of iterations of SDDP
step = 0.01 # discretization step of SDP

######## Stochastic Model Parameters ########
const N_STAGES = 6 # number of stages of the SP problem
const COSTS = [sin(3*t)-1 for t in 1:N_STAGES]
N_STAGES = 6 # number of stages of the SP problem
COSTS = [sin(3*t)-1 for t in 1:N_STAGES-1]
#const COSTS = rand(N_STAGES) # randomly generating deterministic costs

const CONTROL_MAX = 0.5 # bounds on the control
const CONTROL_MIN = 0
CONTROL_MAX = 0.5 # bounds on the control
CONTROL_MIN = 0

const XI_MAX = 0.3 # bounds on the noise
const XI_MIN = 0
const N_XI = 10 # discretization of the noise
XI_MAX = 0.3 # bounds on the noise
XI_MIN = 0
N_XI = 10 # discretization of the noise

const S0 = 0.5 # initial stock
S0 = 0.5 # initial stock

# create law of noises
proba = 1/N_XI*ones(N_XI) # uniform probabilities
Expand Down Expand Up @@ -87,7 +87,7 @@ if run_sdp
controlSteps = [step] # discretization step of the control
infoStruct = "HD" # noise at time t is known before taking the decision at time t
paramSDP = SDPparameters(spmodel, stateSteps, controlSteps, infoStruct)
Vs = solve_DP(spmodel,paramSDP, 1)
Vs = solve_dp(spmodel,paramSDP, 1)
value_sdp = StochDynamicProgramming.get_bellman_value(spmodel,paramSDP,Vs)
println("Value obtained by SDP: "*string(round(value_sdp,4)))
toc(); println();
Expand All @@ -110,7 +110,7 @@ end
if run_sddp && run_sdp && test_simulation
scenarios = StochDynamicProgramming.simulate_scenarios(xi_laws,1000)
costsddp, stocks = forward_simulations(spmodel, paramSDDP, pbs, scenarios)
costsdp, states, controls = sdp_forward_simulation(spmodel,paramSDP,scenarios,Vs)
costsdp, states, controls = forward_simulations(spmodel,paramSDP, Vs, scenarios)
println("Simulated relative gain of sddp over sdp: "
*string(round(200*mean(costsdp-costsddp)/abs(mean(costsddp+costsdp)),3))*"%")
end
2 changes: 1 addition & 1 deletion src/SDDPoptimize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ function solve!(sddp::SDDPInterface)
stopping_test::Bool = false

# Launch execution of forward and backward passes:
while !stop(sddp.stopcrit, stats)
while !stop(sddp.stopcrit, stats, stats)
# Time execution of current pass:
tic()

Expand Down
Loading