Skip to content

Commit

Permalink
Support constant objectives in JuMPExtension
Browse files Browse the repository at this point in the history
  • Loading branch information
odow committed Apr 8, 2019
1 parent 587f8ed commit 62449e3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/objective.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ function set_objective_sense(model::Model, sense::MOI.OptimizationSense)
end

"""
set_objective_function(model::Model,
func::Union{AbstractJuMPScalar,
MathOptInterface.AbstractScalarFunction})
set_objective_function(
model::Model,
func::Union{AbstractJuMPScalar, MathOptInterface.AbstractScalarFunction})
Sets the objective function of the model to the given function. See
[`set_objective_sense`](@ref) to set the objective sense. These are low-level
Expand Down
4 changes: 4 additions & 0 deletions test/JuMPExtension.jl
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,10 @@ function JuMP.set_objective(m::MyModel, sense::MOI.OptimizationSense,
m.objectivesense = sense
m.objective_function = f
end
function JuMP.set_objective(m::MyModel, sense::MOI.OptimizationSense, f::Real)
m.objectivesense = sense
m.objective_function = JuMP.GenericAffExpr{Float64, MyVariableRef}(f)
end
JuMP.objective_sense(model::MyModel) = model.objectivesense
function JuMP.set_objective_sense(model::MyModel, sense)
model.objectivesense = sense
Expand Down

0 comments on commit 62449e3

Please sign in to comment.