StructJuMP / StructJuMP.jl

A block-structured optimization framework for JuMP
Other
54 stars 19 forks source link

Allowing constant objective function #80

Closed kibaekkim closed 4 years ago

kibaekkim commented 4 years ago

It is strange that Real <: AbstractJuMPScalar returns false. This could have been addressed in JuMP. But, this commit would resolve that.

blegat commented 4 years ago

Real is not an AbstractJuMPScalar as it does not corresponds to any MOI scalar function. We should rather do as in https://github.com/JuliaOpt/JuMP.jl/pull/2247

kibaekkim commented 4 years ago

Real is not an AbstractJuMPScalar as it does not corresponds to any MOI scalar function. We should rather do as in jump-dev/JuMP.jl#2247

@blegat Can you elaborate a bit more about your suggestion? Is this comment on https://github.com/StructJuMP/StructJuMP.jl/pull/80/commits/b25afc99ea311bc79536a6be6923c1190ef06185? My fix was base on https://github.com/jump-dev/JuMP.jl/blob/release-0.21/src/objective.jl#L107-L114

blegat commented 4 years ago

Add a method

function JuMP.set_objective_function(m::StructuredModel, f::Real)
    JuMP.set_objective_function(m, convert(AffExpr, f))
end

It should work once https://github.com/jump-dev/JuMP.jl/pull/2247 is merged. We should do a patch release of JuMP including this PR soon so that won't block this PR for long

kibaekkim commented 4 years ago

@blegat can you check if the changes are compatible to the PR?

blegat commented 4 years ago

Add in Project.toml that we require at least JuMP v0.21.3

kibaekkim commented 4 years ago

@blegat any other concerns or suggestions?