Skip to content

Commit 5c56bae

Browse files
committed
Merge pull request #85 from leclere/dev-release-v0.1.2
Dev release v0.1.2
2 parents 77d7b06 + b9aa095 commit 5c56bae

15 files changed

+185
-134
lines changed

NEWS.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# StochDynamicProgramming.jl release notes
2+
3+
## Version v0.1.2
4+
5+
* Update to JuMP 0.13
6+
* Add a proper way to define final cost with JuMP
7+
* return control in extensive formulation
8+
9+
## Version v0.1.1
10+
11+
* Add cuts pruning
12+
* Update documentation
13+
* Improve coverage of unit-tests
14+

REQUIRE

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
julia 0.4
2-
MathProgBase
3-
Clp
2+
JuMP 0.13
43
Distributions
5-
JuMP
6-
FactCheck
74
ProgressMeter
85
Interpolations
96
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: 10 additions & 11 deletions
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
@@ -51,23 +50,23 @@ function solve_anticipative_problem(model, scenario)
5150
m = Model(solver=SOLVER)
5251

5352

54-
@defVar(m, model.xlim[1][1] <= x1[1:(N_STAGES)] <= model.xlim[1][2])
55-
@defVar(m, model.xlim[2][1] <= x2[1:(N_STAGES)] <= model.xlim[2][2])
56-
@defVar(m, model.ulim[1][1] <= u1[1:N_STAGES-1] <= model.ulim[1][2])
57-
@defVar(m, model.ulim[2][1] <= u2[1:N_STAGES-1] <= model.ulim[2][2])
53+
@variable(m, model.xlim[1][1] <= x1[1:(N_STAGES)] <= model.xlim[1][2])
54+
@variable(m, model.xlim[2][1] <= x2[1:(N_STAGES)] <= model.xlim[2][2])
55+
@variable(m, model.ulim[1][1] <= u1[1:N_STAGES-1] <= model.ulim[1][2])
56+
@variable(m, model.ulim[2][1] <= u2[1:N_STAGES-1] <= model.ulim[2][2])
5857

59-
@setObjective(m, Min, sum{COST[i]*(u1[i] + u2[i]), i = 1:N_STAGES-1})
58+
@objective(m, Min, sum{COST[i]*(u1[i] + u2[i]), i = 1:N_STAGES-1})
6059

6160
for i in 1:N_STAGES-1
62-
@addConstraint(m, x1[i+1] - x1[i] + u1[i] - scenario[i] == 0)
63-
@addConstraint(m, x2[i+1] - x2[i] + u2[i] - u1[i] == 0)
61+
@constraint(m, x1[i+1] - x1[i] + u1[i] - scenario[i] == 0)
62+
@constraint(m, x2[i+1] - x2[i] + u2[i] - u1[i] == 0)
6463
end
6564

66-
@addConstraint(m, x1[1] == model.initialState[1])
67-
@addConstraint(m, x2[1] == model.initialState[2])
65+
@constraint(m, x1[1] == model.initialState[1])
66+
@constraint(m, x2[1] == model.initialState[2])
6867

6968
status = solve(m)
70-
return getObjectiveValue(m)
69+
return getobjectivevalue(m)
7170
end
7271

7372

examples/dam.jl

Lines changed: 6 additions & 8 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

@@ -65,17 +63,17 @@ function solve_determinist_problem()
6563
println(alea_year)
6664
m = Model(solver=SOLVER)
6765

68-
@defVar(m, 0 <= x[1:N_STAGES] <= 100)
69-
@defVar(m, 0. <= u[1:N_STAGES-1] <= 7)
70-
@defVar(m, 0. <= s[1:N_STAGES-1] <= 7)
66+
@variable(m, 0 <= x[1:N_STAGES] <= 100)
67+
@variable(m, 0. <= u[1:N_STAGES-1] <= 7)
68+
@variable(m, 0. <= s[1:N_STAGES-1] <= 7)
7169

72-
@setObjective(m, Min, sum{COST[i]*u[i], i = 1:N_STAGES-1})
70+
@objective(m, Min, sum{COST[i]*u[i], i = 1:N_STAGES-1})
7371

7472
for i in 1:(N_STAGES-1)
75-
@addConstraint(m, x[i+1] - x[i] + u[i] + s[i] - alea_year[i] == 0)
73+
@constraint(m, x[i+1] - x[i] + u[i] + s[i] - alea_year[i] == 0)
7674
end
7775

78-
@addConstraint(m, x[1] .==X0)
76+
@constraint(m, x[1] .==X0)
7977

8078
status = solve(m)
8179
println(status)

examples/damsvalley.jl

Lines changed: 9 additions & 10 deletions
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

@@ -65,20 +64,20 @@ function solve_determinist_problem()
6564
m = Model(solver=SOLVER)
6665

6766

68-
@defVar(m, VOLUME_MIN <= x1[1:N_STAGES] <= VOLUME_MAX)
69-
@defVar(m, VOLUME_MIN <= x2[1:N_STAGES] <= VOLUME_MAX)
70-
@defVar(m, CONTROL_MIN <= u1[1:N_STAGES-1] <= CONTROL_MAX)
71-
@defVar(m, CONTROL_MIN <= u2[1:N_STAGES-1] <= CONTROL_MAX)
67+
@variable(m, VOLUME_MIN <= x1[1:N_STAGES] <= VOLUME_MAX)
68+
@variable(m, VOLUME_MIN <= x2[1:N_STAGES] <= VOLUME_MAX)
69+
@variable(m, CONTROL_MIN <= u1[1:N_STAGES-1] <= CONTROL_MAX)
70+
@variable(m, CONTROL_MIN <= u2[1:N_STAGES-1] <= CONTROL_MAX)
7271

73-
@setObjective(m, Min, sum{COST[i]*(u1[i] + u2[i]), i = 1:N_STAGES})
72+
@objective(m, Min, sum{COST[i]*(u1[i] + u2[i]), i = 1:N_STAGES})
7473

7574
for i in 1:N_STAGES-1
76-
@addConstraint(m, x1[i+1] - x1[i] + u1[i] - alea_year[i] == 0)
77-
@addConstraint(m, x2[i+1] - x2[i] + u2[i] - u1[i] == 0)
75+
@constraint(m, x1[i+1] - x1[i] + u1[i] - alea_year[i] == 0)
76+
@constraint(m, x2[i+1] - x2[i] + u2[i] - u1[i] == 0)
7877
end
7978

80-
@addConstraint(m, x1[1] == X0[1])
81-
@addConstraint(m, x2[1] == X0[2])
79+
@constraint(m, x1[1] == X0[1])
80+
@constraint(m, x2[1] == X0[2])
8281

8382
status = solve(m)
8483
println(status)

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

0 commit comments

Comments
 (0)