Finite Parameters

A technical manual for finite parameters in InfiniteOpt. See the respective guide for more information.

Definition

InfiniteOpt.@finite_parameterMacro
@finite_parameter(model::InfiniteModel, value, kwargs...)

Define and add an anonymous finite parameter to model and return its parameter reference. Its value is equal to value.

@finite_parameter(model::InfiniteModel, param_expr == value_expr, kwargs...)

Define and add a finite parameter(s) to model and return appropriate parameter reference(s). The parameter(s) has/have value(s) indicated by the value_expr. The expression param_expr can be of the form:

  • paramname creating a scalar parameter of name paramname
  • paramname[...] or [...] creating a container of parameters

The expression value_expr simply expresses the value of the parameter(s). This is typically a number but could be an array indexed using an index defined in param_expr.

The recognized keyword arguments in kwargs are the following:

  • base_name: Sets the name prefix used to generate parameter names. It corresponds to the parameter name for scalar parameter, otherwise, the parameter names are set to base_name[...] for each index ... of the axes axes.
  • container: Specify the container type, defaults to Auto.

Examples

julia> par = @finite_parameter(model, 2)
noname

julia> vals = [3, 2];

julia> pars = @finite_parameter(model, [i = 1:2] == vals[i], base_name = "par")
2-element Array{ParameterRef,1}:
 par[1]
 par[2]

julia> @finite_parameter(model, par2 == 42)
par2
source
InfiniteOpt.FiniteParameterType
FiniteParameter <: ScalarParameter

A DataType for storing finite parameters meant to be nested in expressions and replaced with their values at runtime.

Fields

  • value::Float64: The parameter value.
source
InfiniteOpt.build_parameterMethod
build_parameter(_error::Function, value::Real)::FiniteParameter

Returns a FiniteParameter given the appropriate information. This is analagous to JuMP.build_variable. This is meant to primarily serve as a helper method for @finite_parameter.

Example

julia> build_finite_parameter(error, 1)
FiniteParameter(1.0)
source
InfiniteOpt.add_parameterMethod
add_parameter(model::InfiniteModel, p::FiniteParameter,
              [name::String = ""])::GeneralVariableRef

Returns a GeneralVariableRef associated with the parameter p that is added to model. This adds a parameter to the model in a manner similar to JuMP.add_variable. This is to add parameters with the use of @finite_parameter. build_parameter should be used to construct p.

Example

julia> p = build_parameter(error, 42);

julia> param_ref = add_parameter(model, p, "name")
name
source
InfiniteOpt.FiniteParameterRefType
FiniteParameterRef <: FiniteRef

A DataType for finite parameters references who are replaced with their values at the transcription step.

Fields

  • model::InfiniteModel: Infinite model.
  • index::FiniteParameterIndex: Index of the parameter in model.
source

Methods

Many methods are shared with independent infinite parameters since both finite and independent infinite parameters are scalar. See the infinite parameter technical manual for the remainder of the methods available for finite parameters (i.e., any method typed for ScalarParameterRefs)

InfiniteOpt.parameter_valueMethod
parameter_value(pref::FiniteParameterRef)::Float64

Return the value of a finite parameter reference pref. Errors if it is an infinite parameter.

Example

julia> value(cost)
42.0
source
JuMP.set_valueMethod
JuMP.set_value(pref::FiniteParameterRef, value::Real)::Nothing

Set the value of pref so long as it is a finite parameter. Errors if it is an infinite parameter.

Example

julia> set_value(cost, 27)

julia> value(cost)
27.0
source