# Solving multiple similar problems in JuMP

Hello,

I’m interested in using JuMP to solve series of (all nonlinear) problems with identical constraints but different objectives. Is it possible to speed this up over the naive approach of just defining each problem separately?

I’m also curious about the case where all of the problems have the same objectives with the constraints being a function g(x,y), where x is the variable to be optimized under different values of y (so problems with the same objective but different constraints). Is there a smart way of handling this?

Thanks for the help.

Modifying the objective:

Modifying constraints:

1 Like

Thank you. So there are no better options for defining the problem that allows them to be solved simultaneously, right?

I’m not sure I understand the question - are you talking about some sort of paralellization?

Sorry, I should have been clearer in my explanation. The different problems do not depend on each other, so I would likely be defining multiple models and solving them in parallel (though I would still need to use your suggestion to modify the models because of the large number of problems I have to solve.)

My actual question is perhaps somewhat solver-specific. I see from the documentation that JuMP has some amount of support for multi-objective optimization. I know that the setup I’m interested in differs from traditional multi-objective optimization because I have no interest in finding any pareto front or other compromise between my completely decoupled objectives, but I was curious as to wether any of the infrastructure related to that could be useful in my situation.

If your model has the same variables and same constraints, just different objectives you may use multi-objective but it may lose some time searching solutions that are good for both but best for none (what does not seem to be what you want). If they only share objective function I think there is nothing you can make use of to speed up the solving (except maybe passing the upper/lower bounds from one to the other, after the first ends, so the second can cut reduce the search space).

1 Like

As I understand it, you want to solve several independent models which only differ in the objective function. You could pass some case distinction as arguments to your script, e.g., with ArgParse, and start your script from the shell (not REPL), e.g.,
`\$julia script.jl --objectiveType objective_1`

In your script make some case distinction when you build the model, e.g.,

``````if parsed_args["objectiveType"] == "objective_1"
@objective(model, ....) # your first objective
elseif parsed_args["objectiveType"] == "objective_2"
@objective(model, ....) # your second objective
...
end
``````

This way you can start several julia instances in parallel, thus solve serveral models in parallel (depending on your machine).

2 Likes

Thank you for all of the suggestions. I’ll move ahead with trying these and see what works best.