Public interface
Documentation for StochasticPrograms.jl
's public interface.
Contents
Index
StochasticPrograms.AbstractSampler
StochasticPrograms.AbstractScenario
StochasticPrograms.AbstractStochasticStructure
StochasticPrograms.DecisionRef
StochasticPrograms.DecisionVariable
StochasticPrograms.Deterministic
StochasticPrograms.DeterministicEquivalent
StochasticPrograms.DistributedHorizontal
StochasticPrograms.DistributedScenarioDecomposition
StochasticPrograms.DistributedStageDecomposition
StochasticPrograms.DistributedVertical
StochasticPrograms.ExpectedScenario
StochasticPrograms.Horizontal
StochasticPrograms.Probability
StochasticPrograms.SMPS.SMPSSampler
StochasticPrograms.SMPS.SMPSScenario
StochasticPrograms.SPConstraintRef
StochasticPrograms.Sampler
StochasticPrograms.Scenario
StochasticPrograms.ScenarioDecomposition
StochasticPrograms.ScenarioDecompositionStructure
StochasticPrograms.StageDecomposition
StochasticPrograms.StageDecompositionStructure
StochasticPrograms.StochasticInstantiation
StochasticPrograms.StochasticProgram
StochasticPrograms.StochasticProgram
StochasticPrograms.StochasticProgram
StochasticPrograms.StochasticProgram
StochasticPrograms.StochasticProgram
StochasticPrograms.StochasticProgram
StochasticPrograms.UnloadableStructure
StochasticPrograms.UnloadedStructure
StochasticPrograms.UnspecifiedInstantiation
StochasticPrograms.UnsupportedStructure
StochasticPrograms.Vertical
StochasticPrograms.@decision
StochasticPrograms.@define_scenario
StochasticPrograms.@define_scenario
StochasticPrograms.@expectation
StochasticPrograms.@expectation
StochasticPrograms.@first_stage
StochasticPrograms.@known
StochasticPrograms.@parameters
StochasticPrograms.@recourse
StochasticPrograms.@sample
StochasticPrograms.@sampler
StochasticPrograms.@scenario
StochasticPrograms.@scenario
StochasticPrograms.@second_stage
StochasticPrograms.@stage
StochasticPrograms.@stochastic_model
StochasticPrograms.@uncertain
StochasticPrograms.@uncertain
StochasticPrograms.@zero
StochasticPrograms.@zero
Base.getindex
Base.read
Base.read
Base.read
JuMP.BinaryRef
JuMP.FixRef
JuMP.IntegerRef
JuMP.LowerBoundRef
JuMP.UpperBoundRef
JuMP.all_constraints
JuMP.constraint_by_name
JuMP.constraint_object
JuMP.constraint_object
JuMP.delete
JuMP.delete
JuMP.delete
JuMP.delete
JuMP.delete
JuMP.delete
JuMP.delete
JuMP.delete
JuMP.delete_lower_bound
JuMP.delete_lower_bound
JuMP.delete_upper_bound
JuMP.delete_upper_bound
JuMP.dual
JuMP.dual
JuMP.dual_objective_value
JuMP.dual_objective_value
JuMP.dual_objective_value
JuMP.dual_status
JuMP.dual_status
JuMP.dual_status
JuMP.fix
JuMP.fix
JuMP.fix
JuMP.get_optimizer_attribute
JuMP.get_optimizer_attribute
JuMP.has_duals
JuMP.has_duals
JuMP.has_duals
JuMP.has_lower_bound
JuMP.has_lower_bound
JuMP.has_upper_bound
JuMP.has_upper_bound
JuMP.has_values
JuMP.has_values
JuMP.has_values
JuMP.index
JuMP.index
JuMP.is_binary
JuMP.is_binary
JuMP.is_fixed
JuMP.is_fixed
JuMP.is_integer
JuMP.is_integer
JuMP.is_valid
JuMP.is_valid
JuMP.is_valid
JuMP.is_valid
JuMP.list_of_constraint_types
JuMP.lower_bound
JuMP.lower_bound
JuMP.name
JuMP.name
JuMP.name
JuMP.name
JuMP.normalized_coefficient
JuMP.normalized_coefficient
JuMP.normalized_rhs
JuMP.normalized_rhs
JuMP.num_constraints
JuMP.num_variables
JuMP.objective_bound
JuMP.objective_bound
JuMP.objective_function
JuMP.objective_function
JuMP.objective_function
JuMP.objective_function_type
JuMP.objective_function_type
JuMP.objective_function_type
JuMP.objective_sense
JuMP.objective_sense
JuMP.objective_sense
JuMP.objective_value
JuMP.objective_value
JuMP.objective_value
JuMP.objective_value
JuMP.optimize!
JuMP.optimize!
JuMP.optimizer_index
JuMP.optimizer_index
JuMP.optimizer_index
JuMP.optimizer_index
JuMP.primal_status
JuMP.primal_status
JuMP.primal_status
JuMP.raw_status
JuMP.raw_status
JuMP.raw_status
JuMP.reduced_cost
JuMP.reduced_cost
JuMP.relative_gap
JuMP.relative_gap
JuMP.relax_integrality
JuMP.set_binary
JuMP.set_binary
JuMP.set_integer
JuMP.set_integer
JuMP.set_lower_bound
JuMP.set_lower_bound
JuMP.set_name
JuMP.set_name
JuMP.set_name
JuMP.set_name
JuMP.set_normalized_coefficient
JuMP.set_normalized_coefficient
JuMP.set_normalized_rhs
JuMP.set_normalized_rhs
JuMP.set_objective_coefficient
JuMP.set_objective_coefficient
JuMP.set_objective_sense
JuMP.set_objective_sense
JuMP.set_objective_sense
JuMP.set_optimizer
JuMP.set_optimizer
JuMP.set_optimizer_attribute
JuMP.set_optimizer_attribute
JuMP.set_optimizer_attributes
JuMP.set_start_value
JuMP.set_start_value
JuMP.set_upper_bound
JuMP.set_upper_bound
JuMP.shadow_price
JuMP.shadow_price
JuMP.solve_time
JuMP.solve_time
JuMP.solve_time
JuMP.start_value
JuMP.start_value
JuMP.termination_status
JuMP.termination_status
JuMP.termination_status
JuMP.unfix
JuMP.unfix
JuMP.unset_binary
JuMP.unset_binary
JuMP.unset_integer
JuMP.unset_integer
JuMP.upper_bound
JuMP.upper_bound
JuMP.value
JuMP.value
JuMP.value
JuMP.value
JuMP.value
JuMP.value
JuMP.value
StochasticPrograms.DEP
StochasticPrograms.EEV
StochasticPrograms.EEV
StochasticPrograms.EV
StochasticPrograms.EVP
StochasticPrograms.EVPI
StochasticPrograms.EVPI
StochasticPrograms.EWS
StochasticPrograms.EWS
StochasticPrograms.StochasticStructure
StochasticPrograms.VRP
StochasticPrograms.VRP
StochasticPrograms.VSS
StochasticPrograms.VSS
StochasticPrograms.WS
StochasticPrograms.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_auxiliary_variables
StochasticPrograms.all_decision_variables
StochasticPrograms.all_decision_variables
StochasticPrograms.all_decision_variables
StochasticPrograms.all_decision_variables
StochasticPrograms.all_known_decision_variables
StochasticPrograms.all_known_decision_variables
StochasticPrograms.cache_solution!
StochasticPrograms.clear!
StochasticPrograms.confidence_interval
StochasticPrograms.decision
StochasticPrograms.decision
StochasticPrograms.decision
StochasticPrograms.decision
StochasticPrograms.decision
StochasticPrograms.decision_by_name
StochasticPrograms.default_structure
StochasticPrograms.deferred
StochasticPrograms.distributed
StochasticPrograms.evaluate_decision
StochasticPrograms.evaluate_decision
StochasticPrograms.evaluate_decision
StochasticPrograms.expected
StochasticPrograms.expected
StochasticPrograms.expected_value_decision
StochasticPrograms.first_stage
StochasticPrograms.gap
StochasticPrograms.generate!
StochasticPrograms.generator
StochasticPrograms.has_generator
StochasticPrograms.instantiate
StochasticPrograms.instantiate
StochasticPrograms.instantiate
StochasticPrograms.instantiate
StochasticPrograms.lower_confidence_interval
StochasticPrograms.master_optimizer
StochasticPrograms.num_decisions
StochasticPrograms.num_decisions
StochasticPrograms.num_known_decisions
StochasticPrograms.num_scenarios
StochasticPrograms.num_stages
StochasticPrograms.num_subproblems
StochasticPrograms.optimal_decision
StochasticPrograms.optimal_decision
StochasticPrograms.optimal_decision
StochasticPrograms.optimal_decision
StochasticPrograms.optimal_recourse_decision
StochasticPrograms.optimizer
StochasticPrograms.optimizer
StochasticPrograms.optimizer_constructor
StochasticPrograms.optimizer_constructor
StochasticPrograms.optimizer_name
StochasticPrograms.optimizer_name
StochasticPrograms.outcome_model
StochasticPrograms.outcome_model
StochasticPrograms.probability
StochasticPrograms.probability
StochasticPrograms.probability
StochasticPrograms.probability
StochasticPrograms.proxy
StochasticPrograms.recourse_decision
StochasticPrograms.sample
StochasticPrograms.sample!
StochasticPrograms.sample!
StochasticPrograms.scenario
StochasticPrograms.scenario
StochasticPrograms.scenario_type
StochasticPrograms.scenario_types
StochasticPrograms.scenarios
StochasticPrograms.scenariotext
StochasticPrograms.set_probability!
StochasticPrograms.stage
StochasticPrograms.stage
StochasticPrograms.stage_model
StochasticPrograms.stage_one_model
StochasticPrograms.stage_parameters
StochasticPrograms.stage_probability
StochasticPrograms.state
StochasticPrograms.state
StochasticPrograms.state
StochasticPrograms.statistically_evaluate_decision
StochasticPrograms.structure
StochasticPrograms.structure_name
StochasticPrograms.subproblem
StochasticPrograms.subproblem
StochasticPrograms.subproblem_optimizer
StochasticPrograms.subproblems
StochasticPrograms.update_decisions!
StochasticPrograms.update_known_decisions!
StochasticPrograms.upper_confidence_interval
StochasticPrograms.upper_confidence_interval
StochasticPrograms.wait_and_see_decision
Constructors
StochasticPrograms.StochasticProgram
— TypeStochasticProgram
An instance of a stochastic optimization problem.
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 <: AbstractFloat
Create 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 <: AbstractScenario
Create 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 <: AbstractScenario
Create 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
— TypeDeterministic
Instantiates with the DeterministicEquivalent
structure.
See also: DeterministicEquivalent
StochasticPrograms.DistributedHorizontal
— TypeDistributedHorizontal
Instantiates with the ScenarioDecompositionStructure
on multiple cores.
See also: ScenarioDecompositionStructure
StochasticPrograms.DistributedScenarioDecomposition
— TypeDistributedScenarioDecomposition
Instantiates with the ScenarioDecompositionStructure
on multiple cores.
See also: ScenarioDecompositionStructure
StochasticPrograms.DistributedStageDecomposition
— TypeDistributedStageDecomposition
Instantiates with the StageDecompositionStructure
on multiple cores.
See also: StageDecompositionStructure
StochasticPrograms.DistributedVertical
— TypeDistributedVertical
Instantiates with the StageDecompositionStructure
on multiple cores.
See also: StageDecompositionStructure
StochasticPrograms.Horizontal
— TypeHorizontal
Instantiates with the ScenarioDecompositionStructure
on a single core.
See also: ScenarioDecompositionStructure
StochasticPrograms.ScenarioDecomposition
— TypeScenarioDecomposition
Instantiates with the ScenarioDecompositionStructure
on a single core.
See also: ScenarioDecompositionStructure
StochasticPrograms.StageDecomposition
— TypeStageDecomposition
Instantiates with the StageDecompositionStructure
on a single core.
See also: StageDecompositionStructure
StochasticPrograms.StochasticInstantiation
— TypeStochasticInstantiation
Abstract 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
— TypeUnspecifiedInstantiation
Default 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
— TypeVertical
Instantiates with the StageDecompositionStructure
on a single core.
See also: StageDecompositionStructure
StochasticPrograms.StochasticStructure
— FunctionStochasticStructure(scenario_types::ScenarioTypes{M}, instantiation::StochasticInstantiation) where M
Constructs 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 M
Constructs 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
— TypeDeterministicEquivalent
Deterministic equivalent memory structure. Stochastic program is stored as one large optimization problem. Supported by any standard AbstractOptimizer
.
StochasticPrograms.StageDecompositionStructure
— TypeStageDecompositionStructure
Vertical memory structure. Decomposes stochastic program by stages.
StochasticPrograms.ScenarioDecompositionStructure
— TypeScenarioDecompositionStructure
Horizontal memory structure. Decomposes stochastic program by scenario.
Decisions
StochasticPrograms.DecisionVariable
— TypeDecisionVariable <: AbstractVariableRef
Identifier 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, 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
— 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_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_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
.
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.VariableIndex
Return 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)::String
Get the name of the scenario-dependent decision variable dvar
in scenario scenario_index
.
JuMP.name
— Methodname(dvar::DecisionVariable, scenario_index::Integer)::String
Get the name of the decision variable dvar
.
JuMP.optimizer_index
— Methodoptimizer_index(dvar::DecisionVariable, scenario_index)::MOI.VariableIndex
Return 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.VariableIndex
Return the index of the variable that corresponds to dvar
in the optimizer model.
JuMP.reduced_cost
— Methodreduced_cost(dvar::DecisionVariable)::Float64
Return the reduced cost associated with the scenario-dependent decision variable dvar
at scenario_index
.
JuMP.reduced_cost
— Methodreduced_cost(dvar::DecisionVariable)::Float64
Return the reduced cost associated with the decision variable dvar
.
JuMP.relax_integrality
— Methodrelax_integrality(stochasticprogram::StochasticProgram)
Modifies stochasticprogram
to "relax" all binary and integrality constraints on decisions and auxiliary variables.
Returns a function that can be called without any arguments to restore the original stochasticprogram. The behavior of this function is undefined if additional changes are made to the affected decisions and variables in the meantime.
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 T
Evaluate 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.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
— TypeSPConstraintRef
Holds 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_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.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.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.ConstraintIndex
Return 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{Type, Type}}
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)::String
Get the name of the scenario-dependent decision constraint sp_cref
in scenario scenario_index
.
JuMP.name
— Methodname(sp_cref::SPConstraintRef)::String
Get 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)::Int64
Return 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.VariableIndex
Return 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.VariableIndex
Return 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.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.
JuMP.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.
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.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)::AbstractJuMPScalar
Return 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)::AbstractJuMPScalar
Return the type of the objective function of stochasticprogram
.
JuMP.objective_function_type
— Methodobjective_function_type(stochasticprogram::Stochasticprogram, stage::Integer)::AbstractJuMPScalar
Return the type of the objective function at stage stage
of stochasticprogram
.
JuMP.objective_sense
— Methodobjective_sense(stochasticprogram::StochasticProgram, stage::Integer, scenario_index::Integer)::MathOptInterface.OptimizationSense
Return the objective sense in the node at stage stage
and scenario scenario_index
.
JuMP.objective_sense
— Methodobjective_sense(stochasticprogram::StochasticProgram)::MathOptInterface.OptimizationSense
Return the objective sense of the stochasticprogram
.
JuMP.objective_sense
— Methodobjective_sense(stochasticprogram::StochasticProgram, stage::Integer)::MathOptInterface.OptimizationSense
Return 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 <: AbstractVariableRef
Holds a reference to the model, the stage the decision is taken in, and the corresponding MOI.VariableIndex.
JuMP.fix
— MethodStochasticPrograms.all_auxiliary_variables
— Methodall_auxiliary_variables(model::JuMP.Model)
Returns a list of all auxiliary variables currently in the decision model
through @variable
. The variables are ordered by creation time.
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::DecisionRef)
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
— TypeAbstractScenario
Abstract 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
— TypeProbability
A type-safe wrapper for Float64
used to represent probability of a scenario occuring.
StochasticPrograms.Scenario
— TypeScenario
Conveniece 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.@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]
end
The 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.@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
end
Examples
The following defines expectation for the example scenario defined in @scenario
@expectation begin
return ExampleScenario(sum([probability(s)*s.ξ for s in scenarios]))
end
See also @define_scenario
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.4
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.@zero
— Macro@zero(def)
Define the additive zero scenario inside a @scenario block using the syntax:
@zero begin
...
return zero_scenario
end
Examples
The following defines a zero scenario for the example scenario defined in @define_scenario
@zero begin
return ExampleScenario(0.0)
end
See also @define_scenario
StochasticPrograms.AbstractSampler
— TypeAbstractSampler
Abstract 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
— TypeSMPSScenario
Conveniece type that adheres to the AbstractScenario
abstraction. Obtained when reading scenarios specified in SMPS format.
See also: SMPSSampler
StochasticPrograms.SMPS.SMPSSampler
— TypeSMPSSampler
Sampler 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.4
StochasticPrograms.@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]
end
The 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
end
Examples
The following defines a zero scenario for the example scenario defined in @define_scenario
@zero begin
return ExampleScenario(0.0)
end
See 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
end
Examples
The following defines expectation for the example scenario defined in @scenario
@expectation begin
return ExampleScenario(sum([probability(s)*s.ξ for s in scenarios]))
end
See 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
end
Any 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
end
The 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(stochasticprogram, var) ...
@uncertain ξ
... JuMPdef ...
...
end
where stage
is the stage number and JuMP syntax is used inside the block to define the stage model. During definition, the stage model is referenced using the same variable name as stochasticprogram
.
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(sp, x₁ >= 40)
@decision(sp, x₂ >= 20)
@objective(sp, Min, 100*x₁ + 150*x₂)
@constraint(sp, x₁ + x₂ <= 120)
end
@stage 2 sp = begin
@uncertain q₁ q₂ d₁ d₂
@variable(sp, 0 <= y₁ <= d₁)
@variable(sp, 0 <= y₂ <= d₂)
@objective(sp, Max, q₁*y₁ + q₂*y₂)
@constraint(sp, 6*y₁ + 10*y₂ <= 60*x₁)
@constraint(sp, 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 matching the name of stochasticprogram
.
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(sp, x₁ >= 40)
@decision(sp, x₂ >= 20)
@objective(sp, Min, 100*x₁ + 150*x₂)
@constraint(sp, x₁ + x₂ <= 120)
end
See 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 ...
...
end
where 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 matching the name of stochasticprogram
.
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(sp, x₁, x₂)
@uncertain q₁ q₂ d₁ d₂
@variable(sp, 0 <= y₁ <= d₁)
@variable(sp, 0 <= y₂ <= d₂)
@objective(sp, Min, q₁*y₁ + q₂*y₂)
@constraint(sp, 6*y₁ + 10*y₂ <= 60*x₁)
@constraint(sp, 8*y₁ + 5*y₂ <= 80*x₂)
end
See 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
end
See 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
@stochastic_model model_name begin
...
@stage x begin
...
end
...
end
where 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. The model is referenced using model_name
in the @stage
blocks. If model_name
is left out, the macro returns an anonymous model object, and the reserved keyword model
must be used in the @stage
blocks. Otherwise, the resulting stochastic model object is stored in a variable named model_name
.
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 $ξ$.
@stochastic_model sm begin
@stage 1 begin
@decision(sm, x₁ >= 40)
@decision(sm, x₂ >= 20)
@objective(sm, Min, 100*x₁ + 150*x₂)
@constraint(sm, x₁ + x₂ <= 120)
end
@stage 2 begin
@uncertain q₁ q₂ d₁ d₂
@variable(sm, 0 <= y₁ <= d₁)
@variable(sm, 0 <= y₂ <= d₂)
@objective(sm, Min, q₁*y₁ + q₂*y₂)
@constraint(sm, 6*y₁ + 10*y₂ <= 60*x₁)
@constraint(sm, 8*y₁ + 5*y₂ <= 80*x₂)
end
end
or alternatively using anonymous syntax:
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
@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
end
where the reserved keyword model
is used throughout.
See 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.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
.
JuMP.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
.
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 a confidence interval around 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(), cache::Bool = false; 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. Setting the cache
flag to true will, upon sucessful termination, try to cache the solution values for all relevant attributes in the model. The values will then persist after future evaluate
calls that would otherwise overwrite the optimal solution.
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: 6
The 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 N
Returns 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 N
Returns a stage-wise list of all decisions currently in the stochasticprogram
. The decisions are ordered by creation time. Defaults to the first stage.
StochasticPrograms.cache_solution!
— Methodcache_solution!(stochasticprogram::StochasticProgram)
Cache the optimal solution, including as many model/variable/constraints attributes as possible, after a call to optimize!
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.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 <: AbstractScenario
Instantiate 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!(stochasticprogram::Stochasticprogram, stage::Integer, scenario_index::Integer)
Update all known decision values in the node at stage stage
and scenario scenario_index
of stochasticprogram
.
StochasticPrograms.update_known_decisions!
— Methodupdate_known_decisions!(stochasticprogram::Stochasticprogram)
Update all known decision values in the first-stage of 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 a optimal solution to stochasticprogram
has been determined, but cache_solution!
has not been called, then the solution will be overwritten by this call. 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}, 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.
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.
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 recourse 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