From 41dd1c16a9d899c67ce23cc3ef9ecc20a91ba550 Mon Sep 17 00:00:00 2001 From: "femtocleaner[bot]" Date: Mon, 16 Jul 2018 19:22:05 +0000 Subject: [PATCH] Fix deprecations --- src/cutpruning.jl | 6 +++--- src/interface.jl | 2 +- src/noises.jl | 2 +- src/objects.jl | 30 +++++++++++++++--------------- src/oneStepOneAleaProblem.jl | 2 +- src/params.jl | 2 +- src/regularization.jl | 2 +- src/stopcrit.jl | 14 +++++++------- 8 files changed, 30 insertions(+), 30 deletions(-) diff --git a/src/cutpruning.jl b/src/cutpruning.jl index 738a52b..06e0132 100644 --- a/src/cutpruning.jl +++ b/src/cutpruning.jl @@ -54,7 +54,7 @@ ncuts(V::PolyhedralFunction) = length(V.betas) ncuts(V::Array{PolyhedralFunction}) = sum([ncuts(v) for v in V]) # Update cut pruner -update!{T}(pruner::CutPruners.DeMatosCutPruner, x::Vector{T}, λ::Vector{T})=addposition!(pruner, x) -update!{T}(pruner::CutPruners.AvgCutPruner, x::Vector{T}, λ::Vector{T})=addusage!(pruner, λ) -update!{T}(pruner::CutPruners.DecayCutPruner, x::Vector{T}, λ::Vector{T})=addusage!(pruner, λ) +update!(pruner::CutPruners.DeMatosCutPruner, x::Vector{T}, λ::Vector{T}) where {T}=addposition!(pruner, x) +update!(pruner::CutPruners.AvgCutPruner, x::Vector{T}, λ::Vector{T}) where {T}=addusage!(pruner, λ) +update!(pruner::CutPruners.DecayCutPruner, x::Vector{T}, λ::Vector{T}) where {T}=addusage!(pruner, λ) diff --git a/src/interface.jl b/src/interface.jl index 04d5901..8262ee6 100644 --- a/src/interface.jl +++ b/src/interface.jl @@ -6,7 +6,7 @@ # SDDP interface ############################################################################# -type SDDPInterface +mutable struct SDDPInterface init::Bool # Stochastic model to solve spmodel::SPModel diff --git a/src/noises.jl b/src/noises.jl index db02714..c486b13 100644 --- a/src/noises.jl +++ b/src/noises.jl @@ -9,7 +9,7 @@ ############################################################################# -type NoiseLaw +mutable struct NoiseLaw # Dimension of noise dimNoises::Int64 # Number of points in distribution: diff --git a/src/objects.jl b/src/objects.jl index 19466ac..e851913 100644 --- a/src/objects.jl +++ b/src/objects.jl @@ -10,13 +10,13 @@ abstract type RiskMeasure end # Define an object to -type Expectation <: RiskMeasure +mutable struct Expectation <: RiskMeasure function Expectation() return new() end end -type AVaR <: RiskMeasure +mutable struct AVaR <: RiskMeasure # If the random variable is a cost and beta = 0.05, # it returns the average of the five worst costs solving the problem # minimize alpha + 1/beta * E[max(X - alpha; 0)] @@ -28,13 +28,13 @@ type AVaR <: RiskMeasure end end -type WorstCase <: RiskMeasure +mutable struct WorstCase <: RiskMeasure function WorstCase() return new() end end -type ConvexCombi <: RiskMeasure +mutable struct ConvexCombi <: RiskMeasure # Define a convex combination between Expectation and AVaR_{beta} # with form lambda*E + (1-lambda)*AVaR # lambda = 1 ==> Expectation @@ -46,7 +46,7 @@ type ConvexCombi <: RiskMeasure end end -type PolyhedralRisk <: RiskMeasure +mutable struct PolyhedralRisk <: RiskMeasure # Define a convex polyhedral set P of probability distributions # by its extreme points p1, ..., pn # In the case of costs X, the problem solved is @@ -61,7 +61,7 @@ end abstract type SPModel end -type PolyhedralFunction +mutable struct PolyhedralFunction #function defined by max_k betas[k] + lambdas[k,:]*x betas::Vector{Float64} lambdas::Array{Float64,2} #lambdas[k,:] is the subgradient @@ -81,7 +81,7 @@ function fetchnewcuts!(V::PolyhedralFunction) return β, λ end -type LinearSPModel <: SPModel +mutable struct LinearSPModel <: SPModel # problem dimension stageNumber::Int64 #number of information step + 1 dimControls::Int64 @@ -139,7 +139,7 @@ type LinearSPModel <: SPModel Vf = PolyhedralFunction(zeros(1), zeros(1, dimStates), 1, UInt64[], 0) end - isbu = isa(control_cat, Vector{Symbol})? control_cat: [:Cont for i in 1:dimControls] + isbu = isa(control_cat, Vector{Symbol}) ? control_cat : [:Cont for i in 1:dimControls] is_smip = (:Int in isbu)||(:Bin in isbu) if (x_bounds == nothing) @@ -195,7 +195,7 @@ function max_bounds(bounds::Array) [(m_bounds[i,1], m_bounds[i,2]) for i in 1:size(bounds)[1]] end -type StochDynProgModel <: SPModel +mutable struct StochDynProgModel <: SPModel # problem dimension stageNumber::Int64 dimControls::Int64 @@ -239,8 +239,8 @@ type StochDynProgModel <: SPModel finalCostFunction, dynamic, constraints, aleas, search_space_builder = Nullable{Function}()) dimState = length(x0) dimControls = size(u_bounds)[1] - u_bounds1 = ndims(u_bounds) == 1? u_bounds : max_bounds(u_bounds) - x_bounds1 = ndims(x_bounds) == 1? x_bounds : max_bounds(x_bounds) + u_bounds1 = ndims(u_bounds) == 1 ? u_bounds : max_bounds(u_bounds) + x_bounds1 = ndims(x_bounds) == 1 ? x_bounds : max_bounds(x_bounds) return new(TF, dimControls, dimState, length(aleas[1].support[:, 1]), @@ -252,7 +252,7 @@ type StochDynProgModel <: SPModel end -type SDPparameters +mutable struct SDPparameters stateSteps controlSteps totalStateSpaceSize @@ -295,7 +295,7 @@ abstract type AbstractSDDPStats end # Define an object to store evolution of solution # along iterations: -type SDDPStat <: AbstractSDDPStats +mutable struct SDDPStat <: AbstractSDDPStats # Number of iterations: niterations::Int # evolution of lower bound: @@ -361,7 +361,7 @@ end abstract type AbstractNLDSSolution end -type NLDSSolution <: AbstractNLDSSolution +mutable struct NLDSSolution <: AbstractNLDSSolution # solver status: status::Bool # cost: @@ -378,7 +378,7 @@ type NLDSSolution <: AbstractNLDSSolution πc::Vector{Float64} end -type DHNLDSSolution <: AbstractNLDSSolution +mutable struct DHNLDSSolution <: AbstractNLDSSolution # solver status: status::Bool # cost: diff --git a/src/oneStepOneAleaProblem.jl b/src/oneStepOneAleaProblem.jl index f695291..384f156 100644 --- a/src/oneStepOneAleaProblem.jl +++ b/src/oneStepOneAleaProblem.jl @@ -89,7 +89,7 @@ function solve_one_step_one_alea(model, end if model.IS_SMIP - solved = relaxation ? solve_relaxed!(m, param,verbosity): solve_mip!(m, param,verbosity) + solved = relaxation ? solve_relaxed!(m, param,verbosity) : solve_mip!(m, param,verbosity) else status = (verbosity>3) ? solve(m, suppress_warnings=false) : solve(m, suppress_warnings=false) solved = (status == :Optimal) diff --git a/src/params.jl b/src/params.jl index a57580c..1daa84e 100644 --- a/src/params.jl +++ b/src/params.jl @@ -6,7 +6,7 @@ # Definition of SDDP parameters ############################################################################# -type SDDPparameters +mutable struct SDDPparameters # Solver used to solve LP SOLVER::MathProgBase.AbstractMathProgSolver # Solver used to solve MILP (default is nothing): diff --git a/src/regularization.jl b/src/regularization.jl index 11e6517..0b1d21a 100644 --- a/src/regularization.jl +++ b/src/regularization.jl @@ -12,7 +12,7 @@ export SDDPRegularization abstract type AbstractRegularization end -type SDDPRegularization <: AbstractRegularization +mutable struct SDDPRegularization <: AbstractRegularization ρ::Float64 alpha::Float64 incumbents diff --git a/src/stopcrit.jl b/src/stopcrit.jl index ec0f994..4dea833 100644 --- a/src/stopcrit.jl +++ b/src/stopcrit.jl @@ -25,7 +25,7 @@ $(TYPEDEF) Stops if `lhs` *or* `rhs` want to stop. """ -type OrStoppingCriterion <: AbstractStoppingCriterion +mutable struct OrStoppingCriterion <: AbstractStoppingCriterion lhs::AbstractStoppingCriterion rhs::AbstractStoppingCriterion end @@ -43,7 +43,7 @@ $(TYPEDEF) Stops if `lhs` *and* `rhs` want to stop. """ -type AndStoppingCriterion <: AbstractStoppingCriterion +mutable struct AndStoppingCriterion <: AbstractStoppingCriterion lhs::AbstractStoppingCriterion rhs::AbstractStoppingCriterion end @@ -61,7 +61,7 @@ $(TYPEDEF) Stops if `iter` ≧ `limit`. """ -type IterLimit <: AbstractStoppingCriterion +mutable struct IterLimit <: AbstractStoppingCriterion limit::Int end @@ -75,7 +75,7 @@ $(TYPEDEF) Stops if there was less than or equal to `limit` cuts added in the iteration. For instance, `CutLimit(0)` stops when there are no cuts added. """ -type CutLimit <: AbstractStoppingCriterion +mutable struct CutLimit <: AbstractStoppingCriterion limit::Int end @@ -90,7 +90,7 @@ $(TYPEDEF) Stops if total time of execution is greater than the time limit specified. For instance, `TimeLimit(100)` stops after 100s. """ -type TimeLimit <: AbstractStoppingCriterion +mutable struct TimeLimit <: AbstractStoppingCriterion timelimit::Float64 end @@ -104,7 +104,7 @@ $(TYPEDEF) Stops if `z_UB - α * σ/√K - tol < z_LB < z_UB + α * σ/√K + tol` and `σ / √K > β * max(1, |z_LB|))` """ -type Pereira <: AbstractStoppingCriterion +mutable struct Pereira <: AbstractStoppingCriterion α::Float64 β::Float64 tol::Float64 @@ -137,7 +137,7 @@ Stops if the lower bound is stabilized total time of execution is greater than the time limit specified. For instance, `TimeLimit(100)` stops after 100s. """ -type LBStabilization <: AbstractStoppingCriterion +mutable struct LBStabilization <: AbstractStoppingCriterion epsilon::Float64 n_back::Int end