-
-
Notifications
You must be signed in to change notification settings - Fork 402
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for vector-valued objectives #3176
Conversation
Codecov ReportBase: 98.06% // Head: 98.07% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## master #3176 +/- ##
=======================================
Coverage 98.06% 98.07%
=======================================
Files 34 34
Lines 4597 4612 +15
=======================================
+ Hits 4508 4523 +15
Misses 89 89
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
Picking on the main sticking points from #2099
You can re-define the objective without rebuilding the model. This is working with MOO.jl model = Model()
@variable(model, x >= 0.0)
@variable(model, y >= 0.25)
@constraint(model, x + y >= 1.0)
@constraint(model, 0.5 * x + y >= 0.75)
@expression(model, obj1, 2 * x + y)
@expression(model, obj2, -x - 3 * y)
# Optimize two objectives
@objective(model, Min, [obj1, -obj2])
optimize!(model)
# ... do something with solution
# Drop objective 2
@objective(model, Min, [obj1])
optimize!(model)
# ... do something with solution
These are just normal solver parameters using JuMP
import HiGHS, MOO
model = JuMP.Model(() -> MOO.Optimizer(HiGHS.Optimizer))
set_optimizer_attribute(model, "algorithm", MOO.NISE())
This is tricky. For now, Y_N = MOI.get(model, vOpt.EfficientFacets())
This is still a problem.
You can set a new objective, but we can't say "delete the 2nd objective from this vector." Would solvers benefit from the ability to do this? |
682bc27
to
4efe50a
Compare
To be read in conjunction with jump-dev/MathOptInterface.jl#2070 A proof-of-concept solver and JuMP examples are available at jump-dev/MultiObjectiveAlgorithms.jl#2 The issue #2099 discussed two approaches for implementing MO in JuMP. 1. Treat multicriteria as a vector of scalar objectives and a vector of scalar senses. This would let someone write [Min, Max], [f(x), g(x)]. The main reason for this approach is that it matches what users want to do. 2. Treat multicriteria as an optimization problem with a vector-valued objective function. Users could write only Min, f(x) where f(x) is a vector. The main reason for this approach is that it matches what MathOptInterface wants. This PR implements option 2. The strongest reason in support of option 2 is that it requires very little code to implement, suggesting that it is a natural extension of MOI. The biggest downside is that it doesn't overcome the Min-Max issue; but I think we can work around this with user-facing cosmetic tooling in JuMP; solvers would be forced to accept a single sense.
459595b
to
3253664
Compare
Before merging, I'd like to tag https://github.com/jump-dev/MultiObjectiveAlgorithms.jl as a public package and add a tutorial to the documentation. This would let us document both vector-valued objectives, and solvers which support multiple solutions. |
I've added a tutorial using MultiObjectiveAlgorithms. I think it's pretty cool. The ease to which we can solve multi-objective problems is going to be a nice boost to the popularity of JuMP. I'll post a link here once CI finishes. |
Here's the tutorial: https://jump.dev/JuMP.jl/previews/PR3176/tutorials/linear/multi_objective_knapsack |
Co-authored-by: Miles Lubin <[email protected]>
@xgandibleux: I've updated the tutorial to use vectors instead of the |
Great! |
After 3+ years (#2099), this is finally ready to merge! |
src/objective.jl
Outdated
For scalar-valued objectives, this function returns a `Float64`. For | ||
vector-valued objectives, it returns a `Vector{Float64}`. | ||
|
||
In the case of a vector-valued objective, this returns the ideal point, that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is an "ideal point" ? Is this a technical term from the multi-objective field ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. See https://en.wikipedia.org/wiki/Multi-objective_optimization ("ideal objective vector").
It's also plotted in the tutorial:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, maybe write it in italic to signify its the first occurence of this technical word and maybe add a href to the wikipedia page
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added italics. I don't think the href is useful. We don't link to other technical terms, and the docstring includes a that is, ...
comment in non-jargon.
Ideed, Ideal point is a common reference point in MOO, and I agree with Oscar, extra explanations are not required here. |
Closes #2099
Overview
The issue #2099 discussed two approaches for implementing MO in JuMP.
This PR implements option 2. The strongest reason in support of option 2 is that it requires very little code to implement, suggesting that it is a natural extension of MOI.
There are also solvers, like Gurobi, that support 2, but not 1. That is, they have a single objective sense but support multiple objectives: https://www.gurobi.com/documentation/10.0/refman/c_setobjectiven.html. (You could work-around that by setting the weight of the
Max
objective to-1
instead of1
, but that's getting a bit finicky.)The biggest downside is that it doesn't overcome the Min-Max issue; but I think we can work around this with user-facing cosmetic tooling in JuMP; solvers would be forced to accept a single sense.
Documentation
See https://jump.dev/JuMP.jl/previews/PR3176/manual/objective/#Set-a-vector-valued-objective
Testing it out
The MOI PR is:
The supported solvers are:
] add Gurobi#od/vector-optimization
)Examples to follow are:
but this explains the basic syntax. Currently you need
add_bridges = false
because of an issue in MOI.