Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,15 @@ jobs:
matrix:
version:
- '1.6'
- '1.8'
- 'nightly'
- '1'
os:
- ubuntu-latest
- macOS-latest
- windows-latest
arch:
- x64
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: julia-actions/setup-julia@v1
with:
version: ${{ matrix.version }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
*.jl.mem
docs/build/
docs/site/
Manifest.toml
28 changes: 18 additions & 10 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,33 @@ Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"

[compat]
Clustering = "0.14"
Clustering = "0.14, 0.15"
Compat = "2.2, 3"
Distributions = "0.25.0"
Distributed = "<0.0.1, 1.6"
Distributions = "0.25"
GLPK = "1"
Ipopt = "~1.0, ~1.1, ~1.2"
JuMP = "= 1.2.1"
LinearAlgebra = "<0.0.1, 1.6"
Logging = "<0.0.1, 1.6"
MacroTools = "0.5.3"
MathOptInterface = "= 1.3.0"
MutableArithmetics = "= 1.0.4"
OrderedCollections = "1.2.0"
MathOptInterface = "~1.3"
MutableArithmetics = "1.0.4"
OrderedCollections = "1.2"
Parameters = "0.12"
ProgressMeter = "1.4.1"
Reexport = "1.0.0"
julia = "1"
Printf = "<0.0.1, 1.6"
ProgressMeter = "~1.4.1"
Random = "<0.0.1, 1.6"
Reexport = "1"
SparseArrays = "<0.0.1, 1.6"
Test = "<0.0.1, 1.6"
julia = "1.6"

[extras]
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
GLPK = "60bf3e95-4087-53dc-ae20-288a0d20c6a6"
Ipopt = "b6b21f68-93f8-5de0-b562-5493be1d77c9"
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test", "Logging", "GLPK", "Ipopt", "Distributions"]
test = ["GLPK", "Ipopt", "Logging", "Test"]
6 changes: 2 additions & 4 deletions src/StochasticPrograms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ using Printf
using JuMP
using Compat
using OrderedCollections
using MathOptInterface
import MathOptInterface as MOI
import Distributions: mean, std, quantile, ProbabilityWeights, TDist, Normal
using MacroTools
using MacroTools: @q, postwalk, prewalk
Expand All @@ -47,15 +47,13 @@ const DenseAxisArray = JuMP.Containers.DenseAxisArray
const SparseAxisArray = JuMP.Containers.SparseAxisArray
const VectorizedProductIterator = JuMP.Containers.VectorizedProductIterator

const MOI = MathOptInterface
const MOIU = MOI.Utilities
const MOIB = MOI.Bridges
const VI = MOI.VariableIndex
const CI = MOI.ConstraintIndex
const AcceptableTermination = [MOI.OPTIMAL, MOI.LOCALLY_SOLVED, MOI.ALMOST_OPTIMAL, MOI.ALMOST_LOCALLY_SOLVED]

import MutableArithmetics
const MA = MutableArithmetics
import MutableArithmetics as MA

export
StochasticModel,
Expand Down
4 changes: 1 addition & 3 deletions src/crash.jl
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@ module Crash

using StochasticPrograms
using StochasticPrograms: AbstractCrash, StochasticProgramOptimizer
using MathOptInterface

const MOI = MathOptInterface
import MathOptInterface as MOI

"""
None
Expand Down
2 changes: 1 addition & 1 deletion src/methods/api.jl
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ end

Return the scenario at `scenario_index` of the two-stage `stochasticprogram`
"""
function scenario(stochasticprogram::TwoStageStochasticProgram, scenario_index::Integer) where N
function scenario(stochasticprogram::TwoStageStochasticProgram, scenario_index::Integer)
return scenario(structure(stochasticprogram), 2, scenario_index)
end
"""
Expand Down
3 changes: 1 addition & 2 deletions src/solvers/sampled/SAA/SAA.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,13 @@
@reexport module SAA

using JuMP
using MathOptInterface
import MathOptInterface as MOI
using StochasticPrograms
using ProgressMeter
using Parameters

import StochasticPrograms: AbstractCrash, load_model!, optimizer_name, optimal_instance

const MOI = MathOptInterface
const MOIU = MOI.Utilities

include("solver.jl")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ function flush!(lshaped::AbstractLShaped, aggregation::HybridAggregation)
return added
end

function flush!(cutqueue::CutQueue, aggregation::HybridAggregation, metadata::MetaDataChannel, t::Integer, x::AbstractArray) where T <: AbstractFloat
function flush!(cutqueue::CutQueue, aggregation::HybridAggregation, metadata::MetaDataChannel, t::Integer, x::AbstractArray)
flush!(cutqueue, active(aggregation), metadata, t, x)
if shift(fetch(metadata, t, :gap), aggregation.τ)
activate_final!(aggregation)
Expand Down
3 changes: 1 addition & 2 deletions src/solvers/structured/lshaped/lshaped.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ using Printf
# External libraries
using Parameters
using JuMP
using MathOptInterface
import MathOptInterface as MOI
using StochasticPrograms
using StochasticPrograms: AcceptableTermination
using StochasticPrograms: UnspecifiedInstantiation, StageDecompositionStructure, AbstractScenarioProblems, ScenarioProblems, DistributedScenarioProblems, DecisionChannel
Expand All @@ -47,7 +47,6 @@ using Clustering
import Base: show, put!, wait, isready, take!, fetch, zero, +, length, size
import StochasticPrograms: supports_structure, num_iterations, default_structure, check_loadable, load_structure!, restore_structure!, optimize!, optimizer_name, master_optimizer, subproblem_optimizer, num_subproblems, remove_penalty_variables!, remove_penalty_constraints!, relax_decision_integrality

const MOI = MathOptInterface
const MOIU = MOI.Utilities
const CI = MOI.ConstraintIndex
const CutConstraint = CI{AffineDecisionFunction{Float64}, MOI.GreaterThan{Float64}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ using Printf
# External libraries
using Parameters
using JuMP
using MathOptInterface
import MathOptInterface as MOI
using StochasticPrograms
using StochasticPrograms: AcceptableTermination
using StochasticPrograms: UnspecifiedInstantiation, ScenarioDecompositionStructure, AbstractScenarioProblems, ScenarioProblems, DistributedScenarioProblems
Expand All @@ -45,7 +45,6 @@ using ProgressMeter
import Base: show, put!, wait, isready, take!, fetch
import StochasticPrograms: supports_structure, num_iterations, default_structure, load_structure!, restore_structure!, optimize!, optimizer_name, master_optimizer, subproblem_optimizer, num_subproblems

const MOI = MathOptInterface
const MOIU = MOI.Utilities

export
Expand Down
3 changes: 1 addition & 2 deletions src/solvers/structured/quasigradient/quasigradient.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ using Printf
# External libraries
using Parameters
using JuMP
using MathOptInterface
import MathOptInterface as MOI
using StochasticPrograms
using StochasticPrograms: AcceptableTermination
using StochasticPrograms: UnspecifiedInstantiation, StageDecompositionStructure, AbstractScenarioProblems, ScenarioProblems, DistributedScenarioProblems, DecisionChannel
Expand All @@ -48,7 +48,6 @@ import Base: show, put!, wait, isready, take!, fetch, zero, +, length, size
import StochasticPrograms: supports_structure, num_iterations, default_structure, check_loadable, load_structure!, restore_structure!, optimize!, optimizer_name, master_optimizer, subproblem_optimizer, num_subproblems, remove_penalty_variables!, remove_penalty_constraints!
using ProgressMeter: Progress

const MOI = MathOptInterface
const MOIU = MOI.Utilities
const CI = MOI.ConstraintIndex

Expand Down
12 changes: 6 additions & 6 deletions src/types/decision_objective.jl
Original file line number Diff line number Diff line change
Expand Up @@ -188,15 +188,15 @@ function JuMP.dual_objective_value(stochasticprogram::TwoStageStochasticProgram,
return dual_objective_value(stochasticprogram, 2, scenario_index; result = result)
end
"""
objective_sense(stochasticprogram::StochasticProgram)::MathOptInterface.OptimizationSense
objective_sense(stochasticprogram::StochasticProgram)::MOI.OptimizationSense

Return the objective sense of the `stochasticprogram`.
"""
function JuMP.objective_sense(stochasticprogram::StochasticProgram)
return MOI.get(stochasticprogram, MOI.ObjectiveSense())::MOI.OptimizationSense
end
"""
objective_sense(stochasticprogram::StochasticProgram, stage::Integer)::MathOptInterface.OptimizationSense
objective_sense(stochasticprogram::StochasticProgram, stage::Integer)::MOI.OptimizationSense

Return the objective sense of the `stochasticprogram` stage `stage`.
"""
Expand All @@ -205,7 +205,7 @@ function JuMP.objective_sense(stochasticprogram::StochasticProgram{N}, stage::In
return objective_sense(proxy(stochasticprogram, stage))
end
"""
objective_sense(stochasticprogram::StochasticProgram, stage::Integer, scenario_index::Integer)::MathOptInterface.OptimizationSense
objective_sense(stochasticprogram::StochasticProgram, stage::Integer, scenario_index::Integer)::MOI.OptimizationSense

Return the objective sense in the node at stage `stage` and scenario `scenario_index`.
"""
Expand All @@ -215,7 +215,7 @@ function JuMP.objective_sense(stochasticprogram::StochasticProgram, stage::Integ
return MOI.get(stochasticprogram, attr)::MOI.OptimizationSense
end
"""
set_objective_sense(stochasticprogram::StochasticProgram, sense::MathOptInterface.OptimizationSense)
set_objective_sense(stochasticprogram::StochasticProgram, sense::MOI.OptimizationSense)

Sets the objective sense of the `stochasticprogram` to `sense`.
"""
Expand All @@ -231,7 +231,7 @@ function JuMP.set_objective_sense(stochasticprogram::StochasticProgram, sense::M
return nothing
end
"""
set_objective_sense(stochasticprogram::StochasticProgram, stage::Integer, sense::MathOptInterface.OptimizationSense)
set_objective_sense(stochasticprogram::StochasticProgram, stage::Integer, sense::MOI.OptimizationSense)

Sets the objective sense of the `stochasticprogram` at stage `stage` to `sense`.
"""
Expand All @@ -248,7 +248,7 @@ function JuMP.set_objective_sense(stochasticprogram::StochasticProgram{N}, stage
return nothing
end
"""
set_objective_sense(stochasticprogram::StochasticProgram, stage::Integer, scenario_index::Integer, sense::MathOptInterface.OptimizationSense)
set_objective_sense(stochasticprogram::StochasticProgram, stage::Integer, scenario_index::Integer, sense::MOI.OptimizationSense)

Sets the objective sense of the stochasticprogram node at stage `stage`
and scenario `scenario_index` to the given `sense`.
Expand Down
2 changes: 1 addition & 1 deletion src/types/decisions/bridges/constraints/quadratic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ end

function MOI.set(model::MOI.ModelLike, ::MOI.ConstraintFunction,
bridge::QuadraticDecisionConstraintBridge{T,S},
f::QuadraticDecisionFunction{T}) where {T,S,F}
f::QuadraticDecisionFunction{T}) where {T,S}
# Update bridge functions and function constant
bridge.decision_function = f
# Change the function of the bridged constraints
Expand Down
2 changes: 1 addition & 1 deletion src/types/decisions/expressions/mutable_arithmetics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ function MA.promote_operation(::typeof(*), ::Type{<:_Decision}, ::Type{<:_Decisi
return DQE
end
# _Variable/_Decision--(_Variable/_Decision)AffExpr
function MA.promote_operation(::typeof(*), ::Type{<:_Variable}, ::Type{GenericAffExpr{C, _Decision}}) where {C, D <: _Decision}
function MA.promote_operation(::typeof(*), ::Type{<:_Variable}, ::Type{GenericAffExpr{C, _Decision}}) where {C}
return DecisionQuadExpr{C}
end
function MA.promote_operation(::typeof(*), ::Type{GenericAffExpr{C, D}}, ::Type{<:_Variable}) where {C, D <: _Decision}
Expand Down
8 changes: 4 additions & 4 deletions src/types/decisions/functions/affine.jl
Original file line number Diff line number Diff line change
Expand Up @@ -347,14 +347,14 @@ function Base.getindex(it::MOIU.ScalarFunctionIterator{VectorAffineDecisionFunct
push!(decision_terms, MOI.VectorAffineTerm(i, it.f.decision_part.terms[j].scalar_term))
end
end
return VectorAffineDecisionFunction(MOIU.VAF(variable_terms, it.f.variable_part.constants[output_indices]),
MOIU.VAF(decision_terms, it.f.decision_part.constants[output_indices]))
return VectorAffineDecisionFunction(MOI.VectorAffineFunction(variable_terms, it.f.variable_part.constants[output_indices]),
MOI.VectorAffineFunction(decision_terms, it.f.decision_part.constants[output_indices]))
end


function MOIU.zero_with_output_dimension(::Type{VectorAffineDecisionFunction{T}}, n::Integer) where T
return MOI.VectorAffineDecisionFunction{T}(MOIU.zero_with_output_dimension(MOI.VAF{T}, n),
MOIU.zero_with_output_dimension(MOI.VAF{T}, n))
return MOI.VectorAffineDecisionFunction{T}(MOIU.zero_with_output_dimension(MOI.VectorAffineFunction{T}, n),
MOIU.zero_with_output_dimension(MOI.VectorAffineFunction{T}, n))
end

function MOIU.substitute_variables(variable_map::Function, f::AffineDecisionFunction{T}) where T
Expand Down
4 changes: 2 additions & 2 deletions src/types/decisions/functions/operators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -858,8 +858,8 @@ function MOIU.operate(::typeof(vcat), ::Type{T},
out_dim = max(variable_out_dim, decision_out_dim)
append!(variable_constants, zeros(T, out_dim - length(variable_constants)))
append!(decision_constants, zeros(T, out_dim - length(decision_constants)))
return VectorAffineDecisionFunction{T}(MOIU.VAF(variable_terms, variable_constants),
MOIU.VAF(decision_terms, decision_constants))
return VectorAffineDecisionFunction{T}(MOI.VectorAffineFunction(variable_terms, variable_constants),
MOI.VectorAffineFunction(decision_terms, decision_constants))
end

# First or second argument must be decision like to avoid type piracy
Expand Down
12 changes: 6 additions & 6 deletions src/types/decomposition/scenarioproblems.jl
Original file line number Diff line number Diff line change
Expand Up @@ -391,15 +391,15 @@ function scenario_decision_dispatch(decision_function::Function,
scenarioproblems::ScenarioProblems,
index::MOI.VariableIndex,
scenario_index::Integer,
args...) where N
args...)
dref = DecisionRef(subproblem(scenarioproblems, scenario_index), index)
return decision_function(dref, args...)
end
function scenario_decision_dispatch(decision_function::Function,
scenarioproblems::DistributedScenarioProblems,
index::MOI.VariableIndex,
scenario_index::Integer,
args...) where N
args...)
return get_from_scenarioproblem(scenarioproblems, scenario_index, decision_function, index, args...) do sp, i, decision_function, index, args...
subprob = fetch(sp).problems[i]
dref = DecisionRef(subprob, index)
Expand All @@ -410,7 +410,7 @@ function scenario_decision_dispatch!(decision_function!::Function,
scenarioproblems::ScenarioProblems,
index::MOI.VariableIndex,
scenario_index::Integer,
args...) where N
args...)
dref = DecisionRef(subproblem(scenarioproblems, scenario_index), index)
decision_function!(dref, args...)
return nothing
Expand All @@ -419,7 +419,7 @@ function scenario_decision_dispatch!(decision_function!::Function,
scenarioproblems::DistributedScenarioProblems,
index::MOI.VariableIndex,
scenario_index::Integer,
args...) where N
args...)
set_in_scenarioproblem!(scenarioproblems, scenario_index, decision_function!, index, args...) do sp, i, decision_function!, index, args...
subprob = fetch(sp).problems[i]
dref = DecisionRef(subprob, index)
Expand Down Expand Up @@ -558,11 +558,11 @@ end

# Getters #
# ========================== #
function decision(scenarioproblems::ScenarioProblems, index::MOI.VariableIndex, scenario_index::Integer) where N
function decision(scenarioproblems::ScenarioProblems, index::MOI.VariableIndex, scenario_index::Integer)
subprob = subproblem(scenarioproblems, scenario_index)
return decision(DecisionRef(subprob, index))
end
function decision(scenarioproblems::DistributedScenarioProblems, index::MOI.VariableIndex, scenario_index::Integer) where N
function decision(scenarioproblems::DistributedScenarioProblems, index::MOI.VariableIndex, scenario_index::Integer)
return get_from_scenarioproblem(scenarioproblems, scenario_index, index) do sp, i, index
subprob = fetch(sp).problems[i]
return decision(DecisionRef(subprob, index))
Expand Down
6 changes: 2 additions & 4 deletions test/decisions/decision_expressions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@

using StochasticPrograms
using Test
using MathOptInterface
const MOI = MathOptInterface
const MOIU = MOI.Utilities
const MA = MOI.MutableArithmetics
import MathOptInterface as MOI
import MutableArithmetics as MA

function DecisionModel()
m = Model()
Expand Down
5 changes: 2 additions & 3 deletions test/decisions/decision_functions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@

using StochasticPrograms
using Test
using MathOptInterface
const MOI = MathOptInterface
import MathOptInterface as MOI
const MOIU = MOI.Utilities
const MA = MOI.MutableArithmetics
import MutableArithmetics as MA

function test_vectorization(x, fx, y, fy, z, fz, w, fw)
g = VectorAffineDecisionFunction(
Expand Down
6 changes: 2 additions & 4 deletions test/decisions/decision_operators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@
using StochasticPrograms
using Test
using LinearAlgebra
using MathOptInterface
const MOI = MathOptInterface
const MOIU = MOI.Utilities
const MA = MOI.MutableArithmetics
import MathOptInterface as MOI
import MutableArithmetics as MA

function DecisionModel()
m = Model()
Expand Down