Objectives
A technical manual for objective functions in InfiniteOpt
. See the respective guide for more information.
Queries
JuMP.objective_sense
— MethodJuMP.objective_sense(model::InfiniteModel)::MOI.OptimizationSense
Extend JuMP.objective_sense
to return the objective sense of the infinite model model
.
Example
julia> objective_sense(model)
MIN_SENSE::OptimizationSense = 0
JuMP.objective_function_type
— MethodJuMP.objective_function_type(model::InfiniteModel)::Type{<:JuMP.AbstractJuMPScalar}
Extend JuMP.objective_function_type
to return the objective function type of infinite model model
.
Example
julia> objective_function_type(model)
GenericAffExpr{Float64,GeneralVariableRef}
JuMP.objective_function
— MethodJuMP.objective_function(model::InfiniteModel)::JuMP.AbstractJuMPScalar
Extend JuMP.objective_function
to return the objective of infinite model model
.
Example
julia> objective_function(model)
1
InfiniteOpt.objective_has_measures
— Functionobjective_has_measures(model::InfiniteModel)::Bool
Return Bool
whether the objective function contains any measures.
Modification
JuMP.set_objective_function
— MethodJuMP.set_objective_function(model::InfiniteModel,
func::JuMP.AbstractJuMPScalar)::Nothing
Extend JuMP.set_objective_function
to set the objective expression of infinite model model
. Errors if func
contains infinite variables and/or parameters. Also errors if func
contains invalid variables.
Example
julia> set_objective_function(model, 2x + 1)
julia> objective_function(model)
2 x + 1
JuMP.set_objective_function
— MethodJuMP.set_objective_function(model::InfiniteModel, func::Real)::Nothing
Extend JuMP.set_objective_function
to set the objective expression of model
with a number.
Example
julia> set_objective_function(model, 3)
julia> objective_function(model)
3
JuMP.set_objective_sense
— MethodJuMP.set_objective_sense(model::InfiniteModel,
sense::MOI.OptimizationSense)::Nothing
Extend JuMP.set_objective_sense
to set the objective sense of infinite model model
.
Example
julia> set_objective_sense(model, MOI.MIN_SENSE)
julia> objective_sense(model)
MIN_SENSE::OptimizationSense = 0
JuMP.set_objective
— MethodJuMP.set_objective(model::InfiniteModel, sense::MOI.OptimizationSense,
func::Union{JuMP.AbstractJuMPScalar, Real})::Nothing
Extend JuMP.set_objective
to set the objective of infinite model model
. Errors if func
contains infinite variables and/or parameters, or if it does not belong to the model.
Example
julia> set_objective(model, MOI.MIN_SENSE, 2x + 1)
julia> objective_function(model)
2 x + 1
JuMP.set_objective_coefficient
— MethodJuMP.set_objective_coefficient(model::InfiniteModel,
variable::GeneralVariableRef,
coefficient::Real)::Nothing
Extend JuMP.set_objective_coefficient
Set the linear objective coefficient associated with variable
to coefficient
. Errors if the function type is unsupported.
Example
julia> @variable(model, x)
x
julia> @variable(model, y)
y
julia> @objective(model, x + y)
x + y
julia> set_objective_coefficient(model, y, 2)
julia> objective_function(model)
x + 2 y