Skip to content

Commit

Permalink
Add support for Julia v0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
blegat committed Jun 5, 2017
1 parent df8258c commit 81cabeb
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 15 deletions.
1 change: 1 addition & 0 deletions REQUIRE
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ MathProgBase 0.5
JuMP 0.17
StructJuMP 0.0.1
DocStringExtensions 0.2
Compat 0.17
2 changes: 2 additions & 0 deletions src/StructDualDynProg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ __precompile__()

module StructDualDynProg

using Compat

using DocStringExtensions

using CutPruners
Expand Down
4 changes: 2 additions & 2 deletions src/cutstore.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ type CutStore{S}

storecuts::Symbol

function CutStore(nvars)
new(spzeros(S, 0, nvars), spzeros(S, 0), NLDS{S}[], spzeros(S, 0, nvars), spzeros(S, 0), NLDS{S}[], Vector{Tuple{NLDS{S},Tuple{Symbol,Int64}}}(0), Vector{Bool}(0), :IfNeededElseDelete)
function (::Type{CutStore{S}}){S}(nvars)
new{S}(spzeros(S, 0, nvars), spzeros(S, 0), NLDS{S}[], spzeros(S, 0, nvars), spzeros(S, 0), NLDS{S}[], Vector{Tuple{NLDS{S},Tuple{Symbol,Int64}}}(0), Vector{Bool}(0), :IfNeededElseDelete)
end
end

Expand Down
10 changes: 5 additions & 5 deletions src/interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ function getSDDPNode(allnodes, m::Model, t, num_stages, solver, parent, pruninga
newnode = SDDPNode(NLDS{Float64}(W,h,T,K,C,c,solver,pruningalgo, newcut), parent)
nodes[t] = newnode
push!(allnodes[t], newnode)
struct = getStructure(m)
struc = getStructure(m)
if t < num_stages
num_scen = length(struct.children)
num_scen = length(struc.children)
children = Vector{SDDPNode{Float64}}(num_scen)
probability = Vector{Float64}(num_scen)
for (i, id) in enumerate(keys(struct.children))
children[i] = getSDDPNode(allnodes, struct.children[id], t+1, num_stages, solver, newnode, pruningalgo, cutmode, detectlb, newcut)
probability[i] = struct.probability[id]
for (i, id) in enumerate(keys(struc.children))
children[i] = getSDDPNode(allnodes, struc.children[id], t+1, num_stages, solver, newnode, pruningalgo, cutmode, detectlb, newcut)
probability[i] = struc.probability[id]
end
setchildren!(newnode, children, probability, cutmode)
if detectlb
Expand Down
4 changes: 2 additions & 2 deletions src/nlds.jl
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ type NLDS{S}
FCpruner::AbstractCutPruner
OCpruners::Vector

function NLDS(W::AbstractMatrix{S}, h::AbstractVector{S}, T::AbstractMatrix{S}, K, C, c::AbstractVector{S}, solver, pruningalgo::AbstractCutPruningAlgo, newcut::Symbol=:AddImmediately)
function (::Type{NLDS{S}}){S}(W::AbstractMatrix{S}, h::AbstractVector{S}, T::AbstractMatrix{S}, K, C, c::AbstractVector{S}, solver, pruningalgo::AbstractCutPruningAlgo, newcut::Symbol=:AddImmediately)
nx = size(W, 2)
= 0
= length(h)
Expand All @@ -105,7 +105,7 @@ type NLDS{S}
else
model = MathProgBase.LinearQuadraticModel(solver)
end
nlds = new(W, h, T, K, C, c, S[], nothing, nothing, CutStore{S}[], CutStore{S}[], localFC, localOC, nothing, Float64[], [], nothing, :NoOptimalityCut, nx, nθ, nπ, 1:nπ, 0, Int[], Int[], Vector{Int}[], model, false, false, nothing, newcut, pruningalgo, FCpruner, OCpruners)
nlds = new{S}(W, h, T, K, C, c, S[], nothing, nothing, CutStore{S}[], CutStore{S}[], localFC, localOC, nothing, Float64[], [], nothing, :NoOptimalityCut, nx, nθ, nπ, 1:nπ, 0, Int[], Int[], Vector{Int}[], model, false, false, nothing, newcut, pruningalgo, FCpruner, OCpruners)
addfollower(localFC, (nlds, (:Feasibility, 0)))
addfollower(localOC, (nlds, (:Optimality, 1)))
nlds
Expand Down
4 changes: 2 additions & 2 deletions src/node.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ type SDDPNode{S}
# Optimality cuts
ocuts::CutStore{S}

function SDDPNode(nlds::NLDS{S}, parent)
function (::Type{SDDPNode{S}}){S}(nlds::NLDS{S}, parent)
nvars = size(nlds.W, 2)
root = parent === nothing
nvars_a = root ? 0 : parent.nvars
new(nlds, nvars, parent, SDDPNode[], Float64[], nothing, root, true, Dict{Tuple{Int,Int},Int}(), CutStore{S}(nvars_a), CutStore{S}(nvars_a))
new{S}(nlds, nvars, parent, SDDPNode[], Float64[], nothing, root, true, Dict{Tuple{Int,Int},Int}(), CutStore{S}(nvars_a), CutStore{S}(nvars_a))
end

end
Expand Down
2 changes: 1 addition & 1 deletion src/paths.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export AbstractPathSampler
abstract AbstractPathSampler
@compat abstract type AbstractPathSampler end

function _samplepaths!(_npaths, npaths, pmf, semirandom::Bool, canmodifypmf::Bool)
if semirandom
Expand Down
2 changes: 1 addition & 1 deletion src/sddptree.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export AbstractSDDPTree
abstract AbstractSDDPTree{S}
@compat abstract type AbstractSDDPTree{S} end

type GraphSDDPTree{S} <: AbstractSDDPTree{S}
root::SDDPNode{S}
Expand Down
2 changes: 1 addition & 1 deletion src/stats.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export AbstractSDDPStats

abstract AbstractSDDPStats
@compat abstract type AbstractSDDPStats end

type SDDPStats <: AbstractSDDPStats
# number of calls to solver
Expand Down
2 changes: 1 addition & 1 deletion src/stopcrit.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Base.|, Base.&
export stop, AbstractStoppingCriterion, OrStoppingCriterion, AndStoppingCriterion, IterLimit, Pereira, CutLimit, TimeLimit

abstract AbstractStoppingCriterion
@compat abstract type AbstractStoppingCriterion end

"""
$(SIGNATURES)
Expand Down

0 comments on commit 81cabeb

Please sign in to comment.