Infinite Models
A technical manual for infinite dimensional models. See the respective guide for more information.
Models
InfiniteOpt.InfiniteModel — Type
InfiniteModel <: JuMP.AbstractModelA DataType for storing all of the mathematical modeling information needed to model an optmization problem with an infinite-dimensional decision space.
InfiniteOpt.InfiniteModel — Method
InfiniteModel([backend::AbstractTransformationBackend = TranscriptionBackend()])Return a new infinite model that uses backend. For the default case with TranscriptionBackend, the opimizer_constructor and other arguments can be given directly:
InfiniteModel(
optimizer_constructor;
[add_bridges::Bool = true]
)where optimizer_constructor and add_bridges are passed on to the underying JuMP Model.
A different transformation backend can be specified later on using set_transformation_backend.
Example
julia> using InfiniteOpt, JuMP, Ipopt;
julia> model = InfiniteModel()
An InfiniteOpt Model
Feasibility problem with:
Finite parameters: 0
Infinite parameters: 0
Variables: 0
Derivatives: 0
Measures: 0
Transformation backend information:
Backend type: TranscriptionBackend
Solver: none
Transformation built and up-to-date: false
julia> model = InfiniteModel(Ipopt.Optimizer)
An InfiniteOpt Model
Feasibility problem with:
Finite parameters: 0
Infinite parameters: 0
Variables: 0
Derivatives: 0
Measures: 0
Transformation backend information:
Backend type: TranscriptionBackend
Solver: Ipopt
Transformation built and up-to-date: falseJuMP.object_dictionary — Method
JuMP.object_dictionary(model::InfiniteModel)::Dict{Symbol, Any}Return the dictionary that maps the symbol name of a macro defined object (e.g., a parameter, variable, or constraint) to the corresponding object. Objects are registered to a specific symbol in the macros. For example, @variable(model, x[1:2, 1:2]) registers the array of variables x to the symbol :x.
InfiniteOpt.has_internal_supports — Function
has_internal_supports(pref::Union{IndependentParameterRef, DependentParameterRef})::BoolIndicate if pref has internal supports that will be hidden from the user by default.
has_internal_supports(prefs; [kwargs...])Define has_internal_supports for general variable references. It relies on has_internal_supports being defined for the underlying DispatchVariableRef, otherwise an ArgumentError is thrown. See the underlying docstrings for more information. Note that this is a auto generated wrapper and the underlying method may or may not use kwargs.
Base.empty! — Method
Base.empty!(model::InfiniteModel)::InfiniteModelClear out model of everything except the optimizer information and return the cleared model.
JuMP.set_optimize_hook — Method
JuMP.set_optimize_hook(
model::InfiniteModel,
hook::Union{Function, Nothing}
)::NothingSet the function hook as the optimize hook for model where hook should have be of the form hook(model::InfiniteModel; hook_specfic_kwargs..., kwargs...). The kwargs are those passed to optimize!. The hook_specifc_kwargs are passed as additional keywords by the user when they call optimize!.
Notes
- The optimize hook should generally modify the model, or some external state
in some way, and then call optimize!(model; ignore_optimize_hook = true) to optimize the problem, bypassing the hook.
- Use
set_optimize_hook(model, nothing)to unset an optimize hook.
InfiniteOpt.parameter_refs — Method
parameter_refs(model::InfiniteModel)::TupleReturns a tuple of the infinite parameters used by model.
For developers, note that the integer index of each element is what is referred to as an infinite parameter group integer index which corresponds to parameter_group_int_indices.
Example
julia> parameter_refs(model)
(t, x)InfiniteOpt.parameter_group_indices — Function
parameter_group_indices(model::InfiniteModel)::Vector{Union{IndependentParameterIndex, DependentParametersIndex}}Return a list the indices that correspond to the independent infinite parameter groups that have been added to model. This provides the infinite parameter indicies that correspond to the integer indices reported by parameter_group_int_indices. For instance, a group integer index of 2 corresponds to the infinite parameter index stored at parameter_group_indices(model)[2]. This is intended for advanced users writing new types of AbstractTransformationBackends.
Abstract Dependencies
InfiniteOpt.AbstractDataObject — Type
AbstractDataObjectAn abstract type for DataTypes that store core variable DataTypes and their model specific information (e.g., dependency mappings). These are what are stored in the InfiniteModel CleverDicts.
InfiniteOpt.AbstractInfOptIndex — Type
AbstractInfOptIndexAn abstract type for all index objects used in InfiniteOpt.
InfiniteOpt.ObjectIndex — Type
ObjectIndex <: AbstractInfOptIndexAn abstract type for indices of objects stored in MOI.Utilities.CleverDicts.
Model Copying
JuMP.copy_model — Method
JuMP.copy_model(model::InfiniteModel)Return a copy of model and an InfiniteReferenceMap that can be used to obtain the variable and constraint references of the new model corresponding to references from the original model.
The copied model carries an empty backend of the same type as the source's (built via copy_empty_backend), preserving the source's solver and configuration but none of its transformation data. ready_to_optimize is false.
The implementation walks model's registries, rebuilds each entry inline with ref_map[...] for ref-bearing pieces, and inserts the result into new_model via the standard _add_data_object dispatch (which calls MOIUC.add_item). The new index returned by each insertion is recorded in ref_map.source_to_new, an explicit ObjectIndex => ObjectIndex translation table. InfiniteReferenceMap resolves copied refs by looking up the new index in that table, so the copy remains valid even when the source has CleverDict gaps from prior delete! calls (the new model's indices are dense and may differ from the source's).
Entries left in the source's object dictionary that point at deleted refs are skipped on the copy, so dangling registrations do not leak into new_model.obj_dict.
Unlike JuMP.copy_model(::JuMP.GenericModel), this method does not currently accept a filter_constraints keyword argument. All constraints are copied.
Example
julia> model = InfiniteModel();
julia> @infinite_parameter(model, t in [0, 1], num_supports = 10);
julia> @variable(model, x, Infinite(t));
julia> @constraint(model, c, x <= 1);
julia> new_model, ref_map = copy_model(model);
julia> new_x = ref_map[x];
julia> new_c = ref_map[c];InfiniteOpt.InfiniteReferenceMap — Type
InfiniteReferenceMapMaps variable and constraint references from an original InfiniteModel to their counterparts in a copied model. Returned by JuMP.copy_model(::InfiniteModel).
ref_map[x] rewrites any reference into the original model so it points at the new model. Supports GeneralVariableRef, InfOptConstraintRef, affine / quadratic / nonlinear expressions, and any AbstractArray of those. Other values pass through unchanged.
Resolution goes through source_to_new, which is populated by copy_model as it inserts each data object. This carries an explicit source-to-copy ObjectIndex translation, so copies remain valid even when the source has CleverDict gaps from prior deletions.
Fields
old_model::InfiniteModel: The source model.new_model::InfiniteModel: The copied model.source_to_new::Dict{ObjectIndex, ObjectIndex}: Mapping from each source-modelObjectIndexto the corresponding new-model index.