Skip to content

Commit 10e630c

Browse files
committed
[FIX] Fix unit-tests
1 parent 10fe948 commit 10e630c

File tree

3 files changed

+17
-37
lines changed

3 files changed

+17
-37
lines changed

src/SDDPoptimize.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ Return:
164164
Float64 (estimation of the upper bound)
165165
166166
"""
167-
function estimate_upper_bound(model::SPmodel, param::SDDPparameters, V::Vector{PolyhedralFunction}, problem::Vector{JuMP.Model}, n_simulation=1000::Int)
167+
function estimate_upper_bound(model::SPModel, param::SDDPparameters, V::Vector{PolyhedralFunction}, problem::Vector{JuMP.Model}, n_simulation=1000::Int)
168168

169169
aleas = simulate_scenarios(model.noises, n_simulation)
170170

@@ -343,7 +343,6 @@ function initialize_value_functions( model::SPModel,
343343
solverProblems,
344344
stockTrajectories,
345345
model.noises,
346-
true,
347346
true)
348347

349348
return V, solverProblems
@@ -432,6 +431,7 @@ Parameters:
432431
433432
Return:
434433
current lower bound of the problem (Float64)
434+
435435
"""
436436
function get_lower_bound(model::SPModel, param::SDDPparameters,
437437
V::Vector{PolyhedralFunction})

src/extensiveFormulation.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function extensive_formulation(model,
2525

2626
T = model.stageNumber-1
2727

28-
mod = Model(solver=params.solver)
28+
mod = Model(solver=param.solver)
2929

3030

3131
#Calculate the number of nodes n at each step on the scenario tree
@@ -68,14 +68,14 @@ function extensive_formulation(model,
6868
#Add bounds constraint on the control
6969
@addConstraint(mod,[u[t,DIM_CONTROL*(m-1)+k] for k = 1:DIM_CONTROL] .>= [model.ulim[k][1] for k = 1:DIM_CONTROL])
7070
@addConstraint(mod,[u[t,DIM_CONTROL*(m-1)+k] for k = 1:DIM_CONTROL] .<= [model.ulim[k][2] for k = 1:DIM_CONTROL])
71-
71+
7272
#Add dynamic constraints
7373
@addConstraint(mod,
7474
[x[t+1,DIM_STATE*(m-1)+k] for k = 1:DIM_STATE] .== model.dynamics(t,
7575
[x[t,DIM_STATE*(n-1)+k] for k = 1:DIM_STATE],
7676
[u[t,DIM_CONTROL*(m-1)+k] for k = 1:DIM_CONTROL],
7777
laws[t].support[xi]))
78-
78+
7979
#Add constraints to define the cost at each node
8080
@addConstraint(mod,
8181
c[t,m] == model.costFunctions(t,

src/noises.jl

Lines changed: 12 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -17,41 +17,21 @@ type NoiseLaw
1717
support::Array{Float64,2}
1818
# Probabilities of points:
1919
proba::Vector{Float64}
20-
end
21-
22-
23-
"""
24-
Instantiate an element of NoiseLaw
25-
26-
27-
Parameters:
28-
- supportSize (Int64)
29-
Number of points in discrete distribution
30-
31-
- support
32-
Position of each point
20+
function NoiseLaw(supportSize, support, proba)
21+
supportSize = convert(Int64,supportSize)
22+
if ndims(support)==1
23+
support = reshape(support,1,length(support))
24+
end
3325

34-
- proba
35-
Probabilities of each point
36-
37-
38-
Return:
39-
- NoiseLaw
26+
if ndims(proba) == 2
27+
proba = vec(proba)
28+
elseif ndims(proba) >= 2
29+
proba = squeeze(proba,1)
30+
end
4031

41-
"""
42-
function NoiseLaw(supportSize, support, proba)
43-
supportSize = convert(Int64,supportSize)
44-
if ndims(support)==1
45-
support = reshape(support,1,length(support))
46-
end
47-
48-
if ndims(proba) == 2
49-
proba = vec(proba)
50-
elseif ndims(proba) >= 2
51-
proba = squeeze(proba,1)
52-
end
32+
return new(supportSize,support,proba)
33+
end
5334

54-
return NoiseLaw(supportSize,support,proba)
5535
end
5636

5737

0 commit comments

Comments
 (0)