Public interface
Documentation for StochasticPrograms.jl's public interface.
Contents
Index
StochasticPrograms.AbstractSamplerStochasticPrograms.AbstractScenarioStochasticPrograms.AbstractStochasticStructureStochasticPrograms.DecisionRefStochasticPrograms.DecisionVariableStochasticPrograms.DeterministicStochasticPrograms.DeterministicEquivalentStochasticPrograms.DistributedHorizontalStochasticPrograms.DistributedVerticalStochasticPrograms.ExpectedScenarioStochasticPrograms.HorizontalStochasticPrograms.HorizontalStructureStochasticPrograms.KnownRefStochasticPrograms.ProbabilityStochasticPrograms.SMPS.SMPSSamplerStochasticPrograms.SMPS.SMPSScenarioStochasticPrograms.SPConstraintRefStochasticPrograms.SamplerStochasticPrograms.ScenarioStochasticPrograms.StochasticInstantiationStochasticPrograms.StochasticProgramStochasticPrograms.StochasticProgramStochasticPrograms.StochasticProgramStochasticPrograms.StochasticProgramStochasticPrograms.StochasticProgramStochasticPrograms.UnloadableStructureStochasticPrograms.UnloadedStructureStochasticPrograms.UnspecifiedInstantiationStochasticPrograms.UnsupportedStructureStochasticPrograms.VerticalStochasticPrograms.VerticalStructureStochasticPrograms.@decisionStochasticPrograms.@define_scenarioStochasticPrograms.@expectationStochasticPrograms.@first_stageStochasticPrograms.@knownStochasticPrograms.@parametersStochasticPrograms.@recourseStochasticPrograms.@sampleStochasticPrograms.@samplerStochasticPrograms.@scenarioStochasticPrograms.@second_stageStochasticPrograms.@stageStochasticPrograms.@stochastic_modelStochasticPrograms.@uncertainStochasticPrograms.@zeroBase.getindexBase.readBase.readBase.readJuMP.BinaryRefJuMP.FixRefJuMP.IntegerRefJuMP.LowerBoundRefJuMP.UpperBoundRefJuMP.all_constraintsJuMP.constraint_by_nameJuMP.constraint_objectJuMP.constraint_objectJuMP.deleteJuMP.deleteJuMP.deleteJuMP.deleteJuMP.deleteJuMP.deleteJuMP.deleteJuMP.deleteJuMP.delete_lower_boundJuMP.delete_lower_boundJuMP.delete_upper_boundJuMP.delete_upper_boundJuMP.dualJuMP.dualJuMP.dual_objective_valueJuMP.dual_objective_valueJuMP.dual_objective_valueJuMP.dual_statusJuMP.dual_statusJuMP.dual_statusJuMP.fixJuMP.fixJuMP.fixJuMP.fixJuMP.has_dualsJuMP.has_dualsJuMP.has_dualsJuMP.has_lower_boundJuMP.has_lower_boundJuMP.has_upper_boundJuMP.has_upper_boundJuMP.has_valuesJuMP.has_valuesJuMP.indexJuMP.indexJuMP.is_binaryJuMP.is_binaryJuMP.is_fixedJuMP.is_fixedJuMP.is_integerJuMP.is_integerJuMP.is_validJuMP.is_validJuMP.is_validJuMP.is_validJuMP.list_of_constraint_typesJuMP.lower_boundJuMP.lower_boundJuMP.nameJuMP.nameJuMP.nameJuMP.nameJuMP.normalized_coefficientJuMP.normalized_coefficientJuMP.normalized_rhsJuMP.normalized_rhsJuMP.num_constraintsJuMP.num_variablesJuMP.objective_boundJuMP.objective_boundJuMP.objective_functionJuMP.objective_functionJuMP.objective_functionJuMP.objective_function_typeJuMP.objective_function_typeJuMP.objective_function_typeJuMP.objective_senseJuMP.objective_senseJuMP.objective_senseJuMP.objective_valueJuMP.objective_valueJuMP.objective_valueJuMP.objective_valueJuMP.optimize!JuMP.optimize!JuMP.optimizer_indexJuMP.optimizer_indexJuMP.optimizer_indexJuMP.optimizer_indexJuMP.primal_statusJuMP.primal_statusJuMP.primal_statusJuMP.raw_statusJuMP.raw_statusJuMP.raw_statusJuMP.reduced_costJuMP.reduced_costJuMP.relative_gapJuMP.relative_gapJuMP.set_binaryJuMP.set_binaryJuMP.set_integerJuMP.set_integerJuMP.set_lower_boundJuMP.set_lower_boundJuMP.set_nameJuMP.set_nameJuMP.set_nameJuMP.set_nameJuMP.set_normalized_coefficientJuMP.set_normalized_coefficientJuMP.set_normalized_rhsJuMP.set_normalized_rhsJuMP.set_objective_coefficientJuMP.set_objective_coefficientJuMP.set_objective_senseJuMP.set_objective_senseJuMP.set_objective_senseJuMP.set_optimizerJuMP.set_optimizerJuMP.set_optimizer_attributeJuMP.set_optimizer_attributeJuMP.set_optimizer_attributesJuMP.set_start_valueJuMP.set_start_valueJuMP.set_upper_boundJuMP.set_upper_boundJuMP.solve_timeJuMP.solve_timeJuMP.solve_timeJuMP.start_valueJuMP.start_valueJuMP.termination_statusJuMP.termination_statusJuMP.termination_statusJuMP.unfixJuMP.unfixJuMP.unset_binaryJuMP.unset_binaryJuMP.unset_integerJuMP.unset_integerJuMP.upper_boundJuMP.upper_boundJuMP.valueJuMP.valueJuMP.valueJuMP.valueJuMP.valueJuMP.valueJuMP.valueStochasticPrograms.DEPStochasticPrograms.EEVStochasticPrograms.EEVStochasticPrograms.EVStochasticPrograms.EVPStochasticPrograms.EVPIStochasticPrograms.EVPIStochasticPrograms.EWSStochasticPrograms.EWSStochasticPrograms.StochasticStructureStochasticPrograms.VRPStochasticPrograms.VRPStochasticPrograms.VSSStochasticPrograms.VSSStochasticPrograms.WSStochasticPrograms.add_scenario!StochasticPrograms.add_scenario!StochasticPrograms.add_scenario!StochasticPrograms.add_scenario!StochasticPrograms.add_scenarios!StochasticPrograms.add_scenarios!StochasticPrograms.add_scenarios!StochasticPrograms.add_scenarios!StochasticPrograms.add_worker_scenario!StochasticPrograms.add_worker_scenario!StochasticPrograms.add_worker_scenario!StochasticPrograms.add_worker_scenario!StochasticPrograms.add_worker_scenarios!StochasticPrograms.add_worker_scenarios!StochasticPrograms.add_worker_scenarios!StochasticPrograms.add_worker_scenarios!StochasticPrograms.all_decision_variablesStochasticPrograms.all_decision_variablesStochasticPrograms.all_decision_variablesStochasticPrograms.all_decision_variablesStochasticPrograms.all_known_decision_variablesStochasticPrograms.all_known_decision_variablesStochasticPrograms.clear!StochasticPrograms.confidence_intervalStochasticPrograms.decisionStochasticPrograms.decisionStochasticPrograms.decisionStochasticPrograms.decisionStochasticPrograms.decisionStochasticPrograms.decision_by_nameStochasticPrograms.default_structureStochasticPrograms.deferredStochasticPrograms.distributedStochasticPrograms.evaluate_decisionStochasticPrograms.evaluate_decisionStochasticPrograms.evaluate_decisionStochasticPrograms.expectedStochasticPrograms.expectedStochasticPrograms.expected_value_decisionStochasticPrograms.first_stageStochasticPrograms.gapStochasticPrograms.generate!StochasticPrograms.generatorStochasticPrograms.get_optimizer_attributeStochasticPrograms.get_optimizer_attributeStochasticPrograms.has_generatorStochasticPrograms.has_valuesStochasticPrograms.instantiateStochasticPrograms.instantiateStochasticPrograms.instantiateStochasticPrograms.instantiateStochasticPrograms.lower_confidence_intervalStochasticPrograms.master_optimizerStochasticPrograms.num_decisionsStochasticPrograms.num_decisionsStochasticPrograms.num_known_decisionsStochasticPrograms.num_scenariosStochasticPrograms.num_stagesStochasticPrograms.num_subproblemsStochasticPrograms.optimal_decisionStochasticPrograms.optimal_decisionStochasticPrograms.optimal_decisionStochasticPrograms.optimal_decisionStochasticPrograms.optimal_recourse_decisionStochasticPrograms.optimizerStochasticPrograms.optimizerStochasticPrograms.optimizer_constructorStochasticPrograms.optimizer_constructorStochasticPrograms.optimizer_nameStochasticPrograms.optimizer_nameStochasticPrograms.outcome_modelStochasticPrograms.outcome_modelStochasticPrograms.probabilityStochasticPrograms.probabilityStochasticPrograms.probabilityStochasticPrograms.probabilityStochasticPrograms.proxyStochasticPrograms.recourse_decisionStochasticPrograms.sampleStochasticPrograms.sample!StochasticPrograms.sample!StochasticPrograms.scenarioStochasticPrograms.scenarioStochasticPrograms.scenario_typeStochasticPrograms.scenario_typesStochasticPrograms.scenariosStochasticPrograms.scenariotextStochasticPrograms.set_probability!StochasticPrograms.shadow_priceStochasticPrograms.shadow_priceStochasticPrograms.stageStochasticPrograms.stageStochasticPrograms.stage_modelStochasticPrograms.stage_one_modelStochasticPrograms.stage_parametersStochasticPrograms.stage_probabilityStochasticPrograms.stateStochasticPrograms.stateStochasticPrograms.stateStochasticPrograms.statistically_evaluate_decisionStochasticPrograms.structureStochasticPrograms.structure_nameStochasticPrograms.subproblemStochasticPrograms.subproblemStochasticPrograms.subproblem_optimizerStochasticPrograms.subproblemsStochasticPrograms.update_decisions!StochasticPrograms.update_decisions!StochasticPrograms.update_decisions!StochasticPrograms.upper_confidence_intervalStochasticPrograms.upper_confidence_intervalStochasticPrograms.wait_and_see_decision
Constructors
StochasticPrograms.StochasticProgram — TypeStochasticProgram(scenarios::Vector{<:AbstractScenario},
instantiation::StochasticInstantiation,
optimizer_constructor = nothing)Create a new two-stage stochastic program with a given collection of scenarios and no stage data. Optionally, a capable optimizer_constructor can be supplied to later optimize the stochastic program. If multiple Julia processes are available, the resulting stochastic program will automatically be memory-distributed on these processes. This can be avoided by setting procs = [1].
StochasticPrograms.StochasticProgram — TypeStochasticProgram(first_stage_params::Any,
second_stage_params::Any,
instantiation::StochasticInstantiation,
optimizer_constructor=nothing) where T <: AbstractFloatCreate a new two-stage stochastic program with stage data given by first_stage_params and second_stage_params. After construction, scenarios of type Scenario can be added through add_scenario!. Optionally, a capable optimizer_constructor can be supplied to later optimize the stochastic program. If multiple Julia processes are available, the resulting stochastic program will automatically be memory-distributed on these processes. This can be avoided by setting procs = [1].
StochasticPrograms.StochasticProgram — TypeStochasticProgram(first_stage_params::Any,
second_stage_params::Any,
scenarios::Vector{<:AbstractScenario},
instantiation::StochasticInstantiation,
optimizer_constructor = nothing)Create a new two-stage stochastic program with a given collection of scenarios. Optionally, a capable optimizer_constructor can be supplied to later optimize the stochastic program. If multiple Julia processes are available, the resulting stochastic program will automatically be memory-distributed on these processes. This can be avoided by setting procs = [1].
StochasticPrograms.StochasticProgram — MethodStochasticProgram(first_stage_params::Any,
second_stage_params::Any,
::Type{Scenario},
instantiation::StochasticInstantiation,
optimizer_constructor=nothing) where Scenario <: AbstractScenarioCreate a new two-stage stochastic program with stage data given by first_stage_params and second_stage_params. After construction, scenarios of type S can be added through add_scenario!. Optionally, a capable optimizer_constructor can be supplied to later optimize the stochastic program. If multiple Julia processes are available, the resulting stochastic program will automatically be memory-distributed on these processes. This can be avoided by setting procs = [1].
StochasticPrograms.StochasticProgram — MethodStochasticProgram(::Type{Scenario},
instantiation::StochasticInstantiation,
optimizer_constructor=nothing) where Scenario <: AbstractScenarioCreate a new two-stage stochastic program with scenarios of type Scenario and no stage data. Optionally, a capable optimizer_constructor can be supplied to later optimize the stochastic program.
IO
Base.read — Methodread(io::IO,
::Type{SMPSSampler})Return an SMPSSampler capable of sampling SMPSScenario using the model definition read from io in SMPS format.
Base.read — Methodread(io::IO,
::Type{SMPSSampler})Return an StochasticModel from the model definition read from io in SMPS format.
Base.read — Methodread(io::IO,
::Type{StochasticProgram};
num_scenarios::Union{Nothing, Integer} = nothing,
instantiation::StochasticInstantiation = UnspecifiedInstantiation(),
optimizer = nothing;
defer::Bool = false,
kw...)Instantiate a two-stage stochastic program using the model definition read from io in SMPS format, of size num_scenarios. If num_scenarios = nothing, instantiate using the full support. Optionally, supply an optimizer. If no explicit instantiation is provided, the structure is induced by the optimizer. The structure is Deterministic by default.
Structures
StochasticPrograms.AbstractStochasticStructure — TypeAbstractStochasticStructure{N}Abstract supertype for the underlying memory structure of a stochastic program. N is the number of stages.
StochasticPrograms.Deterministic — TypeDeterministicInstantiates with the DeterministicEquivalent structure.
See also: DeterministicEquivalent
StochasticPrograms.DistributedHorizontal — TypeDistributedHorizontalInstantiates with the HorizontalStructure on multiple cores.
See also: HorizontalStructure
StochasticPrograms.DistributedVertical — TypeDistributedVerticalInstantiates with the VerticalStructure on multiple cores.
See also: VerticalStructure
StochasticPrograms.Horizontal — TypeStochasticPrograms.StochasticInstantiation — TypeStochasticInstantiationAbstract supertype for the underlying memory structure of a stochastic program. N is the number of stages.
StochasticPrograms.UnloadableStructure — TypeUnloadasbleStructure{Opt <: StochasticProgramOptimizerType, S <: AbstractStochasticStructure}Error thrown when an optimizer of type Opt cannot load a structure of type S.
StochasticPrograms.UnloadedStructure — TypeUnloadedStructure{Opt <: StochasticProgramOptimizerType}Error thrown when an optimizer of type Opt has not yet loaded a stochastic structure and an operation which requires a structure to be loaded is called.
StochasticPrograms.UnspecifiedInstantiation — TypeUnspecifiedInstantiationDefault instantiation value, which defers the choice to default_structure.
See also: default_structure
StochasticPrograms.UnsupportedStructure — TypeUnsupportedStructure{Opt <: StochasticProgramOptimizerType, S <: AbstractStochasticStructure}Error indicating that an optimizer of type Opt does not support the stochastic structure S.
StochasticPrograms.Vertical — TypeStochasticPrograms.StochasticStructure — FunctionStochasticStructure(scenario_types::ScenarioTypes{M}, instantiation::StochasticInstantiation) where MConstructs a stochastic structure over the M provided scenario types according to the specified instantiation. Should be overrided for every defined stochastic structure.
StochasticStructure(scenarios::NTuple{M, Vector{<:AbstractScenario}}, instantiation::StochasticInstantiation) where MConstructs a stochastic structure over the M provided scenario sets according to the specified instantiation. Should be overrided for every defined stochastic structure.
StochasticPrograms.default_structure — Methoddefault_structure(instantiation::StochasticInstantiation, optimizer)Returns a StochasticInstantiation based on the provided instantiation and optimizer. If an explicit instantiation is provided it is always prioritized. Otherwise, if instantiation is UnspecifiedInstantiation, returns whatever structure requested by the optimizer. Defaults to Deterministic if no optimizer is provided.
StochasticPrograms.DeterministicEquivalent — TypeDeterministicEquivalentDeterministic equivalent memory structure. Stochastic program is stored as one large optimization problem. Supported by any standard AbstractOptimizer.
StochasticPrograms.VerticalStructure — TypeVerticalStructureVertical memory structure. Decomposes stochastic program by stages.
StochasticPrograms.HorizontalStructure — TypeHorizontalStructureHorizontal memory structure. Decomposes stochastic program by scenario.
Decisions
StochasticPrograms.DecisionVariable — TypeDecisionVariable <: AbstractVariableRefIdentifier for a decision in a stochastic program. Holds a reference to the stochastic program, the stage the decision is taken in, and its corresponding MOI.VariableIndex.
JuMP.BinaryRef — MethodBinaryRef(dvar::DecisionVariable)Return a constraint reference to the binary constraint of the decision variable dvar. Errors if one does not exist.
JuMP.FixRef — MethodFixRef(dvar::DecisionVariable)Return a constraint reference to the constraint fixing the value of the decision dvar. Errors if one does not exist.
JuMP.IntegerRef — MethodIntegerRef(dvar::DecisionVariable)Return a constraint reference to the integrality constraint of the decision variable dvar. Errors if one does not exist.
JuMP.LowerBoundRef — MethodLowerBoundRef(dvar::DecisionVariable)Return a constraint reference to the lower bound constraint of the decision variable dvar. Errors if one does not exist.
JuMP.UpperBoundRef — MethodLowerBoundRef(dvar::DecisionVariable)Return a constraint reference to the upper bound constraint of the decision variable dvar. Errors if one does not exist.
JuMP.delete — Methoddelete(stochasticprogram::StochasticProgram, dvars::Vector{DecisionVariable}, scenario_index::Integer)Delete the scenario-dependent decisions associated with dvars from the stochasticprogram at scenario_index.
JuMP.delete — Methoddelete(stochasticprogram::StochasticProgram, dvars::Vector{DecisionVariable})Delete the decisions associated with dvars from the stochasticprogram.
JuMP.delete — Methoddelete(stochasticprogram::StochasticProgram, dvar::DecisionVariable, scenario_index::Integer)Delete the scenario-dependent decision variable associated with dvar from the stochasticprogram at scenario_index.
JuMP.delete — Methoddelete(stochasticprogram::StochasticProgram, dvar::DecisionVariable)Delete the first-stage decision variable associated with dvar from the stochasticprogram.
JuMP.delete_lower_bound — Methoddelete_lower_bound(dvar::DecisionVariable, scenario_index::Integer)Delete the lower bound constraint of the scenario-dependent decision variable dvar at scenario_index.
JuMP.delete_lower_bound — Methoddelete_lower_bound(dvar::DecisionVariable)Delete the lower bound constraint of the first-stage decision variable dvar.
JuMP.delete_upper_bound — Methoddelete_upper_bound(dvar::DecisionVariable, scenario_index::Integer)Delete the upper bound constraint of the scenario-dependent decision variable dvar at scenario_index.
JuMP.delete_upper_bound — Methoddelete_upper_bound(dvar::DecisionVariable)Delete the upper bound constraint of the first-stage decision variable dvar.
JuMP.fix — Methodfix(dvar::DecisionVariable, scenario_index::Integer, val::Number)Fix the scenario-dependent decision associated with dvar at scenario_index to val. In contexts where dvar is a variable, the variable is fixed to the value. In contexts where dvar is a known parameter value, the value is updated.
JuMP.fix — Methodfix(dvar::DecisionVariable, val::Number)Fix the first-stage decision associated with dvar to val. In contexts where dvar is a variable, the variable is fixed to the value. In contexts where dvar is a known parameter value, the value is updated.
JuMP.has_lower_bound — Methodhas_lower_bound(dvar::DecisionVariable, scenario_index::Integer)Return true if the scenario-dependent decision variable dvar has a lower bound at scenario_index.
JuMP.has_lower_bound — Methodhas_lower_bound(dvar::DecisionVariable)Return true if the first-stage decision variable dvar has a lower bound.
JuMP.has_upper_bound — Methodhas_upper_bound(dvar::DecisionVariable, scenario_index::Integer)Return true if the scenario-dependent decision variable dvar has a upper bound at scenario_index.
JuMP.has_upper_bound — Methodhas_upper_bound(dvar::DecisionVariable)Return true if the first-stage decision variable dvar has a upper bound.
JuMP.has_values — Methodhas_values(stochasticprogram::StochasticProgram, stage::Integer, scenario_index::Integer; result::Int = 1)Return true if the solver has a primal solution in the node at stage stage and scenario scenario_index in result index result available to query, otherwise return false.
JuMP.has_values — Methodhas_duals(stochasticprogram::StochasticProgram; result::Int = 1)Return true if the solver has a primal solution in the first-stage of stochasticprogram in result index result available to query, otherwise return false.
JuMP.index — Methodindex(dvar::DecisionVariable)::MOI.VariableIndexReturn the index of the decision variable that corresponds to dvar in the MOI backend.
JuMP.is_binary — Methodis_binary(dvar::DecisionVariable, scenario_index::Integer)Return true if the scenario-dependent decision variable dvar is constrained to be binary at scenario_index.
JuMP.is_binary — Methodis_binary(dvar::DecisionVariable)Return true if the first-stage decision variable dvar is constrained to be binary.
JuMP.is_fixed — Methodis_fixed(dvar::DecisionVariable, scenario_index)Return true if dvar is a fixed decision variable in scenario_index.
JuMP.is_fixed — Methodis_fixed(dvar::DecisionVariable)Return true if dvar is a fixed first-stage decision variable.
JuMP.is_integer — Methodis_integer(dvar::DecisionVariable, scenario_index::Integer)Return true if the scenario-dependent decision variable dvar is constrained to be integer at scenario_index.
JuMP.is_integer — Methodis_integer(dvar::DecisionVariable)Return true if the first-stage decision variable dvar is constrained to be integer.
JuMP.is_valid — Methodis_valid(stochasticprogram::StochasticProgram, dvar::DecisionVariable, scenario_index::Integer)Return true if the scenario-dependent dvar refers to a valid decision variable in stochasticprogram at scenario_index.
JuMP.is_valid — Methodis_valid(stochasticprogram::StochasticProgram, dvar::DecisionVariable)Return true if dvar refers to a valid first-stage decision variable in stochasticprogram.
JuMP.lower_bound — Methodlower_bound(dvar::DecisionVariable, scenario_index::Integer)Return the lower bound of the scenario-dependent decision variable dvar at scenario_index. Error if one does not exist.
JuMP.lower_bound — Methodlower_bound(dvar::DecisionVariable)Return the lower bound of the first-stage decision variable dvar. Error if one does not exist.
JuMP.name — Methodname(dvar::DecisionVariable, scenario_index::Integer)::StringGet the name of the scenario-dependent decision variable dvar in scenario scenario_index.
JuMP.name — Methodname(dvar::DecisionVariable, scenario_index::Integer)::StringGet the name of the decision variable dvar.
JuMP.optimizer_index — Methodoptimizer_index(dvar::DecisionVariable, scenario_index)::MOI.VariableIndexReturn the index of the variable that corresponds to the scenario-dependent dvar in the optimizer model at scenario_index.
JuMP.optimizer_index — Methodoptimizer_index(dvar::DecisionVariable)::MOI.VariableIndexReturn the index of the variable that corresponds to dvar in the optimizer model.
JuMP.reduced_cost — Methodreduced_cost(dvar::DecisionVariable)::Float64Return the reduced cost associated with the scenario-dependent decision variable dvar at scenario_index.
JuMP.reduced_cost — Methodreduced_cost(dvar::DecisionVariable)::Float64Return the reduced cost associated with the decision variable dvar.
JuMP.set_binary — Methodset_binary(dvar::DecisionVariable, scenario_index::Integer)Constrain the scenario-dependent decision variable dvar to the set $\{0,1\}$ at scenario_index.
JuMP.set_binary — Methodset_binary(dvar::DecisionVariable)Constrain the first-stage decision variable dvar to the set $\{0,1\}$.
JuMP.set_integer — Methodset_integer(dvar::DecisionVariable, scenario_index::Integer)Add an integrality constraint on the scenario-dependent decision variable dvar at scenario_index.
JuMP.set_integer — Methodset_integer(dvar::DecisionVariable)Add an integrality constraint on the first-stage decision variable dvar.
JuMP.set_lower_bound — Methodset_lower_bound(dvar::DecisionVariable, scenario_index::Integer, lower::Number)Set the lower bound of the scenario-dependent decision variable dvar at scenario_index to lower. If one does not exist, create a new lower bound constraint.
JuMP.set_lower_bound — Methodset_lower_bound(dvar::DecisionVariable)Set the lower bound of the first-stage decision variable dvar to lower. If one does not exist, create a new lower bound constraint.
JuMP.set_name — Methodset_name(dvar::DecisionVariable, scenario_index::Integer, name::String)Set the name of the scenario-dependent decision variable dvar in scenario scenario_index to name.
JuMP.set_name — Methodset_name(dvar::DecisionVariable, scenario_index::Integer, name::String)Set the name of the decision variable dvar to name.
JuMP.set_start_value — Methodset_start_value(dvar::DecisionVariable, scenario_index::Integer, value::Number)Set the start value of the scenario-dependent decision variable dvar at scenario_index to value.
JuMP.set_start_value — Methodset_start_value(dvar::DecisionVariable)Set the start value of the first-stage decision variable dvar to value.
JuMP.set_upper_bound — Methodset_upper_bound(dvar::DecisionVariable, scenario_index::Integer, upper::Number)Set the upper bound of the scenario-dependent decision variable dvar at scenario_index to upper. If one does not exist, create a new upper bound constraint.
JuMP.set_upper_bound — Methodset_upper_bound(dvar::DecisionVariable, upper::Number)Set the upper bound of the first-stage decision variable dvar to upper. If one does not exist, create a new upper bound constraint.
JuMP.start_value — Methodstart_value(dvar::DecisionVariable, scenario_index::Integer)Return the start value of the scenario-dependent decision variable dvar at scenario_index.
JuMP.start_value — Methodstart_value(dvar::DecisionVariable)Return the start value of the first-stage decision variable dvar.
JuMP.unfix — Methodunfix(dvar::DecisionVariable, scenario_index::Integer)Unfix the scenario-dependent decision associated with dvar at scenario_index. If the decision is already in a NotTaken state, this does nothing.
JuMP.unfix — Methodunfix(dvar::DecisionVariable)Unfix the first-stage decision associated with dvar. If the decision is already in a NotTaken state, this does nothing.
JuMP.unset_binary — Methodunset_binary(dvar::DecisionVariable, scenario_index::Integer)Delete the binary constraint of the scenario-dependent decision variable dvar at scenario_index.
JuMP.unset_binary — Methodunset_binary(dvar::DecisionVariable)Delete the binary constraint of the first-stage decision variable dvar.
JuMP.unset_integer — Methodunset_integer(dvar::DecisionVariable, scenario_index::Integer)Delete the integrality constraint of the scenario-dependent decision variable dvar at scenario_index.
JuMP.unset_integer — Methodunset_integer(dvar::DecisionVariable)Delete the integrality constraint of the first-stage decision variable dvar.
JuMP.upper_bound — Methodupper_bound(dvar::DecisionVariable, scenario_index::Integer)Return the upper bound of the scenario-dependent decision variable dvar at scenario_index. Error if one does not exist.
JuMP.upper_bound — Methodupper_bound(dvar::DecisionVariable)Return the upper bound of the first-stage decision variable dvar. Error if one does not exist.
JuMP.value — Methodvalue(dvar::DecisionVariable, scenario_index::Integer; result = 1)Return the scenario-dependent value of the decision variable dvar associated with result index result at scenario_index of the most-recent returned by the solver.
JuMP.value — Methodvalue(dvar::DecisionVariable; result = 1)Return the value of the first-stage decision variable dvar associated with result index result of the most-recent returned by the solver.
JuMP.value — Methodvalue(dvar_expr::Union{GenericAffExpr{T,DecisionVariable}, GenericQuadExpr{T,DecisionVariable}}, stage_to_scenario::Dict{Int,Int}) where TEvaluate dvar_expr where the value of a given dvar is found in the scenario returned by the provided stage_to_scenario map.
StochasticPrograms.decision — Methoddecision(dvar::DecisionVariable, scenario_index::Integer)Return the scenario-dependent internal Decision associated with dvar at scenario_index.
StochasticPrograms.decision — Methoddecision(dvar::DecisionVariable)Return the internal Decision associated with the first-stage dvar.
StochasticPrograms.decision_by_name — Methoddecision_by_name(stochasticprogram::Stochasticprogram,
stage::Integer,
name::String)::Union{AbstractVariableRef, Nothing}Returns the reference of the variable with name attribute name at stage of stochasticprogram or Nothing if no variable has this name attribute. Throws an error if several variables have name as their name attribute at stage s.
StochasticPrograms.has_values — Methodhas_values(stochasticprogram::TwoStageStochasticProgram, scenario_index::Integer; result::Int = 1)Return true if the solver has a primal solution in scenario scenario_index in result index result available to query, otherwise return false.
StochasticPrograms.stage — Methodstage(dvar::DecisionVariable)Return the stage of dvar.
StochasticPrograms.state — Methodstate(dvar::DecisionVariable, scenario_index::Integer)Return the scenario-dependent DecisionState of dvar at scenario_index.
StochasticPrograms.state — Methodstate(dvar::DecisionVariable)Return the DecisionState of the first-stage dvar.
StochasticPrograms.SPConstraintRef — TypeSPConstraintRefHolds a reference to the stochastic program, the stage the constraint resides in, and the corresponding MOI.ConstraintIndex.
JuMP.all_constraints — Methodall_constraints(stochasticprogram::StochasticProgram, stage::Integer, function_type, set_type)::Vector{<:SPConstraintRef}Return a list of all decision constraints currently in the stochasticprogram at stage where the function has type function_type and the set has type set_type. The constraints are ordered by creation time. This errors if regular constraints are queried. If so, either annotate the relevant variables with @decision or first query the relevant JuMP subproblem and use the regular all_constraints function.
JuMP.constraint_by_name — Methodconstraint_by_name(stochasticprogram::StochasticProgram,
stage::Integer,
name::String)::Union{SPConstraintRef, Nothing}Returns the reference of the constraint with name attribute name at stage of stochasticprogram or Nothing if no constraint has this name attribute. Throws an error if several constraints have name as their name attribute.
constraint_by_name(stochasticprogram::StochasticProgram,
stage::Integer,
name::String,
F::Type{<:Union{AbstractJuMPScalar,
Vector{<:AbstractJuMPScalar},
MOI.AbstactFunction}},
S::Type{<:MOI.AbstractSet})::Union{SPConstraintRef, Nothing}Similar to the method above, except that it throws an error if the constraint is not an F-in-S contraint where F is either the JuMP or MOI type of the function, and S is the MOI type of the set.
JuMP.constraint_object — Methodconstraint_object(sp_cref::SPConstraintRef)Return the underlying constraint data for the first-stage decision constraint referenced by sp_cref.
JuMP.constraint_object — Methodconstraint_object(sp_cref::SPConstraintRef, scenario_index)Return the underlying constraint data for the scenario-dependent decision constraint referenced by sp_cref in scenario scenario_index.
JuMP.delete — Methoddelete(stochasticprogram::StochasticProgram, sp_crefs::Vector{<:SPConstraintRef}, scenario_index::Integer)Delete the scenario-dependent decision constraints associated with sp_crefs from the stochasticprogram at scenario_index.
JuMP.delete — Methoddelete(stochasticprogram::StochasticProgram, sp_crefs::Vector{<:SPConstraintRef})Delete the first-stage decision constraints associated with sp_crefs from the stochasticprogram.
JuMP.delete — Methoddelete(stochasticprogram::StochasticProgram, sp_cref::SPConstraintRef, scenario_index::Integer)Delete the scenario-dependent decision constraint associated with sp_cref from the stochasticprogram in scenario scenario_index.
JuMP.delete — Methoddelete(stochasticprogram::StochasticProgram, sp_cref::SPConstraintRef)Delete the first-stage decision constraint associated with sp_cref from the stochasticprogram.
JuMP.dual — Methoddual(sp_cref::SPConstraintRef, scenario_index::Integer; result::Int = 1)Return the dual value of the scenario-dependent decision constraint sp_cref in scenario scenario_index associated with result index result of the most-recent solution returned by the solver.
JuMP.dual — Methoddual(sp_cref::SPConstraintRef; result::Int = 1)Return the dual value of the first-stage decision constraint sp_cref associated with result index result of the most-recent solution returned by the solver.
JuMP.has_duals — Methodhas_duals(stochasticprogram::StochasticProgram, stage::Integer, scenario_index::Integer; result::Int = 1)Return true if the solver has a dual solution in the node at stage stage and scenario scenario_index in result index result available to query, otherwise return false.
JuMP.has_duals — Methodhas_duals(stochasticprogram::TwoStageStochasticProgram, scenario_index::Integer; result::Int = 1)Return true if the solver has a dual solution in scenario scenario_index in result index result available to query, otherwise return false.
JuMP.has_duals — Methodhas_duals(stochasticprogram::StochasticProgram; result::Int = 1)Return true if the solver has a dual solution in the first-stage of stochasticprogram in result index result available to query, otherwise return false.
JuMP.index — Methodindex(sp_cref::SPConstraintNotOwned)::MOI.ConstraintIndexReturn the index of the decision constraint that corresponds to sp_cref in the MOI backend.
JuMP.is_valid — Methodis_valid(stochasticprogram::StochasticProgram, sp_cref::SPConstraintRef, scenario_index::Integer)Return true if the scenario-dependent sp_cref refers to a valid decision constraint in stochasticprogram at scenario_index.
JuMP.is_valid — Methodis_valid(stochasticprogram::StochasticProgram, sp_cref::SPConstraintRef)Return true if sp_cref refers to a valid first-stage decision constraint in stochasticprogram.
JuMP.list_of_constraint_types — Methodlist_of_constraint_types(stochasticprogram::Stochasticprogram, stage::Integer)::Vector{Tuple{DataType, DataType}}Return a list of tuples of the form (F, S) where F is a JuMP function type and S is an MOI set type such that all_constraints(stochasticprogram, stage, F, S) returns a nonempty list.
JuMP.name — Methodname(sp_cref::SPConstraintRef, scenario_index::Integer)::StringGet the name of the scenario-dependent decision constraint sp_cref in scenario scenario_index.
JuMP.name — Methodname(sp_cref::SPConstraintRef)::StringGet the name of the decision constraint sp_cref.
JuMP.normalized_coefficient — Methodnormalized_coefficient(sp_cref::SPConstraintRef, dvar::DecisionVariable, scenario_index::Integer)Return the coefficient associated with dvar in the decision constraint sp_cref in scenario scenario_index after JuMP has normalized the constraint into its standard form.
JuMP.normalized_coefficient — Methodnormalized_coefficient(sp_cref::SPConstraintRef, dvar::DecisionVariable)Return the coefficient associated with dvar in the first-stage decision constraint sp_cref after JuMP has normalized the constraint into its standard form.
JuMP.normalized_rhs — Methodnormalized_rhs(sp_cref::SPConstraintRef)Return the right-hand side term of the first-stage decision constraint sp_cref after JuMP has converted the constraint into its normalized form.
JuMP.normalized_rhs — Methodnormalized_rhs(sp_cref::SPConstraintRef, scenario_index::Integer)Return the right-hand side term of the scenario-dependent decision constraint sp_cref at scenario_index after JuMP has converted the constraint into its normalized form.
JuMP.num_constraints — Methodnum_constraints(stochasticprogram::StochasticProgram{N}, stage::Integer, function_type, set_type)::Int64Return the number of decision constraints currently in the stochasticprogram at stage where the function has type function_type and the set has type set_type. This errors if regular constraints are queried. If so, either annotate the relevant variables with @decision or first query the relevant JuMP subproblem and use the regular all_constraints function.
JuMP.optimizer_index — Methodoptimizer_index(sp_cref::SPConstraintRef, scenario_index)::MOI.VariableIndexReturn the index of the constraint that corresponds to the scenario-dependent sp_cref in the optimizer model at scenario_index.
JuMP.optimizer_index — Methodoptimizer_index(sp_cref::SPConstraintRef)::MOI.VariableIndexReturn the index of the variable that corresponds to dvar in the optimizer model.
JuMP.set_name — Methodset_name(sp_cref::SPConstraintRef, scenario_index::Integer, name::String)Set the name of the scenario-dependent decision constraint sp_cref in scenario scenario_index to name.
JuMP.set_name — Methodset_name(sp_cref::SPConstraintRef, name::String)Set the name of the decision constraint sp_cref to name.
JuMP.set_normalized_coefficient — Methodset_normalized_coefficient(sp_cref::SPConstraintRef, dvar::DecisionVariable, value)Set the coefficient of dvar in the first-stage decision constraint sp_cref to value.
JuMP.set_normalized_coefficient — Methodset_normalized_coefficient(sp_cref::SPConstraintRef, dvar::DecisionVariable, scenario_index::Integer, value)Set the coefficient of dvar in the decision constraint sp_cref in scenario scenario_index to value.
JuMP.set_normalized_rhs — Methodset_normalized_rhs(sp_cref::SPConstraintRef, value)Set the right-hand side term of the first-stage decision constraint sp_cref to value.
JuMP.set_normalized_rhs — Methodset_normalized_rhs(sp_cref::SPConstraintRef, scenario_index::Integer, value)Set the right-hand side term of the decision constraint sp_cref at scenario_index to value.
JuMP.value — Methodvalue(sp_cref::SPConstraintRef, dvar_value::Function)Evaluate the primal value of the first-stage decision constraint sp_cref using dvar_value(dvar) as the value for each decision variable dvar.
JuMP.value — Methodvalue(sp_cref::SPConstraintRef, dvar_value::Function)Evaluate the primal value of the scenario-dependent decision constraint sp_cref in scenario scenario_index using dvar_value(dvar) as the value for each decision variable dvar.
JuMP.value — Methodvalue(sp_cref::SPConstraintRef, scenario_index::Integer; result::Int = 1)Return the primal value of the scenario-dependent decision constraint sp_cref at scenario_index associated with result index result of the most-recent solution returned by the solver.
JuMP.value — Methodvalue(sp_cref::SPConstraintRef; result::Int = 1)Return the primal value of the first-stage decision constraint sp_cref associated with result index result of the most-recent solution returned by the solver.
StochasticPrograms.shadow_price — Methodshadow_price(sp_cref::SPConstraintRef)Return the shadow price of the first-stage decision constraint sp_cref associated with result index result of the most-recent solution returned by the solver.
StochasticPrograms.shadow_price — Methodshadow_price(sp_cref::SPConstraintRef, scenario_index::Integer)Return the shadow price of the scenario-dependent decision constraint sp_cref in scenario scenario_index associated with result index result of the most-recent solution returned by the solver.
StochasticPrograms.stage — Methodstage(sp_cref::SPConstraintRef)Return the stage of sp_cref.
JuMP.dual_objective_value — Methoddual_objective_value(stochasticprogram::StochasticProgram, stage::Integer, scenario_index::Integer; result::Int = 1)Return the objective value of the dual problem of the node at stage stage and scenario scenario_index associated with result index result of the most-recent solution after a call to optimize!(stochasticprogram).
JuMP.dual_objective_value — Methoddual_objective_value(stochasticprogram::TwoStageStochasticProgram, scenario_index::Integer; result::Int = 1)Return the objective value of the dual problem of scenario scenario_index associated with result index result of the most-recent solution after a call to optimize!(stochasticprogram).
JuMP.dual_objective_value — Methoddual_objective_value(stochasticprogram::StochasticProgram; result::Int = 1)Return the objective value of the dual problem associated with result index result of the most-recent solution after a call to optimize!(stochasticprogram).
JuMP.objective_bound — Methodobjective_bound(stochasticprogram::StochasticProgram, stage::Integer, scenario_index::Integer)Return the best known bound on the optimal objective value in the node at stage stage and scenario scenario_index after a call to optimize!(stochasticprogram).
JuMP.objective_bound — Methodobjective_bound(stochasticprogram::StochasticProgram)Return the best known bound on the optimal objective value after a call to optimize!(stochasticprogram).
JuMP.objective_function — Functionobjective_function(stochasticprogram::StochasticProgram,
T::Type{<:AbstractJuMPScalar}=objective_function_type(model))Return an object of type T representing the full objective function of the stochasticprogram. Error if the objective is not convertible to type T.
JuMP.objective_function — Functionobjective_function(stochasticprogram::StochasticProgram,
stage::Integer,
scenario_index::Integer,
T::Type{<:AbstractJuMPScalar}=objective_function_type(model))Return an object of type T representing the objective function in the node at stage stage and scenario scenario_index. Error if the objective is not convertible to type T.
JuMP.objective_function — Methodobjective_function(stochasticprogram::StochasticProgram,
stage::Integer,
T::Type{<:AbstractJuMPScalar}=objective_function_type(model))Return an object of type T representing the objective function at stage stage of the stochasticprogram. Error if the objective is not convertible to type T.
JuMP.objective_function_type — Methodobjective_function_type(stochasticprogram::Stochasticprogram, stage::Integer, scenario_index::Integer)::AbstractJuMPScalarReturn the type of the objective function in the node at stage stage and scenario scenario_index.
JuMP.objective_function_type — Methodobjective_function_type(stochasticprogram::Stochasticprogram)::AbstractJuMPScalarReturn the type of the objective function of stochasticprogram.
JuMP.objective_function_type — Methodobjective_function_type(stochasticprogram::Stochasticprogram, stage::Integer)::AbstractJuMPScalarReturn the type of the objective function at stage stage of stochasticprogram.
JuMP.objective_sense — Methodobjective_sense(stochasticprogram::StochasticProgram, stage::Integer, scenario_index::Integer)::MathOptInterface.OptimizationSenseReturn the objective sense in the node at stage stage and scenario scenario_index.
JuMP.objective_sense — Methodobjective_sense(stochasticprogram::StochasticProgram)::MathOptInterface.OptimizationSenseReturn the objective sense of the stochasticprogram.
JuMP.objective_sense — Methodobjective_sense(stochasticprogram::StochasticProgram, stage::Integer)::MathOptInterface.OptimizationSenseReturn the objective sense of the stochasticprogram stage stage.
JuMP.objective_value — Methodobjective_value(stochasticprogram::StochasticProgram, stage::Integer, scenario_index::Integer; result::Int = 1)Return the objective value of the node at stage stage and scenario scenario_index associated with result index result of the most-recent solution after a call to optimize!(stochasticprogram).
JuMP.objective_value — Methodobjective_value(stochasticprogram::TwoStageStochasticProgram, scenario_index::Integer; result::Int = 1)Return the objective value of scenario scenario_index associated with result index result of the most-recent solution after a call to optimize!(stochasticprogram).
JuMP.objective_value — Methodobjective_value(stochasticprogram::StochasticProgram; result::Int = 1)Return the objective value associated with result index result of the most-recent solution after a call to optimize!(stochasticprogram).
JuMP.relative_gap — Methodrelative_gap(model::StochasticProgram, stage::Integer, scenario_index::Integer)Return the final relative optimality gap in the node at stage stage and scenario scenario_index after a call to optimize!(stochasticprogram).
JuMP.relative_gap — Methodrelative_gap(model::StochasticProgram)Return the final relative optimality gap after a call to optimize!(stochasticprogram).
JuMP.set_objective_coefficient — Methodset_objective_coefficient(stochasticprogram::StochasticProgram, dvar::DecisionVariable, stage::Integer, scenario_index::Integer, coefficient::Real)Set the scenario-dependent linear objective coefficient at scenario_index associated with dvar to coefficient in stage stage.
JuMP.set_objective_coefficient — Methodset_objective_coefficient(stochasticprogram::StochasticProgram, dvar::DecisionVariable, stage::Integer, coefficient::Real)Set the linear objective coefficient associated with dvar to coefficient in stage stage.
JuMP.set_objective_sense — Methodset_objective_sense(stochasticprogram::StochasticProgram, stage::Integer, scenario_index::Integer, sense::MathOptInterface.OptimizationSense)Sets the objective sense of the stochasticprogram node at stage stage and scenario scenario_index to the given sense.
JuMP.set_objective_sense — Methodset_objective_sense(stochasticprogram::StochasticProgram, sense::MathOptInterface.OptimizationSense)Sets the objective sense of the stochasticprogram to sense.
JuMP.set_objective_sense — Methodset_objective_sense(stochasticprogram::StochasticProgram, stage::Integer, sense::MathOptInterface.OptimizationSense)Sets the objective sense of the stochasticprogram at stage stage to sense.
StochasticPrograms.DecisionRef — TypeDecisionRef <: AbstractVariableRefHolds a reference to the model, the stage the decision is taken in, and the corresponding MOI.VariableIndex.
StochasticPrograms.KnownRef — TypeKnownRef <: AbstractVariableRefHolds a reference to the model, the stage the decision is taken in, and the corresponding MOI.VariableIndex.
JuMP.fix — MethodJuMP.fix — Methodfix(kref::KnownRef, val::Number)Update the known decision value of kref to val.
StochasticPrograms.all_decision_variables — Methodall_decision_variables(model::JuMP.Model, stage::Integer)Returns a list of all decisions currently in the model at stage stage. The decisions are ordered by creation time.
StochasticPrograms.all_decision_variables — Methodall_decision_variables(model::JuMP.Model)Returns a stage-wise list of all decisions currently in the model. The decisions are ordered by creation time.
StochasticPrograms.all_known_decision_variables — Methodall_known_decision_variables(model::JuMP.Model, stage::Integer)Returns a stage-wise list of all known decisions currently in the model at stage stage. The decisions are ordered by creation time.
StochasticPrograms.all_known_decision_variables — Methodall_known_decision_variables(model::JuMP.Model)Returns a stage-wise list of all known decisions currently in the model. The decisions are ordered by creation time.
StochasticPrograms.decision — Methoddecision(dref::Union{DecisionRef, KnownRef})Return the internal Decision associated with dref.
StochasticPrograms.num_decisions — Functionnum_decisions(model::JuMP.Model, stage::Integer = 1)Return the number of decisions in model at stage stage. Defaults to the first stage.
StochasticPrograms.num_known_decisions — Functionnum_known_decisions(model::JuMP.Model, stage::Integer = 2)Return the number of known decisions in model at stage stage. Defaults to the second stage.
StochasticPrograms.state — Methodstate(dref::DecisionRef)Return the DecisionState of dref.
Scenarios
StochasticPrograms.AbstractScenario — TypeAbstractScenarioAbstract supertype for scenario objects.
StochasticPrograms.ExpectedScenario — TypeExpectedScenario{S <: AbstractScenario}Wrapper type around an AbstractScenario. Should for convenience be used as the result of a call to expected.
See also expected
StochasticPrograms.Probability — TypeProbabilityA type-safe wrapper for Float64 used to represent probability of a scenario occuring.
StochasticPrograms.Scenario — TypeScenarioConveniece type that adheres to the AbstractScenario abstraction. Useful when uncertain parameters are defined using @uncertain and instances are created using @scenario.
StochasticPrograms.expected — Methodexpected(scenarios::Vector{<:AbstractScenario})Return the expected scenario out of the collection scenarios in an ExpectedScenario wrapper.
This is defined through classical expectation: sum([probability(s)*s for s in scenarios]), and is always defined for scenarios created through @scenario, if the requested fields support it.
Otherwise, user-defined scenario types must implement this method for full functionality.
See also ExpectedScenario
StochasticPrograms.probability — Methodprobability(scenario::AbstractScenario)Return the probability of scenario occuring.
Is always defined for scenarios created through @scenario. Other user defined scenario types must implement this method to generate a proper probability. The default behaviour is to assume that scenario has a probability field of type Probability
See also: Probability
StochasticPrograms.probability — Methodprobability(scenarios::Vector{<:AbstractScenario})Return the probability of that any scenario in the collection scenarios occurs.
StochasticPrograms.scenariotext — Methodscenariotext(io::IO, scenario::AbstractScenario)Custom printout called when printing scenario.
StochasticPrograms.set_probability! — Methodset_probability!(scenario::AbstractScenario, probability::AbstractFloat)Set the probability of scenario occuring.
Is always defined for scenarios created through @scenario. Other user defined scenario types must implement this method.
StochasticPrograms.AbstractSampler — TypeAbstractSamplerAbstract supertype for sampler objects.
StochasticPrograms.Sampler — TypeStochasticPrograms.sample — Functionsample(sampler::AbstractSampler{S})Sample a scenario of type S using sampler.
sample(sampler::AbstractSampler{S}, π::AbstractSampler)Sample a scenario of type S using sampler and set the probability of the sampled scenario to π.
StochasticPrograms.SMPS.SMPSScenario — TypeSMPSScenarioConveniece type that adheres to the AbstractScenario abstraction. Obtained when reading scenarios specified in SMPS format.
See also: SMPSSampler
StochasticPrograms.SMPS.SMPSSampler — TypeSMPSSamplerSampler object for SMPS scenarios. Obtained by reading from a model defined in SMPS format.
See also: SMPSScenario
StochasticPrograms.@scenario — Macro@scenario(args..., probability = )Create Scenario matching some @uncertain declaration with a supplied probability.
@scenario(var1 = val1, var2 = val2, ..., probability = 1.0)Create Scenario matching @uncertain annotation of the form @uncertain var1, var2, ...
@scenario(ξ[i=..., j=..., ...] = values, probability = 1.0)Create Scenario matching @uncertain annotation of the form @uncertain ξ[i=..., j=..., ...]. values must have the same dimension as the specified index sets.
@scenario(ξ[i=..., j=..., ...], expr, probability = 1.0, requested_container = :Auto)Create Scenario matching @uncertain annotation of the form @uncertain ξ[i=..., j=..., ...]. Wraps JuMP's @container macro to create DenseAxisArray or SparseAxisArray as underlying data. See @container for further syntax information.
Examples
The following are equivalent ways of creating an instance of the random vector $[q₁(ξ) q₂(ξ) d₁(ξ) d₂(ξ)]$ of probability $0.4$ and values $[24.0 28.0 500.0 100.0]$.
@scenario q₁ = 24.0 q₂ = 28.0 d₁ = 500.0 d₂ = 100.0 probability = 0.4
@scenario ξ[i in 1:4] = [24.0, 28.0, 500.0, 100.0] probability = 0.4StochasticPrograms.@define_scenario — Macro@define_scenario(def)Define a scenario type compatible with StochasticPrograms using the syntax
@define_scenario name = begin
...structdef...
[@zero begin
...
return zero(scenario)
end]
[@expectation begin
...
return expected(scenarios)
end]
endThe generated type is referenced through name and a default constructor is always generated. This constructor accepts the keyword probability to set the probability of the scenario occuring. Otherwise, any internal variables and specialized constructors are defined in the @define_scenario block as they would be in any Julia struct.
If possible, a zero method and an expected method will be generated for the defined type. Otherwise, or if the default implementation is not desired, these can be user provided through @zero and @expectation.
The defined scenario type will be available on all Julia processes.
Examples
The following defines a simple scenario $ξ$ with a single value.
@define_scenario ExampleScenario = begin
ξ::Float64
end
ExampleScenario(1.0, probability = 0.5)
# output
ExampleScenario with probability 0.5
ξ: 1.0
See also: @zero, @expectation, @sampler
StochasticPrograms.@zero — Macro@zero(def)Define the additive zero scenario inside a @scenario block using the syntax:
@zero begin
...
return zero_scenario
endExamples
The following defines a zero scenario for the example scenario defined in @define_scenario
@zero begin
return ExampleScenario(0.0)
endSee also @define_scenario
StochasticPrograms.@expectation — Macro@expectation(def)Define how to form the expected scenario inside a @define_scenario block. The scenario collection is accessed through the reserved keyword scenarios.
@zero begin
...
return zero_scenario
endExamples
The following defines expectation for the example scenario defined in @scenario
@expectation begin
return ExampleScenario(sum([probability(s)*s.ξ for s in scenarios]))
endSee also @define_scenario
StochasticPrograms.@sampler — Macro@sampler(def)Define a sampler type for some scenariotype compatible with StochasticPrograms using the syntax
@sampler samplername = begin
...internals...
@sample scenariotype begin
...
return scenario
end
endAny internal state required by the sampler, as well as any specialized constructor, are defined in the @sampler block as they would be in any Julia struct. Define the sample operation inside the @sample block and specify the scenariotype that the sampler returns. The defined sampler will be available on all Julia processes.
Examples
The following defines a simple dummy sampler, with some internal weight value, for the scenario defined in @scenario, and samples one scenario.
@sampler ExampleSampler = begin
w::Float64
ExampleSampler(w::AbstractFloat) = new(w)
@sample ExampleScenario begin
@parameters w
return ExampleScenario(w*randn(), probability = rand())
end
end
s = ExampleSampler(2.0)
s()
# output
ExampleScenario with probability 0.29
ξ: 1.48
StochasticPrograms.@sample — Macro@sample(def)Define the sample operaton inside a @sampler block, using the syntax
@sample begin
...
return sampled_scenario
endThe sampler object is referenced through the reserved keyword sampler, from which any internals can be accessed.
Model definition
StochasticPrograms.@stage — Macro@stage(def)Add a stage model generation recipe to stochasticprogram using the syntax
@stage stage stochasticprogram::StochasticProgram = begin
@parameters param1 param2 ...
@decision(model, var) ...
@uncertain ξ
... JuMPdef ...
...
endwhere JuMP syntax is used inside the block to define the stage model. During definition, the second stage model is referenced through the reserved keyword model.
Examples
The following defines the first stage model given by:
\[ minimize 100x₁ + 150x₂ s.t x₁ + x₂ ≤ 120 x₁ ≥ 40 x₂ ≥ 20\]
and the second-stage model given by:
\[ maximize q₁(ξ)y₁ + q₂(ξ)y₂ s.t 6y₁ + 10y₂ ≤ 60x₁ 8y₁ + 5y₂ ≤ 60x₂ 0 ≤ y₁ ≤ d₁(ξ) 0 ≤ y₂ ≤ d₂(ξ)\]
where $q₁(ξ), q₂(ξ), d₁(ξ), d₂(ξ)$ depend on the scenario $ξ$ and $x₁, x₂$ are first stage variables. Two scenarios are added so that two second stage models are generated.
ξ₁ = @scenario q₁ = 24.0 q₂ = 28.0 d₁ = 500.0 d₂ = 100.0 probability = 0.4
ξ₂ = @scenario q₁ = 28.0 q₂ = 32.0 d₁ = 300.0 d₂ = 300.0 probability = 0.6
sp = StochasticProgram([ξ₁, ξ₂])
@stage 1 sp = begin
@decision(model, x₁ >= 40)
@decision(model, x₂ >= 20)
@objective(model, Min, 100*x₁ + 150*x₂)
@constraint(model, x₁ + x₂ <= 120)
end
@stage 2 sp = begin
@uncertain q₁ q₂ d₁ d₂
@variable(model, 0 <= y₁ <= d₁)
@variable(model, 0 <= y₂ <= d₂)
@objective(model, Max, q₁*y₁ + q₂*y₂)
@constraint(model, 6*y₁ + 10*y₂ <= 60*x₁)
@constraint(model, 8*y₁ + 5*y₂ <= 80*x₂)
end
# output
Stochastic program with:
* 2 decision variables
* 2 scenarios of type Scenario
Solver is default solver
See also: @parameters, @decision, @uncertain
StochasticPrograms.@first_stage — Macro@first_stage(def)Add a first stage model generation recipe to stochasticprogram using the syntax
@first_stage stochasticprogram::StochasticProgram = begin
...
end [defer]where JuMP syntax is used inside the block to define the first stage model. During definition, the first stage model is referenced through the reserved keyword model.
Examples
The following defines the first stage model given by:
\[ minimize 100x₁ + 150x₂ s.t x₁ + x₂ ≤ 120 x₁ ≥ 40 x₂ ≥ 20\]
@first_stage sp = begin
@decision(model, x₁ >= 40)
@decision(model, x₂ >= 20)
@objective(model, Min, 100*x₁ + 150*x₂)
@constraint(model, x₁ + x₂ <= 120)
endSee also: @second_stage
StochasticPrograms.@second_stage — Macro@second_stage(def)Add a second stage model generation recipe to stochasticprogram using the syntax
@second_stage stochasticprogram::StochasticProgram = begin
@known var1 var2 ...
...
endwhere JuMP syntax is used inside the block to define the second stage model. During definition, the second stage model is referenced through the reserved keyword model.
Examples
The following defines the second stage model given by:
\[ minimize q₁(ξ)y₁ + q₂(ξ)y₂ s.t 6y₁ + 10y₂ ≤ 60x₁ 8y₁ + 5y₂ ≤ 60x₂ 0 ≤ y₁ ≤ d₁(ξ) 0 ≤ y₂ ≤ d₂(ξ)\]
where $q₁(ξ), q₂(ξ), d₁(ξ), d₂(ξ)$ depend on the scenario $ξ$ and $x₁, x₂$ are first stage variables. Two scenarios are added so that two second stage models are generated.
@second_stage sp = begin
@known x₁ x₂
@uncertain q₁ q₂ d₁ d₂
@variable(model, 0 <= y₁ <= d₁)
@variable(model, 0 <= y₂ <= d₂)
@objective(model, Min, q₁*y₁ + q₂*y₂)
@constraint(model, 6*y₁ + 10*y₂ <= 60*x₁)
@constraint(model, 8*y₁ + 5*y₂ <= 80*x₂)
endSee also: @first_stage
StochasticPrograms.@decision — Macro@decision(model, expr, args..., kw_args...)Add a decision variable to model described by the expression expr. If used inside a @stage block, the created variable can be used in subsequent stage blocks. @recourse should be used to mark decisions in the final stage. See @variable for syntax details.
Examples
@decision(model, x >= 40)See also @recourse, @parameters, @uncertain, @stage
StochasticPrograms.@recourse — Macro@recourse(model, expr, args..., kw_args...)Add a recourse decision variable to model described by the expression expr. Replaces @decision in the @stage block of the final stage, and can only be used there. See @variable for syntax details.
Examples
@recourse(model, 0 <= y <= 1)See also @decision, @parameters, @uncertain, @stage
StochasticPrograms.@known — Macro@known(def)Annotate each decision taken in the previous stage. Any @decision included in a @stochastic_model definition will implicitly add @known annotations to subsequent stages.
Examples
@known x₁, x₂See also @decision, @parameters, @uncertain, @stage
StochasticPrograms.@parameters — Macro@parameters(def)Define the problem parameters in a @stage block
@parameters param1, param2, ...possibly with default values. Any defined parameter without a default value must be supplied as a keyword argument to instantiate when creating models.
Examples
@parameters d
@parameters begin
Crops = [:wheat, :corn, :beets]
Cost = Dict(:wheat=>150, :corn=>230, :beets=>260)
Budget = 500
endSee also @decision, @uncertain, @stage
StochasticPrograms.@uncertain — Macro@uncertain(def)In a @stage block, annotate each uncertain variable using the syntax
@uncertain var1, var2, ...or using JuMP's container syntax
@uncertain ξ[i=..., j=..., ...]This assumes that the [Scenario] type is used. Matching scenario data is then conveniently created using @scenario.
Alternatively, user-defined scenarios can be specified by annotating the type. Also, inside a @stochasticmodel block, user-defined scenarios can be created during the @uncertain annotation, using [`@definescenario`](@ref) syntax.
Examples
The following are equivalent ways of declaring a random vector $[q₁(ξ) q₂(ξ) d₁(ξ) d₂(ξ)]$ in a @stage block, and creating a matching scenario instance of probability $0.4$ and values $[24.0 28.0 500.0 100.0]$.ö
@uncertain q₁ q₂ d₁ d₂
ξ₁ = @scenario q₁ = 24.0 q₂ = 28.0 d₁ = 500.0 d₂ = 100.0 probability = 0.4
@uncertain ξ[i in 1:4]
ξ₁ = @scenario ξ[i in 1:4] = [24.0, 28.0, 500.0, 100.0] probability = 0.4
@define_scenario SimpleScenario = begin
q₁::Float64
q₂::Float64
d₁::Float64
d₂::Float64
end
@uncertain ξ::SimpleScenario
ξ₁ = SimpleScenario(24.0, 28.0, 500.0, 100.0, probability = 0.4)
@stochastic_model begin
...
@uncertain ξ::SimpleScenario = begin
q₁::Float64
q₂::Float64
d₁::Float64
d₂::Float64
end
...
end
ξ₁ = SimpleScenario(24.0, 28.0, 500.0, 100.0 probability = 0.4)See also @scenario, @define_scenario, @parameters, @decision, @stage
StochasticPrograms.@stochastic_model — Macro@stochastic_model(def)Define a stochastic model capable of instantiating stochastic programs, using the syntax
sm = @stochastic_model begin
...
@stage x begin
...
end
...
endwhere the inner blocks are @stage blocks. At least two stages must be specified in consecutive order. A stochastic model object can later be used to instantiate stochastic programs using a given set of scenarios or by using samplers.
Examples
The following defines a stochastic model consisitng of the first stage model given by:
\[ minimize 100x₁ + 150x₂ s.t x₁ + x₂ ≤ 120 x₁ ≥ 40 x₂ ≥ 20\]
and the second-stage model given by:
\[ minimize q₁(ξ)y₁ + q₂(ξ)y₂ s.t 6y₁ + 10y₂ ≤ 60x₁ 8y₁ + 5y₂ ≤ 60x₂ 0 ≤ y₁ ≤ d₁(ξ) 0 ≤ y₂ ≤ d₂(ξ)\]
where $q₁(ξ), q₂(ξ), d₁(ξ), d₂(ξ)$ depend on the scenario $ξ$.
sm = @stochastic_model begin
@stage 1 begin
@decision(model, x₁ >= 40)
@decision(model, x₂ >= 20)
@objective(model, Min, 100*x₁ + 150*x₂)
@constraint(model, x₁ + x₂ <= 120)
end
@stage 2 begin
@decision x₁ x₂
@uncertain q₁ q₂ d₁ d₂
@variable(model, 0 <= y₁ <= d₁)
@variable(model, 0 <= y₂ <= d₂)
@objective(model, Min, q₁*y₁ + q₂*y₂)
@constraint(model, 6*y₁ + 10*y₂ <= 60*x₁)
@constraint(model, 8*y₁ + 5*y₂ <= 80*x₂)
end
endSee also: @stage, @parameters, @decision, @uncertain
API
Base.getindex — MethodBase.getindex(stochasticprogram::StochasticProgram, stage::Integer, name::Symbol)Returns the decision, or group of decisions, or decision constraint, or group of decision constraints, of the given name and stage of the stochasticprogram which were added to the model. This errors if regular variables or constraints are queried. If so, either annotate the relevant variables with @decision or first query the relevant JuMP subproblem and use the regular [] syntax.
JuMP.dual_status — Methoddual_status(stochasticprogram::StochasticProgram, stage::Integer, scenario_index::Integer; result::Int = 1)Return the status of the most recent dual solution of the solver of the node at stage stage and scenario scenario_index.
JuMP.dual_status — Methoddual_status(stochasticprogram::TwoStageStochasticProgram, scenario_index::Integer; result::Int = 1)Return the status of the most recent dual solution of the solver of scenario scenario_index.
JuMP.dual_status — Methoddual_status(stochasticprogram::StochasticProgram; result::Int = 1)Return the status of the most recent dual solution of the solver of the stochasticprogram.
JuMP.num_variables — Methodnum_variables(stochasticprogram::StochasticProgram, stage::Integer = 1)Return the total number of variables at stage in the stochasticprogram. Defaults to the first stage.
JuMP.objective_value — Methodobjective_value(stochasticmodel::StochasticModel; result::Int = 1)Returns the value of the recourse problem after a call to optimize!(stochasticmodel).
JuMP.optimize! — Methodoptimize!(stochasticmodel::StochasticModel, sampler::AbstractSampler; crash::AbstractCrash = Crash.None(), kw...)Approximately optimize the stochasticmodel when the underlying scenario distribution is inferred by sampler. If an optimizer has not been set yet (see set_optimizer), a NoOptimizer error is thrown.
JuMP.optimize! — Methodoptimize!(stochasticprogram::StochasticProgram; crash::AbstractCrash = Crash.None(); kw...)Optimize the stochasticprogram in expectation. If an optimizer has not been set yet (see set_optimizer), a NoOptimizer error is thrown. An optional crash procedure can be set to warm-start.
Examples
The following solves the stochastic program sp using the L-shaped algorithm.
set_optimizer(sp, LShaped.Optimizer)
set_optimizer_attribute(sp, MasterOptimizer(), GLPK.Optimizer)
set_optimizer_attribute(sp, SubproblemOptimizer(), GLPK.Optimizer)
optimize!(sp);
# output
L-Shaped Gap Time: 0:00:02 (6 iterations)
Objective: -855.8333333333358
Gap: 0.0
Number of cuts: 8
Iterations: 6The following solves the stochastic program sp using GLPK on the extended form.
using GLPK
set_optimizer(sp, GLPK.Optimizer)
optimize!(sp)
See also: VRP
JuMP.primal_status — Methodprimal_status(stochasticprogram::StochasticProgram, stage::Integer, scenario_index::Integer; result::Int = 1)Return the status of the most recent primal solution of the solver of the node at stage stage and scenario scenario_index.
JuMP.primal_status — Methodprimal_status(stochasticprogram::TwoStageStochasticProgram, scenario_index::Integer; result::Int = 1)Return the status of the most recent primal solution of the solver of the scenario scenario_index.
JuMP.primal_status — Methodprimal_status(stochasticprogram::StochasticProgram; result::Int = 1)Return the status of the most recent primal solution of the solver of the stochasticprogram.
JuMP.raw_status — Methodraw_status(stochasticprogram::StochasticProgram, stage::Integer, scenario_index::Integer)Return the reason why the solver of the node at stage stage and scenario scenario_index stopped in its own words.
JuMP.raw_status — Methodraw_status(stochasticprogram::TwoStageStochasticProgram, scenario_index::Integer)Return the reason why the solver of scenario scenario_index stopped in its own words.
JuMP.raw_status — Methodraw_status(stochasticprogram::StochasticProgram)Return the reason why the solver of the stochasticprogram stopped in its own words.
JuMP.set_optimizer — Methodset_optimizer(stochasticmodel::StochasticModel, optimizer)Set the optimizer of the stochasticmodel.
JuMP.set_optimizer — Methodset_optimizer(stochasticprogram::StochasticProgram, optimizer)Set the optimizer of the stochasticprogram.
JuMP.set_optimizer_attribute — Methodset_optimizer_attribute(stochasticprogram::StochasticProgram, attr::MOI.AbstractOptimizerAttribute, value)Set the solver-specific attribute attr in stochasticprogram to value.
See also: get_optimizer_attribute
JuMP.set_optimizer_attribute — Methodset_optimizer_attribute(stochasticprogram::StochasticProgram, name::Union{Symbol, String}, value)Sets solver-specific attribute identified by name to value in the stochasticprogram.
See also: get_optimizer_attribute
JuMP.set_optimizer_attributes — Methodset_optimizer_attributes(stochasticprogram::StochasticProgram, pairs::Pair...)Given a list of attribute => value pairs or a collection of keyword arguments, calls set_optimizer_attribute(stochasticprogram, attribute, value) for each pair.
See also: get_optimizer_attribute
JuMP.solve_time — Methodsolve_time(stochasticprogram::StochasticProgram, stage::Integer, scenario_index::Integer)If available, returns the solve time reported by the solver of the node at stage stage and scenario scenario_index.
JuMP.solve_time — Methodsolve_time(stochasticprogram::TwoStageStochasticProgram, scenario_index::Integer)If available, returns the solve time reported by the solver of scenario scenario_index.
JuMP.solve_time — Methodsolve_time(stochasticprogram::StochasticProgram, stage::Integer, scenario_index::Integer)If available, returns the solve time reported by the solver of the stochasticprogram.
JuMP.termination_status — Methodtermination_status(stochasticprogram::StochasticProgram, stage::Integer, scenario_index::Integer)Return the reason why the solver of the node at stage stage and scenario scenario_index stopped.
JuMP.termination_status — Methodtermination_status(stochasticprogram::TwoStageStochasticProgram, scenario_index::Integer)Return the reason why the solver of scenario scenario_index stopped.
JuMP.termination_status — Methodtermination_status(stochasticprogram::StochasticProgram)Return the reason why the solver of the stochasticprogram stopped.
StochasticPrograms.add_scenario! — Methodadd_scenario!(scenariogenerator::Function, stochasticprogram::StochasticProgram, stage::Integer)Store the scenario returned by scenariogenerator in the stage of the stochasticprogram. If the stochasticprogram is distributed, the scenario will be defined on the node that currently has the fewest scenarios.
StochasticPrograms.add_scenario! — Methodadd_scenario!(scenariogenerator::Function, stochasticprogram::StochasticProgram)Store the scenario returned by scenariogenerator in the two-stage stochasticprogram. If the stochasticprogram is distributed, the scenario will be defined on the node that currently has the fewest scenarios.
StochasticPrograms.add_scenario! — Methodadd_scenario!(stochasticprogram::StochasticProgram, stage::Integer, scenario::AbstractScenario)Store the second stage scenario in the stochasticprogram at stage.
If the stochasticprogram is distributed, the scenario will be defined on the node that currently has the fewest scenarios.
StochasticPrograms.add_scenario! — Methodadd_scenario!(stochasticprogram::TwoStageStochasticProgram, scenario::AbstractScenario)Store the second stage scenario in the two-stage stochasticprogram.
StochasticPrograms.add_scenarios! — Methodadd_scenarios!(scenariogenerator::Function, stochasticprogram::StochasticProgram, stage::Integer, n::Integer)Generate n scenarios using scenariogenerator and store in the stochasticprogram at stage. If the stochasticprogram is distributed, scenarios will be distributed evenly across workers.
StochasticPrograms.add_scenarios! — Methodadd_scenarios!(scenariogenerator::Function, stochasticprogram::TwoStageStochasticProgram, n::Integer)Generate n scenarios using scenariogenerator and store in the two-stage stochasticprogram. If the stochasticprogram is distributed, scenarios will be distributed evenly across workers.
StochasticPrograms.add_scenarios! — Methodadd_scenarios!(stochasticprogram::StochasticProgram, stage::Integer, scenarios::Vector{<:AbstractScenario})Store the collection of scenarios in the stochasticprogram at stage. If the stochasticprogram is distributed, scenarios will be distributed evenly across workers.
StochasticPrograms.add_scenarios! — Methodadd_scenarios!(stochasticprogram::TwoStageStochasticProgram, scenarios::Vector{<:AbstractScenario})Store the collection of scenarios in the two-stage stochasticprogram. If the stochasticprogram is distributed, scenarios will be distributed evenly across workers.
StochasticPrograms.add_worker_scenario! — Methodadd_worker_scenario!(scenariogenerator::Function, stochasticprogram::StochasticProgram, stage::Integer, w::Integer)Store the scenario returned by scenariogenerator in worker node w of the stochasticprogram at stage.
StochasticPrograms.add_worker_scenario! — Methodadd_worker_scenario!(scenariogenerator::Function, stochasticprogram::TwoStageStochasticProgram, w::Integer)Store the scenario returned by scenariogenerator in worker node w of the two-stage stochasticprogram.
StochasticPrograms.add_worker_scenario! — Methodadd_worker_scenario!(stochasticprogram::StochasticProgram, stage::Integer, scenario::AbstractScenario, w::Integer)Store the second stage scenario in worker node w of the stochasticprogram at stage.
StochasticPrograms.add_worker_scenario! — Methodadd_worker_scenario!(stochasticprogram::StochasticProgram, stage::Integer, scenario::AbstractScenario, w::Integer)Store the second stage scenario in worker node w of the two-stage stochasticprogram.
StochasticPrograms.add_worker_scenarios! — Methodadd_worker_scenarios!(scenariogenerator::Function, stochasticprogram::StochasticProgram, stage::Integer, n::Integer, w::Integer)Generate n scenarios using scenariogenerator and store them in worker node w of the stochasticprogram at stage.
StochasticPrograms.add_worker_scenarios! — Methodadd_worker_scenarios!(scenariogenerator::Function, stochasticprogram::TwoStageStochasticProgram, n::Integer, w::Integer)Generate n scenarios using scenariogenerator and store them in worker node w of the two-stage stochasticprogram.
StochasticPrograms.add_worker_scenarios! — Methodadd_worker_scenarios!(stochasticprogram::StochasticProgram, stage::Integer, scenarios::Vector{<:AbstractScenario}, w::Integer)Store the collection of scenarios in in worker node w of the stochasticprogram at stage.
StochasticPrograms.add_worker_scenarios! — Methodadd_worker_scenarios!(stochasticprogram::StochasticProgram, stage::Integer, scenarios::Vector{<:AbstractScenario}, w::Integer)Store the collection of scenarios in in worker node w of the two-stage stochasticprogram.
StochasticPrograms.all_decision_variables — Methodall_decision_variables(stochasticprogram::StochasticProgram{N}, stage::Integer = 1) where NReturns a list of all decisions currently in the stochasticprogram at stage. The decisions are ordered by creation time.
StochasticPrograms.all_decision_variables — Methodall_decision_variables(stochasticprogram::StochasticProgram{N}) where NReturns a stage-wise list of all decisions currently in the stochasticprogram. The decisions are ordered by creation time. Defaults to the first stage.
StochasticPrograms.decision — Methoddecision(stochasticprogram::StochasticProgram, index::MOI.VariableIndex)Return the current value of the first-stage decision at index of stochasticprogram.
StochasticPrograms.decision — Methoddecision(stochasticprogram::StochasticProgram)Return the current first-stage decision values of stochasticprogram.
StochasticPrograms.deferred — Methoddeferred(stochasticprogram::StochasticProgram)Return true if stochasticprogram is not fully generated.
StochasticPrograms.distributed — Functiondistributed(stochasticprogram::StochasticProgram, s::Integer = 2)Return true if the stochasticprogram is memory distributed at stage s. Defaults to the second stage.
StochasticPrograms.expected — Methodexpected(stochasticprogram::StochasticProgram, stage::Integer = 2)Return the exected scenario of all scenarios of the stochasticprogram at stage. Defaults to the second stage.
StochasticPrograms.first_stage — Methodfirst_stage(stochasticprogram::StochasticProgram)Return the first stage of stochasticprogram.
StochasticPrograms.generator — Methodgenerator(stochasticprogram::StochasticProgram, key::Symbol)Return the problem generator associated with key in stochasticprogram.
StochasticPrograms.get_optimizer_attribute — Methodget_optimizer_attribute(stochasticprogram::StochasticProgram, attr::MOI.AbstractOptimizerAttribute)Return the value of the solver-specific attribute attr in stochasticprogram.
See also: set_optimizer_attribute, set_optimizer_attributes.
StochasticPrograms.get_optimizer_attribute — Methodget_optimizer_attribute(stochasticprogram::StochasticProgram, name::String)Return the value associated with the solver-specific attribute named name in stochasticprogram.
See also: set_optimizer_attribute, set_optimizer_attributes.
StochasticPrograms.has_generator — Methodhas_generator(stochasticprogram::StochasticProgram, key::Symbol)Return true if a problem generator with key exists in stochasticprogram.
StochasticPrograms.instantiate — Methodinstantiate(stochasticmodel::StochasticModel{2},
scenarios::Vector{<:AbstractScenario};
instantiation::StochasticInstantiation = UnspecifiedInstantiation(),
optimizer = nothing;
defer::Bool = false,
kw...)Instantiate a two-stage stochastic program using the model definition stored in the two-stage stochasticmodel, and the given collection of scenarios. Optionally, supply an optimizer. If no explicit instantiation is provided, the structure is induced by the optimizer. The structure is Deterministic by default.
StochasticPrograms.instantiate — Methodinstantiate(stochasticmodel::StochasticModel,
scenarios::Vector{<:AbstractScenario};
instantiation::StochasticInstantiation = UnspecifiedInstantiation(),
optimizer = nothing,
defer::Bool = false,
kw...)Instantiate a stochastic program using the model definition stored in stochasticmodel, and the given collection of scenarios. Optionally, supply an optimizer. If no explicit instantiation is provided, the structure is induced by the optimizer. The structure is Deterministic by default.
StochasticPrograms.instantiate — Methodinstantiate(stochasticmodel::StochasticModel{2};
instantiation::StochasticInstantiation = UnspecifiedInstantiation(),
optimizer = nothing,
scenario_type::Type{S} = Scenario,
defer::Bool = false,
kw...) where S <: AbstractScenarioInstantiate a deferred two-stage stochastic program using the model definition stored in the two-stage stochasticmodel over the scenario type S. Optionally, supply an optimizer. If no explicit instantiation is provided, the structure is induced by the optimizer. The structure is Deterministic by default.
StochasticPrograms.instantiate — Methodinstantiate(stochasticmodel::StochasticModel,
sampler::AbstractSampler,
n::Integer;
instantiation::StochasticInstantiation = UnspecifiedInstantiation(),
optimizer = nothing,
defer::Bool = false,
kw...)Generate a sampled instance of size n using the model stored in the two-stage stochasticmodel, and the provided sampler. Optionally, supply an optimizer. If no explicit instantiation is provided, the structure is induced by the optimizer. The structure is Deterministic by default.
StochasticPrograms.master_optimizer — Methodmaster_optimizer(stochasticprogram::StochasticProgram)Return a MOI optimizer using the currently provided optimizer of stochasticprogram.
StochasticPrograms.num_decisions — Methodnum_decisions(stochasticprogram::StochasticProgram, stage::Integer = 1)Return the number of decisions at stage in the stochasticprogram. Defaults to the first stage.
StochasticPrograms.num_scenarios — Functionnum_scenarios(stochasticprogram::StochasticProgram, stage::Integer = 2)Return the number of scenarios in the stochasticprogram at stage. Defaults to the second stage.
StochasticPrograms.num_stages — Methodnum_stages(stochasticprogram::StochasticProgram)Return the number of stages in stochasticprogram.
StochasticPrograms.num_subproblems — Functionnum_subproblems(stochasticprogram::StochasticProgram, stage::Integer = 2)Return the number of subproblems in the stochasticprogram at stage. Defaults to the second stage.
StochasticPrograms.optimal_decision — Methodoptimal_decision(stochasticmodel::StochasticModel)Return the optimal first stage decision of stochasticmodel, after a call to optimize!(stochasticmodel).
StochasticPrograms.optimal_decision — Methodoptimal_decision(stochasticprogram::StochasticProgram, stage::Integer, scenario_index::Integer)Return the optimal decision in the node at stage stage and scenario scenario_index of stochasticprogram, after a call to optimize!(stochasticprogram).
StochasticPrograms.optimal_decision — Methodoptimal_decision(stochasticprogram::TwoStageStochasticProgram, scenario_index::Integer)Return the optimal decision in scenario scenario_index of the two-stage stochasticprogram, after a call to optimize!(stochasticprogram).
StochasticPrograms.optimal_decision — Methodoptimal_decision(stochasticprogram::StochasticProgram)Return the optimal first stage decision of stochasticprogram, after a call to optimize!(stochasticprogram).
StochasticPrograms.optimal_recourse_decision — Methodoptimal_recourse_decision(stochasticprogram::StochasticProgram, scenario_index::Integer)Return the optimal recourse decision in the final stage of stochasticprogram in the scenario scenario_index, after a call to optimize!(stochasticprogram).
StochasticPrograms.optimizer — Methodoptimizer(stochasticmodel::StochasticModel)Return the optimizer attached to stochasticmodel.
StochasticPrograms.optimizer — Methodoptimizer(stochasticprogram::StochasticProgram)Return the optimizer attached to stochasticprogram.
StochasticPrograms.optimizer_constructor — Methodoptimizer_constructor(stochasticmodel::StochasticModel)Return any optimizer constructor supplied to the stochasticmodel.
StochasticPrograms.optimizer_constructor — Methodoptimizer_constructor(stochasticprogram::StochasticProgram)Return any optimizer constructor supplied to the stochasticprogram.
StochasticPrograms.optimizer_name — Methodoptimizer_name(stochasticmodel::StochasticModel)Return the currently provided optimizer type of stochasticmodel.
StochasticPrograms.optimizer_name — Methodoptimizer_name(stochasticprogram::StochasticProgram)Return the currently provided optimizer type of stochasticprogram.
StochasticPrograms.probability — Methodprobability(stochasticprogram::TwoStageStochasticProgram, scenario_index::Integer)Return the probability of the scenario at scenario_index in the two-stage stochasticprogram occuring.
StochasticPrograms.probability — Methodprobability(stochasticprogram::StochasticProgram, stage::Integer, scenario_index::Integer)Return the probability of the scenario at scenario_index in the stochasticprogram at stage occuring.
StochasticPrograms.proxy — Methodproxy(stochasticprogram::StochasticProgram, stage::Integer)Return the proxy model of the stochasticprogram at stage.
StochasticPrograms.sample! — Methodsample!(stochasticprogram::StochasticProgram, stage::Integer, sampler::AbstractSampler, n::Integer)Sample n scenarios using sampler and add to the stochasticprogram at stage. If the stochasticprogram is distributed, scenarios will be distributed evenly across workers.
StochasticPrograms.sample! — Methodsample!(stochasticprogram::TwoStageStochasticProgram, sampler::AbstractSampler, n::Integer)Sample n scenarios using sampler and add to the two-stage stochasticprogram. If the stochasticprogram is distributed, scenarios will be distributed evenly across workers.
StochasticPrograms.scenario — Methodscenario(stochasticprogram::TwoStageStochasticProgram, scenario_index::Integer)Return the scenario at scenario_index of the two-stage stochasticprogram
StochasticPrograms.scenario — Methodscenario(stochasticprogram::StochasticProgram, stage::Integer, scenario_index::Integer)Return the scenario at scenario_index of stochasticprogram at stage stage.
StochasticPrograms.scenario_type — Methodscenario_type(stochasticprogram::StochasticProgram, stage::Integer = 2)Return the type of the scenario structure associated with stochasticprogram at stage. Defaults to the second stage.
StochasticPrograms.scenario_types — Methodscenario_types(stochasticprogram::StochasticProgram)Return a stage-wise list of the scenario types of stochasticprogram.
StochasticPrograms.scenarios — Methodscenarios(stochasticprogram::StochasticProgram, stage::Integer = 2)Return an array of all scenarios of the stochasticprogram at stage. Defaults to the second stage.
StochasticPrograms.stage_parameters — Methodstage_parameters(stochasticprogram::StochasticProgram, stage::Integer)Return the parameters at stage in stochasticprogram.
StochasticPrograms.stage_probability — Methodstage_probability(stochasticprogram::StochasticProgram, stage::Integer = 2)Return the probability of any scenario in the stochasticprogram at stage occuring. A well defined model should return 1. Defaults to the second stage.
StochasticPrograms.structure — Methodstructure(stochasticprogram::StochasticProgram)Return the underlying structure of the stochasticprogram.
StochasticPrograms.structure_name — Methodstructure_name(stochasticprogram::StochasticProgram)Return the name of the underlying structure of the stochasticprogram.
StochasticPrograms.subproblem — Methodsubproblem(stochasticprogram::TwoStasgeStochasticProgram, scenario_index::Integer)Return the subproblem at scenario_index of the two-stage stochasticprogram.
StochasticPrograms.subproblem — Methodsubproblem(stochasticprogram::StochasticProgram, stage::Integer, scenario_index::Integer)Return the subproblem at scenario_index of the stochasticprogram at stage.
StochasticPrograms.subproblem_optimizer — Methodsubproblem_optimizer(stochasticprogram::StochasticProgram)Return a MOI optimizer for solving subproblems using the currently provided optimizer of stochasticprogram.
StochasticPrograms.subproblems — Methodsubproblems(stochasticprogram::StochasticProgram, stage::Integer = 2)Return an array of all subproblems of the stochasticprogram at stage. Defaults to the second stage.
StochasticPrograms.update_decisions! — Methodupdate_decisions!(stochasticmodel::Stochasticprogram, change::DecisionModification, stage::Integer, scenario_index::Integer)Apply the decision modification change to the node at stage stage and scenario scenario_index of stochasticprogram.
StochasticPrograms.update_decisions! — Methodupdate_decisions!(stochasticmodel::Stochasticprogram, change::DecisionModification)Apply the decision modification change to the first-stage of stochasticprogram.
StochasticPrograms.update_decisions! — Methodupdate_decisions!(stochasticmodel::TwoStageStochasticprogram, change::DecisionModification, scenario_index::Integer)Apply the decision modification change in scenario scenario_index of the two-stage stochasticprogram.
StochasticPrograms.clear! — Methodclear!(stochasticprogram::StochasticProgram)Clear the stochasticprogram, removing all model definitions.
StochasticPrograms.generate! — Methodgenerate!(stochasticprogram::StochasticProgram)Generate the stochasticprogram using the model definitions from @stage and available data.
StochasticPrograms.outcome_model — Methodoutcome_model(stochasticprogram::TwoStageStochasticProgram,
decision::AbstractVector,
scenario::AbstractScenario;
optimizer = nothing)Return the resulting second stage model if decision is the first-stage decision in the provided scenario, in stochasticprogram. The supplied decision must match the defined decision variables in stochasticprogram. Optionally, supply a capable optimizer to the outcome model.
StochasticPrograms.outcome_model — Methodoutcome_model(stochasticprogram::StochasticProgram{N},
decisions::NTuple{N-1,AbstractVector}
scenario_path::NTuple{N-1,AbstractScenario},
optimizer = nothing)Return the resulting N:th stage model if decisions are the decisions taken in the previous stages and scenario_path are the realized scenarios up to stage N in stochasticprogram. Optionally, supply a capable solver to the outcome model.
StochasticPrograms.stage_model — Methodstage_model(stochasticprogram::StochasticProgram, stage::Integer, scenario::AbstractScenario; optimizer = nothing)Return a generated stage model corresponding to scenario, in stochasticprogram. Optionally, supply a capable optimizer to the stage model.
StochasticPrograms.stage_one_model — Methodstage_one_model(stochasticprogram::StochasticProgram; optimizer = nothing)Return a generated copy of the first stage model in stochasticprogram. Optionally, supply a capable optimizer to the stage model.
StochasticPrograms.confidence_interval — Methodconfidence_interval(stochasticmodel::StochasticModel{2}, sampler::AbstractSampler)Generate a confidence interval around the true optimum of the two-stage stochasticmodel at level confidence using SAA, over the scenario distribution induced by sampler.
The attribute NumSamples is the size of the sampled models used to generate the interval and generally governs how tight it is. The attribute NumLowerTrials is the number of sampled models used in the lower bound calculation and the attribute NumUpperTrials is the number of sampled models used in the upper bound calculation. The attribute NumEvalSamples is the size of the sampled models used in the upper bound calculation. The confidence level can be set through the Confidence attribute.
If a sample-based optimizer has not been set yet (see set_optimizer), a NoOptimizer error is thrown.
StochasticPrograms.evaluate_decision — Methodevaluate_decision(stochasticmodel::StochasticModel{2}, decision::AbstractVector, sampler::AbstractSampler; kw...)Return a statistical estimate of the objective of the two-stage stochasticmodel at decision in the form of a confidence interval at the current confidence level, over the scenario distribution induced by sampler.
In other words, evaluate decision on a sampled model and generate an confidence interval using the sample variance of the evaluation. The confidence level can be set through the Confidence attribute and the sample size can be set through the NumEvalSamples attribute.
The supplied decision must match the defined decision variables in stochasticmodel. If a sample-based optimizer has not been set yet (see set_optimizer), a NoOptimizer error is thrown.
See also: confidence_interval
StochasticPrograms.evaluate_decision — Methodevaluate_decision(stochasticprogram::TwoStageStochasticProgram, decision::AbstractVector, scenario::AbstractScenario)Evaluate the result of taking the first-stage decision if scenario is the actual outcome in stochasticprogram. The supplied decision must match the defined decision variables in stochasticprogram. If an optimizer has not been set yet (see set_optimizer), a NoOptimizer error is thrown.
StochasticPrograms.evaluate_decision — Methodevaluate_decision(stochasticprogram::TwoStageStochasticProgram, decision::AbstractVector)Evaluate the first-stage decision in stochasticprogram.
In other words, evaluate the first-stage objective at decision and solve outcome models of decision for every available scenario. The supplied decision must match the defined decision variables in stochasticprogram. If an optimizer has not been set yet (see set_optimizer), a NoOptimizer error is thrown.
StochasticPrograms.gap — Methodgap(stochasticmodel::StochasticModel{2}, decision::UnionAbstractVector, sampler::AbstractSampler)Generate a confidence interval around the gap between the result of using decision and the true optimum of the two-stage stochasticmodel at the current confidence level, over the scenario distribution induced by sampler.
The attribute NumSamples is the size of the sampled models used to generate the interval and generally governs how tight it is. The attribute NumLowerTrials is the number of sampled models used in the lower bound calculation and the attribute NumUpperTrials is the number of sampled models used in the upper bound calculation. The attribute NumEvalSamples is the size of the sampled models used in the upper bound calculation. The confidence level can be set through the Confidence attribute.
The supplied decision must match the defined decision variables in stochasticmodel. If a sample-based optimizer has not been set yet (see set_optimizer), a NoOptimizer error is thrown.
StochasticPrograms.lower_confidence_interval — Methodlower_confidence_interval(stochasticmodel::StochasticModel{2}, sampler::AbstractSampler; kw...)Generate a confidence interval around a lower bound on the true optimum of the two-stage stochasticmodel at the current confidence level, over the scenario distribution induced by sampler.
The attribute NumSamples is the size of the sampled models used to generate the interval and generally governs how tight it is. The attribute NumLowerTrials is the number of sampled models. The confidence level can be set through the Confidence attribute.
If a sample-based optimizer has not been set yet (see set_optimizer), a NoOptimizer error is thrown.
StochasticPrograms.recourse_decision — Methodrecourse_decision(stochasticprogram::TwoStageStochasticProgram, decision::AbstractVector, scenario::AbstractScenario)Determine the optimal recourse decision after taking the first-stage decision if scenario is the actual outcome in stochasticprogram. The supplied decision must match the defined decision variables in stochasticprogram. If an optimizer has not been set yet (see set_optimizer), a NoOptimizer error is thrown.
StochasticPrograms.statistically_evaluate_decision — Methodstatistically_evaluate_decision(stochasticprogram::TwoStageStochasticProgram, decision::AbstractVector)Statistically evaluate the first-stage decision in stochasticprogram, returning the evaluated value and the spread over the scenarios.
The supplied decision must match the defined decision variables in stochasticprogram. If an optimizer has not been set yet (see set_optimizer), a NoOptimizer error is thrown.
StochasticPrograms.upper_confidence_interval — Methodupper_confidence_interval(stochasticmodel::StochasticModel{2}, decision::AbstractVector, sampler::AbstractSampler; kw...)Generate a confidence interval around an upper bound of the expected value of decision in the two-stage stochasticmodel at the current confidence level, over the scenario distribution induced by sampler.
The attribute NumUpperTrials is the number of sampled models and the attribute NumEvalSamples is the size of the evaluation models. The confidence level can be set through the Confidence attribute.
The supplied decision must match the defined decision variables in stochasticmodel. If an optimizer has not been set yet (see set_optimizer), a NoOptimizer error is thrown.
StochasticPrograms.upper_confidence_interval — Methodupper_confidence_interval(stochasticmodel::StochasticModel{2}, sampler::AbstractSampler; kw...)Generate a confidence interval around an upper bound of the true optimum of the two-stage stochasticmodel at the current confidence level, over the scenario distribution induced by sampler, by generating and evaluating a candidate decision.
The attribute NumSamples is the size of the sampled model used to generate a candidate decision. The attribute NumUpperTrials is the number of sampled models and the attribute NumEvalSamples is the size of the evaluation models. The confidence level can be set through the Confidence attribute.
If a sample-based optimizer has not been set yet (see set_optimizer), a NoOptimizer error is thrown.
Stochastic programming constructs
StochasticPrograms.DEP — MethodDEP(stochasticprogram::TwoStageStochasticProgram; optimizer = nothing)Generate the deterministically equivalent problem (DEP) of the two-stage stochasticprogram, unless a cached version already exists.
In other words, generate the extended form the stochasticprogram as a single JuMP model. Optionally, a capable optimizer can be supplied to DEP.
StochasticPrograms.EEV — MethodEEV(stochasticmodel::StochasticModel{2}, sampler::AbstractSampler)Approximately calculate the expected value of the expected value decision (EEV) of the two-stage stochasticmodel to the current confidence level, over the scenario distribution induced by sampler.
The attribute NumEEVSamples is the size of the sampled models used in the eev calculation. The confidence level can be set through the Confidence attribute.
If a sample-based optimizer has not been set yet (see set_optimizer), a NoOptimizer error is thrown.
StochasticPrograms.EEV — MethodEEV(stochasticprogram::TwoStageStochasticProgram)Calculate the expected value of the expected value solution (EEV) of the two-stage stochasticprogram.
In other words, evaluate the EVP decision. If an optimizer has not been set yet (see set_optimizer), a NoOptimizer error is thrown.
StochasticPrograms.EV — MethodEV(stochasticprogram::TwoStageStochasticProgram)Calculate the optimal value of the EVP of the two-stage stochasticprogram.
If an optimizer has not been set yet (see set_optimizer), a NoOptimizer error is thrown.
See also: EVP, expected_value_decision, EEV
StochasticPrograms.EVP — MethodEVP(stochasticprogram::TwoStageStochasticProgram; optimizer = nothing)Generate the expected value problem (EVP) of the two-stage stochasticprogram.
In other words, generate a wait-and-see model corresponding to the expected scenario over all available scenarios in stochasticprogram. Optionally, a capable optimizer can be supplied to WS.
See also: expected_value_decision, EEV, EV, WS
StochasticPrograms.EVPI — MethodEVPI(stochasticmodel::StochasticModel{2}, sampler::AbstractSampler)Approximately calculate the expected value of perfect information (EVPI) of the two-stage stochasticmodel to the current confidence level, over the scenario distribution induced by sampler.
In other words, calculate confidence intervals around VRP and EWS. If they do not overlap, the EVPI is statistically significant, and a confidence interval is calculated and returned.
The attribute NumSamples is the size of the sampled models used to generate the interval and generally governs how tight it is. The attribute NumLowerTrials is the number of sampled models used in the lower bound calculation and the attribute NumUpperTrials is the number of sampled models used in the upper bound calculation. The attribute NumEvalSamples is the size of the sampled models used in the upper bound calculation. The confidence level can be set through the Confidence attribute.
If a sample-based optimizer has not been set yet (see set_optimizer), a NoOptimizer error is thrown.
StochasticPrograms.EVPI — MethodEVPI(stochasticprogram::TwoStageStochasticProgram)Calculate the expected value of perfect information (EVPI) of the two-stage stochasticprogram.
In other words, calculate the gap between VRP and EWS. If an optimizer has not been set yet (see set_optimizer), a NoOptimizer error is thrown.
StochasticPrograms.EWS — MethodEWS(stochasticmodel::StochasticModel{2}, sampler::AbstractSampler)Approximately calculate the expected wait-and-see result (EWS) of the two-stage stochasticmodel to the current confidence level, over the scenario distribution induced by sampler.
The attribute NumEWSSamples is the size of the sampled models used to generate the interval and generally governs how tight it is. The confidence level can be set through the Confidence attribute.
If a sample-based optimizer has not been set yet (see set_optimizer), a NoOptimizer error is thrown.
StochasticPrograms.EWS — MethodEWS(stochasticprogram::StochasticProgram)Calculate the expected wait-and-see result (EWS) of the stochasticprogram.
In other words, calculate the expectated result of all possible wait-and-see models, using the provided scenarios in stochasticprogram.
If an optimizer has not been set yet (see set_optimizer), a NoOptimizer error is thrown.
StochasticPrograms.VRP — MethodVRP(stochasticmodel::StochasticModel{2}, sampler::AbstractSampler; confidence = 0.95)Return a confidence interval around the value of the recouse problem (VRP) of stochasticmodel to the given confidence level.
If a sample-based optimizer has not been set yet (see set_optimizer), a NoOptimizer error is thrown.
StochasticPrograms.VRP — MethodVRP(stochasticprogram::StochasticProgram)Calculate the value of the recouse problem (VRP) in stochasticprogram.
In other words, optimize the stochastic program and return the optimal value.
If an optimizer has not been set yet (see set_optimizer), a NoOptimizer error is thrown.
StochasticPrograms.VSS — MethodVSS(stochasticmodel::StochasticModel{2}, sampler::AbstractSampler)Approximately calculate the value of the stochastic solution (VSS) of the two-stage stochasticmodel to the current confidence level, over the scenario distribution induced by sampler.
In other words, calculate confidence intervals around EEV and VRP. If they do not overlap, the VSS is statistically significant, and a confidence interval is calculated and returned. Ñ is the number of samples in the out-of-sample evaluation of EEV.
The attribute NumSamples is the size of the sampled models used to generate the interval and generally governs how tight it is. The same size is used to generate the expected value decision. The attribute NumLowerTrials is the number of sampled models used in the lower bound calculation and the attribute NumUpperTrials is the number of sampled models used in the upper bound calculation. The attribute NumEvalSamples is the size of the sampled models used in the upper bound calculation and the attribute [NumEEVSamples] is the size of the sampled models used in the EEV calculation. The confidence level can be set through the Confidence attribute.
If a sample-based optimizer has not been set yet (see set_optimizer), a NoOptimizer error is thrown.
StochasticPrograms.VSS — MethodVSS(stochasticprogram::TwoStageStochasticProgram)Calculate the value of the stochastic solution (VSS) of the two-stage stochasticprogram.
In other words, calculate the gap between EEV and VRP. If an optimizer has not been set yet (see set_optimizer), a NoOptimizer error is thrown.
StochasticPrograms.WS — MethodWS(stochasticprogram::TwoStageStochasticProgram, scenario::AbstractScenarioaData; optimizer = nothing)Generate a wait-and-see (WS) model of the two-stage stochasticprogram, corresponding to scenario.
In other words, generate the first stage and the second stage of the stochasticprogram as if scenario is known to occur. Optionally, a capable optimizer can be supplied to WS.
StochasticPrograms.expected_value_decision — Methodexpected_value_decision(stochasticprogram::TwoStageStochasticProgram)Calculate the optimizer of the EVP of the two-stage stochasticprogram.
If an optimizer has not been set yet (see set_optimizer), a NoOptimizer error is thrown.
StochasticPrograms.wait_and_see_decision — Methodwait_and_see_decision(stochasticprogram::TwoStageStochasticProgram, scenario::AbstractScenario, optimizer_constructor = nothing)Calculate the optimizer of the wait-and-see (WS) model of the two-stage stochasticprogram, corresponding to scenario.
If an optimizer has not been set yet (see set_optimizer), a NoOptimizer error is thrown.
See also: WS