Skip to content

Commit d1c8191

Browse files
committed
Merge branch 'dev-release-v0.1.2' into update-jump-interface
Conflicts: REQUIRE src/extensiveFormulation.jl
2 parents 575bab1 + db45e60 commit d1c8191

File tree

10 files changed

+25
-17
lines changed

10 files changed

+25
-17
lines changed

REQUIRE

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
julia 0.4
2-
Clp
3-
Distributions
42
JuMP 0.13
5-
FactCheck
3+
Distributions
64
ProgressMeter
75
Interpolations
86
Iterators

doc/conf.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import sys
1616
import os
1717
import sphinx_rtd_theme
18-
import juliadoc
1918

2019
# If extensions (or modules to document with autodoc) are in another directory,
2120
# add these directories to sys.path here. If the directory is relative to the
@@ -32,7 +31,7 @@
3231
# ones.
3332
extensions = [
3433
'sphinx.ext.coverage',
35-
'sphinx.ext.mathjax', 'juliadoc.julia', 'juliadoc.jlhelp'
34+
'sphinx.ext.mathjax',
3635
]
3736

3837
# Add any paths that contain templates here, relative to this directory.

examples/benchmark.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#############################################################################
1717

1818
srand(2713)
19-
push!(LOAD_PATH, "../src")
2019

2120
using StochDynamicProgramming, JuMP
2221
using Clp

examples/dam.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
# Source: Adrien Cassegrain
88
#############################################################################
99

10-
push!(LOAD_PATH, "../src")
11-
1210

1311
using StochDynamicProgramming, JuMP, Clp
1412

examples/damsvalley.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#############################################################################
99

1010
srand(2713)
11-
push!(LOAD_PATH, "../src")
1211

1312
using StochDynamicProgramming, JuMP, Clp
1413

examples/dynamic_example.jl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,18 @@
88
#############################################################################
99

1010
#srand(2713)
11-
push!(LOAD_PATH, "../src")
1211

1312
using StochDynamicProgramming, JuMP, Clp
1413

1514
#Constant that the user have to define himself
1615
const SOLVER = ClpSolver()
1716
# const SOLVER = CplexSolver(CPX_PARAM_SIMDISPLAY=0)
1817

19-
const N_STAGES = 5
20-
const N_SCENARIOS = 1
18+
const N_STAGES = 3
19+
const N_SCENARIOS = 2
2120

2221
const DIM_STATES = 1
23-
const DIM_CONTROLS = 1
22+
const DIM_CONTROLS = 2
2423
const DIM_ALEAS = 1
2524

2625

@@ -177,11 +176,12 @@ end
177176
#Solve the problem and try nb_iter times to generate random data in case of infeasibility
178177
unsolve = true
179178
sol = 0
179+
firstControl = zeros(DIM_CONTROLS*N_SCENARIOS)
180180
i = 0
181181
nb_iter = 10
182182

183183
while i<nb_iter
184-
sol, status = extensive_formulation(model,params)
184+
sol, firstControl, status = extensive_formulation(model,params)
185185
if (status == :Optimal)
186186
unsolve = false
187187
break
@@ -204,6 +204,7 @@ if (unsolve)
204204
else
205205
a,b = solve_dams(modelbis,paramsbis)
206206
println("solution =",sol)
207+
println("firstControl =", firstControl)
207208
println("V0 = ", b[1].lambdas[1,:]*X0+b[1].betas[1])
208209
end
209210

examples/stock-example.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
# u_min <= u_t <= u_max
1111
# u_t choosen knowing xi_1 .. xi_t
1212
#############################################################################
13-
push!(LOAD_PATH, "../src")
13+
1414
using StochDynamicProgramming, JuMP, Clp, Distributions
1515
println("library loaded")
1616

src/extensiveFormulation.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,14 @@ function extensive_formulation(model,
9595
solved = (status == :Optimal)
9696

9797
if solved
98+
<<<<<<< HEAD
9899
return getobjectivevalue(mod), status
100+
=======
101+
firstControl = collect(values(getValue(u)))[1:DIM_CONTROL*laws[1].supportSize]
102+
return getObjectiveValue(mod), firstControl, status
103+
>>>>>>> dev-release-v0.1.2
99104
else
100-
return -1., status
105+
error("Extensive formulation not solved to optimality. Change the model")
101106
end
102107

103108
end

test/REQUIRE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
FactCheck

test/runtests.jl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
# run unit-tests
77
#############################################################################
88

9-
push!(LOAD_PATH, "src")
109

1110
using StochDynamicProgramming
1211
using Distributions, Clp, FactCheck, JuMP
@@ -118,6 +117,15 @@ facts("SDDP algorithm: 1D case") do
118117
noise_scenarios = simulate_scenarios(model.noises,params.forwardPassNumber)
119118

120119
sddp_costs = 0
120+
121+
context("Unsolvable extensive formulation") do
122+
model_ef = StochDynamicProgramming.LinearDynamicLinearCostSPmodel(n_stages, u_bounds,
123+
x0, cost, dynamic, laws)
124+
x_bounds_ef = [(-2., -1.)]
125+
set_state_bounds(model_ef, x_bounds_ef)
126+
@fact_throws extensive_formulation(model_ef, params)
127+
end
128+
121129
context("Linear cost") do
122130
# Compute bellman functions with SDDP:
123131
V, pbs = solve_SDDP(model, params, 0)

0 commit comments

Comments
 (0)