Skip to content

Commit d9b339d

Browse files
committed
Merge previous branch
1 parent d988371 commit d9b339d

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

src/SDDPoptimize.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,12 @@ function build_model(model, param, t,verbosity::Int64=0)
370370

371371
# Define objective function (could be linear or piecewise linear)
372372
if isa(model.costFunctions, Function)
373+
try
373374
@objective(m, Min, model.costFunctions(t, x, u, w) + alpha)
375+
catch
376+
@objective(m, Min, model.costFunctions(m, t, x, u, w) + alpha)
377+
end
378+
374379

375380
elseif isa(model.costFunctions, Vector{Function})
376381
@variable(m, cost)

src/noises.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ mutable struct NoiseLaw
2222
function NoiseLaw(dimNoises, supportSize, support, proba)
2323
dimNoises = convert(Int64,dimNoises)
2424
supportSize = convert(Int64,supportSize)
25+
if ndims(support)==1
26+
support = reshape(support,length(support),1)
27+
end
2528

2629
support, proba = reshaping_noise(support, proba)
2730

src/oneStepOneAleaProblem.jl

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,11 @@ function solve_one_step_one_alea(model,
6666

6767
#update objective
6868
if isa(model.costFunctions, Function)
69-
@objective(m, Min, model.costFunctions(t, x, u, xi) + alpha)
70-
69+
try
70+
@objective(m, Min, model.costFunctions(t, x, u, xi) + alpha)
71+
catch
72+
@objective(m, Min, model.costFunctions(m, t, x, u, xi) + alpha)
73+
end
7174
elseif isa(model.costFunctions, Vector{Function})
7275
cost = getindex(m, :cost)
7376
for i in 1:length(model.costFunctions)
@@ -92,7 +95,7 @@ function solve_one_step_one_alea(model,
9295
solved = relaxation ? solve_relaxed!(m, param,verbosity) : solve_mip!(m, param,verbosity)
9396
else
9497
status = (verbosity>3) ? solve(m, suppress_warnings=false) : solve(m, suppress_warnings=false)
95-
solved = (status == :Optimal)
98+
solved = (status == :Optimal) || (status == :Suboptimal)
9699
end
97100

98101
# get time taken by the solver:
@@ -114,6 +117,8 @@ function solve_one_step_one_alea(model,
114117
println(status)
115118
error("Foo")
116119
# If no solution is found, then return nothing
120+
#= println(m) =#
121+
#= error("Fail to solve") =#
117122
result = NLDSSolution()
118123
end
119124

0 commit comments

Comments
 (0)