Variables
A technical manual for variables in InfiniteOpt
. See the respective guide for more information.
Definition
Note that the principle way for defining variables is by using JuMP.@variable
which originates from JuMP.jl
.
Infinite
InfiniteOpt.InfOptVariableType
— TypeInfOptVariableType
An abstract DataType
for variable type objects used to create InfiniteOpt
variables via JuMP.@variable
.
InfiniteOpt.Infinite
— TypeInfinite{VT <: VectorTuple} <: InfOptVariableType
A DataType
to assist in making infinite variables. This can be passed as an extra argument to @variable
to make an infinite variable:
@variable(model, var_expr, Infinite(parameter_refs...), args..., kwargs...)
Here parameter_refs
can be a single parameter reference, a single parameter array with parameters defined in the same macro call, or multiple arguments where each argument is either of the first two options listed.
Fields
parameter_refs::VT
: The infinite parameters the variable will depend on.
JuMP.build_variable
— MethodJuMP.build_variable(_error::Function, info::JuMP.VariableInfo,
var_type::Infinite)::InfiniteVariable{GeneralVariableRef}
Build and return an infinite variable based on info
and var_type
. Errors if the infinite parameter references included in var_type
are invalid. See Infinite
for more information.
Example
julia> info = VariableInfo(false, 0, false, 0, false, 0, true, 0, false, false);
julia> inf_var = build_variable(error, info, Infinite(t));
JuMP.add_variable
— MethodJuMP.add_variable(model::InfiniteModel, var::InfiniteVariable,
[name::String = ""])::GeneralVariableRef
Extend the JuMP.add_variable
function to accomodate infinite variable types. Adds a variable to an infinite model model
and returns a GeneralVariableRef
. Primarily intended to be an internal function of the constructor macro @variable
. However, it can be used in combination with JuMP.build_variable
to add infinite variables to an infinite model object. Errors if invalid parameter reference(s) are included in var
.
Example
julia> @infinite_parameter(m, t in [0, 10]);
julia> info = VariableInfo(false, 0, false, 0, false, 0, true, 0, false, false);
julia> inf_var = build_variable(error, info, Infinite(t));
julia> ivref = add_variable(m, inf_var, "var_name")
var_name(t)
InfiniteOpt.InfiniteVariable
— TypeInfiniteVariable{F <: Function, VT <: VectorTuple} <: JuMP.AbstractVariable
A DataType
for storing core infinite variable information. Note that indices that refer to the same dependent parameter group must be in the same tuple element. It is important to note that info.start
should contain a start value function that generates the start value for a given infinite parameter support. This function should map a support to a start value using user-formatting if is_vector_start = false
, otherwise it should do the mapping using a single support vector as input.
Fields
info::JuMP.VariableInfo{Float64, Float64, Float64, F}
: JuMP variable information. Here the start value is a function that maps the parameter values to a start value.parameter_refs::VT
: The infinite parameter references that parameterize the variable.parameter_nums::Vector{Int}
: The parameter numbers ofparameter_refs
.group_int_idxs::Vector{Int}
: The parameter group integer indices associated withparameter_refs
.is_vector_start::Bool
: Does the start function take support values formatted as vectors?
InfiniteOpt.restrict
— Functionrestrict(ivref::GeneralVariableRef, supps...)::GeneralVariableRef
Restrict the input domain of an infinite variable/derivative ivref
in accordance with the infinite parameters and/or values supps
. Here supps
must match the formatting of ivref
's infinite parameters. Here the following outputs are possible:
- Equivalent to
@variable(model, variable_type = Point(ivref, supps...)
ifsupps
are a complete support point - Equivalent to
@variable(model, variable_type = SemiInfinite(ivref, supps...)
ifsupps
are a partial support point.
Conveniently, we can also invoke this method by calling ivref(supps...)
.
Errors if ivref is not an infinite variable or derivative or the formatting of supps
is incorrect. Will warn if supps
only contain infinite parameters and will simply return ivref
.
Example
julia> restrict(y, 0, x)
y(0, [x[1], x[2]])
julia> restrict(y, 0, [0, 0])
y(0, [0, 0])
julia> y(0, x)
y(0, [x[1], x[2]])
julia> y(0, [0, 0])
y(0, [0, 0])
restrict(expr::JuMP.AbstractJuMPScalar, supps...)::JuMP.AbstractJuMPScalar
Restrict an infinite expression expr
to be enforced over infinite parameter supports supps
. This is limited to expressions only contain infinite variables with the same kind of infinite parameter dependencies. Note that more conveniently the expression can be treated as a function for the syntax expr(supps...)
.
Example
julia> ex = @expression(model, 3y - 2)
3 y(t) - 2
julia> restrict(ex, 0)
3 y(0) - 2
julia> ex(0)
3 y(0) - 2
InfiniteOpt.VariableData
— TypeVariableData{V <: JuMP.AbstractVariable} <: AbstractDataObject
A mutable DataType
for storing variables and their data.
Fields
variable::V
: The scalar variable.name::String
: The name used for printing.lower_bound_index::Union{InfOptConstraintIndex, Nothing}
: Index of lower bound constraint.upper_bound_index::Union{InfOptConstraintIndex, Nothing}
: Index of upper bound constraint.fix_index::Union{InfOptConstraintIndex, Nothing}
: Index on fixing constraint.zero_one_index::Union{InfOptConstraintIndex, Nothing}
: Index of binary constraint.integrality_index::Union{InfOptConstraintIndex, Nothing}
: Index of integer constraint.measure_indices::Vector{MeasureIndex}
: Indices of dependent measures.constraint_indices::Vector{InfOptConstraintIndex}
: Indices of dependent constraints.in_objective::Bool
: Is this used in objective?point_var_indices::Vector{PointVariableIndex}
: Indices of dependent point variables.semi_infinite_var_indices::Vector{SemiInfiniteVariableIndex}
: Indices of dependent semi-infinite variables.derivative_indices::Vector{DerivativeIndex}
: Indices of dependent derivatives.deriv_constr_indices::Vector{InfOptConstraintIndex}
: Indices of dependent derivative evaluation constraints.
InfiniteOpt.InfiniteVariableIndex
— TypeInfiniteVariableIndex <: ObjectIndex
A DataType
for storing the index of a InfiniteVariable
.
Fields
value::Int64
: The index value.
InfiniteOpt.InfiniteVariableRef
— TypeInfiniteVariableRef <: DispatchVariableRef
A DataType
for untranscripted infinite dimensional variable references (e.g., second stage variables, time dependent variables).
Fields
model::InfiniteModel
: Infinite model.index::InfiniteVariableIndex
: Index of the variable in model.
InfiniteOpt.Collections.VectorTuple
— TypeVectorTuple{T, I <: Tuple}
A collection DataType for storing a Tuple
of singular elements of type T
and/or AbstractArray{<:T}
s in a convenient vector form that utilizes linear indexing. Here I
is denotes the type of a Tuple
that stores the indices of each tuple element as given by indices
. VectorTuple
s should be defined from an original tuple via VectorTuple(tuple)
or by listing the tuple elements VectorTuple(items...)
. Note this is still an experimental type and is primarily intended to store infinite parameter reference tuples and point variable support value tuples. Some of the notable capabilities are exemplified below.
Example
julia> tuple = (3, [-2, 4], ones(2, 2))
(3, [-2, 4], [1.0 1.0; 1.0 1.0])
julia> vt = VectorTuple(tuple) # make by listing items (notice everything is a vector)
([3.0], [3.0, 4.0], [1.0, 1.0, 1.0, 1.0])
julia> vt[2] # linear indexing
-2.0
julia> vt[2, 2] # tuple indexing (note the second index is treated linearly)
4.0
julia> vt[6:end] # linear slicing
2-element Array{Float64,1}:
1.0
1.0
julia> vt[2:3, :] # tuple slicing
2-element Array{Array{Float64,1},1}:
[-2.0, 4.0]
[1.0, 1.0, 1.0, 1.0]
julia> tuple2 = Tuple(vt) # rebuild original Tuple with original indices
([3.0], [-2.0, 4.0], [1.0 1.0; 1.0 1.0])
julia> inds = [true, true, true, false, true, true, true];
julia> restricted_copy(vt, delete_locs) # make a copy with deleted elements
([3.0], [-2.0, 4.0], [1.0, 1.0, 1.0])
julia> Tuple(vt) # The 3rd element becomes a SparseAxisArray because of deletion
([3.0], [-2.0, 4.0], [1, 2] = 1.0
[2, 2] = 1.0
[2, 1] = 1.0)
Semi-Infinite
InfiniteOpt.SemiInfinite
— TypeSemiInfinite{V, VT <: VectorTuple} <: InfOptVariableType
A DataType
to assist in making semi-infinite variables. This can be passed as an extra argument to @variable
to make such a variable:
@variable(model, var_expr, SemiInfinite(inf_var, parameter_values...), kwargs...)
Here parameter_values
must match the format of the infinite parameter references associated with the infinite variable inf_var
and can be comprised of both real valued supports and/or infinite parameters.
Fields
infinite_variable_ref::V
parameter_values::VT
: The infinite parameters and/or infinite parameter support values the variable will depend on.
JuMP.build_variable
— MethodJuMP.build_variable(_error::Function, info::JuMP.VariableInfo,
var_type::SemiInfinite)::SemiInfiniteVariable{GeneralVariableRef}
Build and return a semi-infinite variable based on info
and var_type
. Errors if the information stored in var_type
is invalid. See SemiInfinite
for more information.
Example
julia> y
y(t, x)
julia> info = VariableInfo(false, 0, false, 0, false, 0, true, 0, false, false);
julia> semi_inf_var = build_variable(error, info, SemiInfinite(y, t, 0));
JuMP.build_variable
— MethodJuMP.build_variable(_error::Function, ivref::GeneralVariableRef,
eval_supports::Dict{Int, Float64}; [check::Bool = true]
)::SemiInfiniteVariable{GeneralVariableRef}
Extend the JuMP.build_variable
function to build a semi-infinite variable based on the infinite variable/derivative/parameter function ivref
with reduction support eval_supports
. Will check that input is appropriate if check = true
. Errors if ivref
is not an infinite variable, eval_supports
violate infinite parameter domains, or if the support dimensions don't match the infinite parameter dimensions of ivref
. This is intended an internal method for use in evaluating measures.
JuMP.add_variable
— MethodJuMP.add_variable(model::InfiniteModel, var::SemiInfiniteVariable,
[name::String = ""])::GeneralVariableRef
Extend the JuMP.add_variable
function to accomodate InfiniteOpt
semi-infinite variable types. Adds var
to the infinite model model
and returns a GeneralVariableRef
. Primarily intended to be an internal function used in evaluating measures.
InfiniteOpt.SemiInfiniteVariable
— TypeSemiInfiniteVariable{I <: GeneralVariableRef} <: JuMP.AbstractVariable
A DataType
for storing semi-infinite variables which partially support an infinite variable.
Fields
infinite_variable_ref::I
: The original infinite/derivvative variable.eval_supports::Dict{Int, Float64}
: The original parameter tuple linear indices to the evaluation supports.parameter_nums::Vector{Int}
: The parameter numbers associated with the evaluatedparameter_refs
.group_int_idxs::Vector{Int}
: The parameter group integer indices associated with the evaluatedparameter_refs
.
InfiniteOpt.SemiInfiniteVariableIndex
— TypeSemiInfiniteVariableIndex <: ObjectIndex
A DataType
for storing the index of a SemiInfiniteVariable
.
Fields
value::Int64
: The index value.
InfiniteOpt.SemiInfiniteVariableRef
— TypeSemiInfiniteVariableRef <: DispatchVariableRef
A DataType
for partially transcripted infinite dimensional variable references. This is used to expand measures that contain infinite variables that are not fully transcripted by the measure.
Fields
model::InfiniteModel
: Infinite model.index::SemiInfiniteVariableIndex
: Index of the variable in model.
Point
InfiniteOpt.Point
— TypePoint{V, VT <: VectorTuple} <: InfOptVariableType
A DataType
to assist in making point variables. This can be passed as an extra argument to @variable
to make such a variable:
@variable(model, var_expr, Point(inf_var, parameter_values...), args...,
kwargs...)
Here parameter_values
must match the format of the infinite parameter references associated with the infinite variable inf_var
and can be comprised of both real valued supports.
Fields
infinite_variable_ref::V
parameter_values::VT
: The infinite parameter support values the variable will depend on.
JuMP.build_variable
— MethodJuMP.build_variable(_error::Function, info::JuMP.VariableInfo,
var_type::Point)::InfiniteVariable{GeneralVariableRef}
Build and return a point variable based on info
and var_type
. Errors if the information stored in var_type
is invalid. See Point
for more information.
Example
julia> y
y(t)
julia> info = VariableInfo(false, 0, false, 0, false, 0, true, 0, false, false);
julia> pt_var = build_variable(error, info, SemiInfinite(y, 0));
JuMP.add_variable
— MethodJuMP.add_variable(model::InfiniteModel, var::PointVariable,
[name::String = ""])::GeneralVariableRef
Extend the JuMP.add_variable
function to accomodate PointVariable
variable types. Adds a variable to an infinite model model
and returns a GeneralVariableRef
. Primarily intended to be an internal function of the constructor macro @variable
. However, it can be used in combination with JuMP.build_variable
to add variables to an infinite model object. Errors if an invalid infinite variable reference is included in var
.
Example
julia> @infinite_parameter(m, t in [0, 10]);
julia> info = VariableInfo(false, 0, false, 0, false, 0, true, 0, false, false);
julia> inf_var = build_variable(error, info, Infinite(t));
julia> ivref = add_variable(m, inf_var, "var_name")
var_name(t)
julia> pt_var = build_variable(error, info, Point(ivref, 0.5));
julia> pvref = add_variable(m, pt_var, "var_alias")
var_alias
InfiniteOpt.PointVariable
— TypePointVariable{I <: GeneralVariableRef} <: JuMP.AbstractVariable
A DataType
for storing point variable information. Note that the elements parameter_values
field must match the format of the parameter reference tuple defined in InfiniteVariable
Fields
info::JuMP.VariableInfo{Float64, Float64, Float64, Float64}
: JuMP Variable information.infinite_variable_ref::I
: The infinite variable/derivative reference associated with the point variable.parameter_values::Vector{Float64}
: The infinite parameter values defining the point.
InfiniteOpt.PointVariableIndex
— TypePointVariableIndex <: ObjectIndex
A DataType
for storing the index of a PointVariable
.
Fields
value::Int64
: The index value.
InfiniteOpt.PointVariableRef
— TypePointVariableRef <: FiniteRef
A DataType
for variables defined at a transcipted point (e.g., second stage variable at a particular scenario, dynamic variable at a discretized time point).
Fields
model::InfiniteModel
: Infinite model.index::PointVariableIndex
: Index of the variable in model.
Finite
Note that finite variables simply correspond to using JuMP.ScalarVariable
which originates from JuMP.jl
as well. In other words, these are defined via JuMP.@variable
without specifying any InfOptVariableType
.
JuMP.add_variable
— MethodJuMP.add_variable(model::InfiniteModel, var::JuMP.ScalarVariable,
[name::String = ""])::GeneralVariableRef
Extend the JuMP.add_variable
function to accomodate finite (scalar) variable types. Adds a variable to an infinite model model
and returns a GeneralVariableRef
. Primarily intended to be an internal function of the constructor macro @variable
. However, it can be used in combination with JuMP.build_variable
to add finite variables to an infinite model object.
Examples
julia> f_var = build_variable(error, info);
julia> fvref = add_variable(m, f_var, "var_name")
var_name
InfiniteOpt.FiniteVariableIndex
— TypeFiniteVariableIndex <: ObjectIndex
A DataType
for storing the index of a JuMP.ScalarVariable
.
Fields
value::Int64
: The index value.
InfiniteOpt.FiniteVariableRef
— TypeFiniteVariableRef <: FiniteRef
A DataType
for finite fixed variable references (e.g., first stage variables, steady-state variables).
Fields
model::InfiniteModel
: Infinite model.index::FiniteVariableIndex
: Index of the variable in model.
Queries
General
JuMP.name
— MethodJuMP.name(vref::DecisionVariableRef)::String
Extend JuMP.name
to return the names of InfiniteOpt
variables.
Example
julia> name(vref)
"var_name"
JuMP.variable_by_name
— MethodJuMP.variable_by_name(model::InfiniteModel,
name::String)::Union{GeneralVariableRef, Nothing}
Extend JuMP.variable_by_name
for InfiniteModel
objects. Return the variable reference assoociated with a variable name. Errors if multiple variables have the same name. Returns nothing if no such name exists.
Examples
julia> variable_by_name(m, "var_name")
var_name
julia> variable_by_name(m, "fake_name")
JuMP.num_variables
— MethodJuMP.num_variables(model::InfiniteModel, [type])::Int
Extend JuMP.num_variables
to return the number of InfiniteOpt
variables assigned to model
. By default, the total number of infinite, semi-infinite, point, and finite variables is returned. The amount of a particular type is obtained by specifying the concrete variable type via type
. Type options include:
InfiniteVariable
: all infinite variablesSemiInfiniteVariable
: all semi-infinite variablesPointVariable
: all point variablesFiniteVariable
: all finite variables
Example
julia> num_variables(model)
3
julia> num_variables(model, InfiniteVariable)
2
JuMP.all_variables
— MethodJuMP.all_variables(model::InfiniteModel, [type])::Vector{GeneralVariableRef}
Extend JuMP.all_variables
] to return a list of all the variable references associated with model
. By default, all of the infinite, semi-infinite, point, and finite variables is returned. Those of a particular type is obtained by specifying the concrete variable type via type
. Type options include:
InfiniteVariable
: all infinite variablesSemiInfiniteVariable
: all semi-infinite variablesPointVariable
: all point variablesFiniteVariable
: all finite variables
Examples
julia> all_variables(model)
4-element Array{GeneralVariableRef,1}:
y(t)
w(t, x)
y(0)
z
julia> all_variables(model, PointVariable)
1-element Array{GeneralVariableRef,1}:
y(0)
JuMP.has_lower_bound
— MethodJuMP.has_lower_bound(vref::UserDecisionVariableRef)::Bool
Extend JuMP.has_lower_bound
to return a Bool
whether an InfiniteOpt
variable has a lower bound.
Example
julia> has_lower_bound(vref)
true
JuMP.lower_bound
— MethodJuMP.lower_bound(vref::UserDecisionVariableRef)::Float64
Extend JuMP.lower_bound
to return the lower bound of an InfiniteOpt
variable. Errors if vref
doesn't have a lower bound.
Example
julia> lower_bound(vref)
0.0
JuMP.LowerBoundRef
— MethodJuMP.LowerBoundRef(vref::UserDecisionVariableRef)::InfOptConstraintRef
Extend JuMP.LowerBoundRef
to extract a constraint reference for the lower bound of vref
.
Example
var ≥ 0.0
JuMP.has_upper_bound
— MethodJuMP.has_upper_bound(vref::UserDecisionVariableRef)::Bool
Extend JuMP.has_upper_bound
to return a Bool
whether an InfiniteOpt
variable has an upper bound.
Example
julia> has_upper_bound(vref)
true
JuMP.upper_bound
— MethodJuMP.upper_bound(vref::UserDecisionVariableRef)::Float64
Extend JuMP.upper_bound
to return the upper bound of an InfiniteOpt
variable. Errors if vref
doesn't have a upper bound.
Example
julia> upper_bound(vref)
0.0
JuMP.UpperBoundRef
— MethodJuMP.UpperBoundRef(vref::UserDecisionVariableRef)::InfOptConstraintRef
Extend JuMP.UpperBoundRef
to extract a constraint reference for the upper bound of vref
.
Example
julia> cref = UpperBoundRef(vref)
var ≤ 1.0
JuMP.is_fixed
— MethodJuMP.is_fixed(vref::UserDecisionVariableRef)::Bool
Extend JuMP.is_fixed
to return Bool
whether an InfiniteOpt
variable is fixed.
Example
julia> is_fixed(vref)
true
JuMP.fix_value
— MethodJuMP.fix_value(vref::UserDecisionVariableRef)::Float64
Extend JuMP.fix_value
to return the fix value of an InfiniteOpt
variable. Errors if variable is not fixed.
Example
julia> fix_value(vref)
0.0
JuMP.FixRef
— MethodJuMP.FixRef(vref::UserDecisionVariableRef)::InfOptConstraintRef
Extend JuMP.FixRef
to return the constraint reference of the fix constraint associated with vref
. Errors vref
is not fixed.
Examples
julia> cref = FixRef(vref)
var = 1.0
JuMP.start_value
— MethodJuMP.start_value(vref::UserDecisionVariableRef)::Union{Nothing, Float64}
Extend JuMP.start_value
to return starting value of InfiniteOpt
variable if it has one. Returns nothing
otherwise.
Example
julia> start_value(vref)
0.0
JuMP.is_binary
— MethodJuMP.is_binary(vref::UserDecisionVariableRef)::Bool
Extend JuMP.is_binary
to return Bool
whether an InfiniteOpt
variable is binary.
Example
true
JuMP.BinaryRef
— MethodJuMP.BinaryRef(vref::UserDecisionVariableRef)::InfOptConstraintRef
Extend JuMP.BinaryRef
to return a constraint reference to the constraint constrainting vref
to be binary. Errors if one does not exist.
Example
julia> cref = BinaryRef(vref)
var binary
JuMP.is_integer
— MethodJuMP.is_integer(vref::UserDecisionVariableRef)::Bool
Extend JuMP.is_integer
to return Bool
whether an InfiniteOpt
variable is integer.
Example
julia> is_integer(vref)
true
JuMP.IntegerRef
— MethodJuMP.IntegerRef(vref::UserDecisionVariableRef)::InfOptConstraintRef
Extend JuMP.IntegerRef
to return a constraint reference to the constraint constrainting vref
to be integer. Errors if one does not exist.
Example
julia> cref = IntegerRef(vref)
var integer
InfiniteOpt.is_used
— Methodis_used(vref::DecisionVariableRef)::Bool
Return a Bool
indicating if vref
is used in the model.
Example
julia> is_used(vref)
true
InfiniteOpt.used_by_constraint
— Methodused_by_constraint(vref::DecisionVariableRef)::Bool
Return a Bool
indicating if vref
is used by a constraint.
Example
julia> used_by_constraint(vref)
false
InfiniteOpt.used_by_measure
— Methodused_by_measure(vref::DecisionVariableRef)::Bool
Return a Bool
indicating if vref
is used by a measure.
Example
julia> used_by_measure(vref)
true
InfiniteOpt.used_by_objective
— Methodused_by_objective(vref::DecisionVariableRef)::Bool
Return a Bool
indicating if vref
is used by the objective.
Example
julia> used_by_objective(vref)
true
Infinite
InfiniteOpt.start_value_function
— Methodstart_value_function(vref::Union{InfiniteVariableRef, DerivativeRef})::Union{Nothing, Function}
Return the function that is used to generate the start values of vref
for particular support values. Returns nothing
if no start behavior has been specified.
Example
julia> start_value_function(vref)
my_start_func
InfiniteOpt.parameter_refs
— Methodparameter_refs(vref::InfiniteVariableRef)::Tuple
Return the parameter references associated with the infinite variable vref
. This is formatted as a Tuple of containing the parameter references as they inputted to define vref
.
Example
julia> @variable(model, T, Infinite(t))
T(t)
julia> parameter_refs(T)
(t,)
InfiniteOpt.parameter_list
— Methodparameter_list(vref::InfiniteVariableRef)::Vector{GeneralVariableRef}
Return a vector of the parameter references that vref
depends on. This is primarily an internal method where parameter_refs
is intended as the preferred user function.
InfiniteOpt.raw_parameter_refs
— Methodraw_parameter_refs(vref::InfiniteVariableRef)::VectorTuple
Return the raw VectorTuple
of the parameter references that vref
depends on. This is primarily an internal method where parameter_refs
is intended as the preferred user function.
InfiniteOpt.is_used
— Methodis_used(vref::Union{InfiniteVariableRef, DerivativeRef})::Bool
Return a Bool
indicating if vref
is used in the model.
Example
julia> is_used(vref)
false
InfiniteOpt.used_by_derivative
— Methodused_by_derivative(vref::Union{InfiniteVariableRef, DerivativeRef})::Bool
Return a Bool
indicating if vref
is used by a derivative.
Example
julia> used_by_derivative(vref)
true
InfiniteOpt.used_by_point_variable
— Methodused_by_point_variable(vref::Union{InfiniteVariableRef, DerivativeRef})::Bool
Return a Bool
indicating if vref
is used by a point variable.
Example
julia> used_by_point_variable(vref)
false
InfiniteOpt.used_by_semi_infinite_variable
— Methodused_by_semi_infinite_variable(vref::Union{InfiniteVariableRef, DerivativeRef})::Bool
Return a Bool
indicating if vref
is used by a semi-infinite variable.
Example
julia> used_by_semi_infinite_variable(vref)
false
InfiniteOpt.parameter_group_int_indices
— Methodparameter_group_int_indices(vref::InfiniteVariableRef)::Vector{Int}
Return the list of infinite parameter group integer indices used by vref
.
InfiniteOpt.core_object
— Methodcore_object(vref::InfiniteVariableRef)::InfiniteVariable
Retrieve the underlying core InfiniteVariable
object for vref
. This is intended as an advanced method for developers.
Semi-Infinite
JuMP.has_lower_bound
— MethodJuMP.has_lower_bound(vref::SemiInfiniteVariableRef)::Bool
Extend JuMP.has_lower_bound
to return a Bool
whether the original infinite variable of vref
has a lower bound.
Example
julia> has_lower_bound(vref)
true
JuMP.lower_bound
— MethodJuMP.lower_bound(vref::SemiInfiniteVariableRef)::Float64
Extend JuMP.lower_bound
to return the lower bound of the original infinite variable of vref
. Errors if vref
doesn't have a lower bound.
Example
julia> lower_bound(vref)
0.0
JuMP.LowerBoundRef
— MethodJuMP.LowerBoundRef(vref::SemiInfiniteVariableRef)::InfOptConstraintRef
Extend JuMP.LowerBoundRef
to extract a constraint reference for the lower bound of the original infinite variable of vref
.
Example
julia> cref = LowerBoundRef(vref)
var >= 0.0
JuMP.has_upper_bound
— MethodJuMP.has_upper_bound(vref::SemiInfiniteVariableRef)::Bool
Extend JuMP.has_upper_bound
to return a Bool
whether the original infinite variable of vref
has an upper bound.
Example
julia> has_upper_bound(vref)
true
JuMP.upper_bound
— MethodJuMP.upper_bound(vref::SemiInfiniteVariableRef)::Float64
Extend JuMP.upper_bound
to return the upper bound of the original infinite variable of vref
. Errors if vref
doesn't have a upper bound.
Example
julia> upper_bound(vref)
0.0
JuMP.UpperBoundRef
— MethodJuMP.UpperBoundRef(vref::SemiInfiniteVariableRef)::InfOptConstraintRef
Extend JuMP.UpperBoundRef
to extract a constraint reference for the upper bound of the original infinite variable of vref
.
Example
julia> cref = UpperBoundRef(vref)
var <= 1.0
JuMP.is_fixed
— MethodJuMP.is_fixed(vref::SemiInfiniteVariableRef)::Bool
Extend JuMP.is_fixed
to return Bool
whether the original infinite variable of vref
is fixed.
Example
julia> is_fixed(vref)
true
JuMP.fix_value
— MethodJuMP.fix_value(vref::SemiInfiniteVariableRef)::Float64
Extend JuMP.fix_value
to return the fix value of the original infinite variable of vref
. Errors if variable is not fixed.
Example
julia> fix_value(vref)
0.0
JuMP.FixRef
— MethodJuMP.FixRef(vref::SemiInfiniteVariableRef)::InfOptConstraintRef
Extend JuMP.FixRef
to return the constraint reference of the fix constraint associated with the original infinite variable of vref
. Errors vref
is not fixed.
Examples
julia> cref = FixRef(vref)
var == 1.0
InfiniteOpt.start_value_function
— Methodstart_value_function(vref::SemiInfiniteVariableRef)::Union{Nothing, Function}
Return the function that is used to generate the start values of vref
for particular support values. Returns nothing
if no start behavior has been specified.
Example
julia> start_value_func(vref)
my_func
JuMP.is_binary
— MethodJuMP.is_binary(vref::SemiInfiniteVariableRef)::Bool
Extend JuMP.is_binary
to return Bool
whether the original infinite variable of vref
is binary.
Example
julia> is_binary(vref)
true
JuMP.BinaryRef
— MethodJuMP.BinaryRef(vref::SemiInfiniteVariableRef)::InfOptConstraintRef
Extend JuMP.BinaryRef
to return a constraint reference to the constraint constrainting the original infinite variable of vref
to be binary. Errors if one does not exist.
Example
julia> cref = BinaryRef(vref)
var binary
JuMP.is_integer
— MethodJuMP.is_integer(vref::SemiInfiniteVariableRef)::Bool
Extend JuMP.is_integer
to return Bool
whether the original infinite variable of vref
is integer.
Example
julia> is_integer(vref)
true
JuMP.IntegerRef
— MethodJuMP.IntegerRef(vref::SemiInfiniteVariableRef)::InfOptConstraintRef
Extend JuMP.IntegerRef
to return a constraint reference to the constraint constrainting the original infinite variable of vref
to be integer. Errors if one does not exist.
Example
julia> cref = IntegerRef(vref)
var integer
InfiniteOpt.infinite_variable_ref
— Methodinfinite_variable_ref(vref::SemiInfiniteVariableRef)::GeneralVariableRef
Return the infinite variable/derivative/parameter function reference associated with the semi-infinite variable vref
.
Example
julia> infinite_variable_ref(vref)
g(t, x)
InfiniteOpt.parameter_refs
— Methodparameter_refs(vref::SemiInfiniteVariableRef)::Tuple
Return the infinite parameter references associated with the semi-infinite variable vref
. This is formatted as a Tuple
of containing the parameter references as they were inputted to define the untranscripted infinite variable except, the evaluated parameters are excluded.
Example
julia> parameter_refs(vref)
(t, [x[1], x[2]])
InfiniteOpt.parameter_list
— Methodparameter_list(vref::SemiInfiniteVariableRef)::Vector{GeneralVariableRef}
Return a vector of the parameter references that vref
depends on. This is primarily an internal method where parameter_refs
is intended as the preferred user function.
InfiniteOpt.raw_parameter_refs
— Methodraw_parameter_refs(vref::Union{SemiInfiniteVariableRef, SemiInfiniteVariable})::VectorTuple
Return the raw VectorTuple
of the parameter references that vref
depends on. This is primarily an internal method where parameter_refs
is intended as the preferred user function.
InfiniteOpt.eval_supports
— Methodeval_supports(vref::SemiInfiniteVariableRef)::Dict{Int, Float64}
Return the evaluation supports associated with the semi-infinite variable vref
.
Example
julia> eval_supports(vref)
Dict{Int64,Float64} with 1 entry:
1 => 0.5
InfiniteOpt.is_used
— Methodis_used(vref::SemiInfiniteVariableRef)::Bool
Return a Bool
indicating if vref
is used in the model.
Example
julia> is_used(vref)
true
InfiniteOpt.used_by_derivative
— Methodused_by_derivative(vref::SemiInfiniteVariableRef)::Bool
Return a Bool
indicating if vref
is used by a derivative.
Example
julia> used_by_derivative(vref)
true
InfiniteOpt.parameter_group_int_indices
— Methodparameter_group_int_indices(vref::SemiInfiniteVariableRef)::Vector{Int}
Return the list of infinite parameter group integer indices used by vref
.
InfiniteOpt.core_object
— Methodcore_object(vref::SemiInfiniteVariableRef)::SemiInfiniteVariable
Retrieve the underlying core [SemiInfiniteVariable
] object for vref
. This is intended as an advanced method for developers.
Point
InfiniteOpt.infinite_variable_ref
— Methodinfinite_variable_ref(vref::PointVariableRef)::GeneralVariableRef
Return the InfiniteVariableRef
associated with the point variable vref
.
Example
julia> @variable(model, T, Infinite(t))
T(t)
julia> @variable(model, T0, Point(T, 0))
T0
julia> infinite_variable_ref(T0)
T(t)
InfiniteOpt.parameter_values
— Methodparameter_values(vref::PointVariableRef)::Tuple
Return the support point associated with the point variable vref
.
Example
julia> @variable(model, T, Infinite(t))
T(t)
julia> @variable(model, T0, Point(T, 0))
T0
julia> parameter_values(T0)
(0,)
InfiniteOpt.raw_parameter_values
— Methodraw_parameter_values(vref::PointVariableRef)::Vector{Float64}
Return the raw support point values associated with the point variable vref
.
InfiniteOpt.core_object
— Methodcore_object(vref::PointVariableRef)::PointVariable
Retrieve the underlying core [PointVariable
] object for vref
. This is intended as an advanced method for developers.
Finite
InfiniteOpt.core_object
— Methodcore_object(vref::FiniteVariableRef)::JuMP.ScalarVariable
Retrieve the underlying core JuMP.ScalarVariable
object for vref
. This is intended as an advanced method for developers.
Modification
General
JuMP.set_name
— MethodJuMP.set_name(vref::DecisionVariableRef, name::String)::Nothing
Extend JuMP.set_name
to set names of decision variables.
Example
julia> set_name(vref, "var_name")
julia> name(vref)
"var_name"
JuMP.set_lower_bound
— MethodJuMP.set_lower_bound(vref::UserDecisionVariableRef, lower::Real)::Nothing
Extend JuMP.set_lower_bound
to specify the lower bound of an InfiniteOpt
variable vref
. Errors if vref
is fixed.
Example
julia> set_lower_bound(vref, -1)
julia> lower_bound(vref)
-1.0
JuMP.delete_lower_bound
— MethodJuMP.delete_lower_bound(vref::UserDecisionVariableRef)::Nothing
Extend JuMP.delete_lower_bound
to delete lower bound of vref
. Errors if it doesn't have a lower bound.
Example
julia> delete_lower_bound(vref)
julia> has_lower_bound(vref)
false
JuMP.set_upper_bound
— MethodJuMP.set_upper_bound(vref::UserDecisionVariableRef, upper::Real)::Nothing
Extend JuMP.set_upper_bound
to specify the upper bound of an InfiniteOpt
variable vref
. Errors if vref
is fixed.
Example
julia> set_upper_bound(vref, 1)
julia> upper_bound(vref)
1.0
JuMP.delete_upper_bound
— MethodJuMP.delete_upper_bound(vref::UserDecisionVariableRef)::Nothing
Extend JuMP.delete_upper_bound
to delete the upper bound of vref
. Errors if it doesn't have an upper bound.
Example
julia> delete_upper_bound(vref)
julia> has_upper_bound(vref)
false
JuMP.fix
— MethodJuMP.fix(vref::UserDecisionVariableRef, value::Real;
force::Bool = false)::Nothing
Extend JuMP.fix
to fix the value of an InfiniteOpt
variable. Errors if variable has a lower and/or an upper bound(s) unless force = true
.
Examples
julia> fix(vref, 3)
julia> fix_value(vref)
3.0
julia> fix(vref2, 2, force = true)
julia> fix_value(vref2)
2.0
JuMP.unfix
— MethodJuMP.unfix(vref::UserDecisionVariableRef)::Nothing
Extend JuMP.unfix
to unfix vref
. Errors if it is not fixed.
Example
julia> unfix(vref)
julia> is_fixed(vref)
false
JuMP.set_start_value
— MethodJuMP.set_start_value(vref::UserDecisionVariableRef, value::Real)::Nothing
Extend JuMP.set_start_value
to specify the start value of InfiniteOpt
variables.
Example
julia> set_start_value(vref, 1)
julia> start_value(vref)
1.0
JuMP.set_binary
— MethodJuMP.set_binary(vref::UserDecisionVariableRef)::Nothing
Extend JuMP.set_binary
to specify an InfiniteOpt
variable as a binary variable. Errors if vref
is an integer variable.
Example
julia> set_binary(vref)
julia> is_binary(vref)
true
JuMP.unset_binary
— MethodJuMP.unset_binary(vref::UserDecisionVariableRef)::Nothing
Extend JuMP.unset_binary
to unset vref
as a binary variable. Errors if it is not binary.
julia> unset_binary(vref)
julia> is_binary(vref)
false
JuMP.set_integer
— MethodJuMP.set_integer(vref::UserDecisionVariableRef)::Nothing
Extend JuMP.set_integer
to specify an InfiniteOpt
variable as a integer variable. Errors if vref
is an binary variable.
Example
julia> set_integer(vref)
julia> is_integer(vref)
true
JuMP.unset_integer
— MethodJuMP.unset_integer(vref::UserDecisionVariableRef)::Nothing
Extend JuMP.unset_integer
to unset vref
as an integer variable. Errors if it is not an integer variable.
julia> unset_integer(vref)
julia> is_integer(vref)
false
JuMP.relax_integrality
— MethodJuMP.relax_integrality(model::InfiniteModel)::Function
Modifies model
to "relax" all binary and integrality constraints on variables. Specifically,
- Binary constraints are deleted, and variable bounds are tightened if necessary to ensure the variable is constrained to the interval $[0, 1]$.
- Integrality constraints are deleted without modifying variable bounds.
- All other constraints are ignored (left in place). This includes discrete constraints like SOS and indicator constraints.
Returns a function that can be called without any arguments to restore the original model. The behavior of this function is undefined if additional changes are made to the affected variables in the meantime.
Example
julia> undo_relax = relax_integrality(model);
julia> print(model)
Min x + ∫{t ∈ [0, 10]}(y(t))
Subject to
x ≥ 0.0
y(t) ≥ 1.0
x ≤ 1.0
y(t) ≤ 10.0
julia> undo_relax()
julia> print(model)
Min x + ∫{t ∈ [0, 10]}(y(t))
Subject to
y(t) ≥ 1.0
y(t) ≤ 10.0
y(t) integer
x binary
JuMP.delete
— MethodJuMP.delete(model::InfiniteModel, vref::DecisionVariableRef)::Nothing
Extend JuMP.delete
to delete InfiniteOpt
variables and their dependencies. Errors if variable is invalid, meaning it has already been deleted or it belongs to another model.
Example
julia> print(model)
Min measure(g(t)*t) + z
Subject to
z ≥ 0.0
g(t) + z ≥ 42.0, ∀ t ∈ [0, 6]
g(0.5) = 0
julia> delete(model, g)
julia> print(model)
Min measure(t) + z
Subject to
z ≥ 0.0
z ≥ 42.0
Infinite
InfiniteOpt.set_start_value_function
— Methodset_start_value_function(vref::InfiniteVariableRef,
start::Union{Real, Function})::Nothing
Set the start value function of vref
. If start::Real
then a function is generated to such that the start value will be start
for the entire infinite domain. If start::Function
then this function should map to a scalar start value given a support value arguments matching the format of the parameter elements in parameter_refs(vref)
.
Example
julia> set_start_value_function(vref, 1) # all start values will be 1
julia> set_start_value_function(vref, my_func) # each value will be made via my_func
InfiniteOpt.reset_start_value_function
— Methodreset_start_value_function(vref::InfiniteVariableRef)::Nothing
Remove the existing start value function and return to the default. Generally, this is triggered by deleting an infinite parameter that vref
depends on.
Example
julia> reset_start_value_function(vref)
InfiniteOpt.constant_over_collocation
— Methodconstant_over_collocation(vref::InfiniteVariableRef, pref::GeneralVariableRef)::Nothing
Adds constraints such that vref
is constant over internal collocation points generated within finite elements for pref
. This is prinicipally useful for manipulated variables in control problems that use OrthogonalCollocation
. Errors if pref
is not a single independent infinite parameter and/or it is not used by vref
.
Example
@infinite_parameter(model, t in [0, 1], deriviative_method = OrthogonalCollocation(3))
@variable(model, y_state, Infinite(t))
@variable(model, y_control, Infinite(t))
@constraint(model, ∂(y_state, t) == y_state^2)
@constraint(model, y_state(0) == 0)
constant_over_collocation(y_control, t)
Semi-Infinite
JuMP.set_name
— MethodJuMP.set_name(vref::DecisionVariableRef, name::String)::Nothing
Extend JuMP.set_name
to set names of decision variables.
Example
julia> set_name(vref, "var_name")
julia> name(vref)
"var_name"