Skip to content
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

Multi-objective optimization with CP-Sat #1344

Closed
ghost opened this issue Jun 11, 2019 · 9 comments
Closed

Multi-objective optimization with CP-Sat #1344

ghost opened this issue Jun 11, 2019 · 9 comments
Assignees
Labels
Solver: CP-SAT Solver Relates to the CP-SAT solver
Milestone

Comments

@ghost
Copy link

ghost commented Jun 11, 2019

Hi!

This may come across as a newbie question, but is it possible to have multiple objective functions and set a priority or preference over them?

Right now I am manually adding a coefficient to each objective:
model.Minimize(objective1+10000*objective2)

But this doesn't seem right as the order of magnitude of each objective may be different.

@lperron
Copy link
Collaborator

lperron commented Jun 11, 2019 via email

@ghost
Copy link
Author

ghost commented Jun 11, 2019

Thank you very much!

Didn't know about solution hinting, maybe my problem should also be broken down to make better use of this feature.

Will use the code that you posted in another issue to do this:

model.Proto().solution_hint.Clear()
for i in range(len(model.Proto().variables)):
    model.Proto().solution_hint.vars.append(i)
    model.Proto().solution_hint.values.append(solver.ResponseProto().solution[i])

@ghost ghost closed this as completed Jun 11, 2019
@lperron
Copy link
Collaborator

lperron commented Jun 11, 2019 via email

@ghost
Copy link
Author

ghost commented Jun 11, 2019

Thanks!

I only knew about the examples in https://github.com/google/or-tools/tree/master/examples, will also keep an eye on https://github.com/google/or-tools/tree/master/ortools/sat/samples from now on.

@lperron
Copy link
Collaborator

lperron commented Jun 11, 2019 via email

@Mizux Mizux added the Solver: CP-SAT Solver Relates to the CP-SAT solver label Jul 4, 2019
@philippe3263
Copy link

Hi!

This may come across as a newbie question, but is it possible to have multiple objective functions and set a priority or preference over them?

Right now I am manually adding a coefficient to each objective:
model.Minimize(objective1+10000*objective2)

But this doesn't seem right as the order of magnitude of each objective may be different.

here a two step approach

https://github.com/philippe3263/ORTools_Visual_Studio

file : JS_with_SAT_And_Two_Objective.cpp

not a good solution but acceptable avoiding objective function defined with a sum of objectives

@ghost
Copy link

ghost commented Jun 15, 2020

No you cannot directly What I would do: solve with the first objective record the solution change the objective to the second objective add a constraint s.t. the first objective is close to the optimal solution of the first solve add solution hinting to the model to start from the optimal solution of the first solve resolve Laurent Perron | Operations Research | lperron@google.com | (33) 1 42 68 53 00

@lperron, how do I keep the first objective close to the optimal?

Just a model.add(obj < x), where x is a value that I calculate? Is there any other way?

Thanks,
Ciprian

@lperron
Copy link
Collaborator

lperron commented Jun 15, 2020 via email

@ghost
Copy link

ghost commented Jun 15, 2020

Thank you for showing me the way 🙇

@Mizux Mizux added this to the v7.8 milestone Jun 15, 2020
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Solver: CP-SAT Solver Relates to the CP-SAT solver
Projects
None yet
Development

No branches or pull requests

3 participants