I would like to set an upper bound for my JuMP model. That is, given I am minimizing, all nodes and solutions that have a value higher than my upper bound should not be considered by JuMP. How should I do that? What could I have searched on JuMP's documentation or Google to find out? I tried bound
but couldn't find anything.

- 1,800
- 11
- 28
-
One obvious way would be: `min z` subject to `z=objfun`, `z<=bound` – Erwin Kalvelagen Dec 06 '21 at 18:57
2 Answers
JuMP does not solve problems. Instead, it formulates them, and passes the solution off to a solver. You might want to read: https://jump.dev/JuMP.jl/stable/background/algebraic_modeling_languages/
You can tell some solvers that there is a solution limit. For example, Gurobi has: https://www.gurobi.com/documentation/9.5/refman/cutoff.html#parameter:Cutoff
model = Model(Gurobi.Optimizer)
set_optimizer_attribute(model, "Cutoff", 1000)
Note that this is specific to Gurobi. If you use a different solver, you will need to look at their documentation for the corresponding attribute (which may not exist).
Why do you want this? Cutoffs are rarely helpful.

- 2,395
- 1
- 5
- 13
-
I want to do this because my problem is the best solution between two sub-problems, one that I solve polynomially and another one that I solve with Gurobi. That's why I want Gurobi to avoid all solutions worse than my other algorithm. – JKHA Dec 13 '21 at 13:17
Alright, I found a way to do so, I do not know if it is the way recommended but at least it works.
I use my objective as follows:
@objective(m, f(x,y))
While supposing that f(x,y)
is defined for arrays x
and y
Then I set a constraint on f
:
threshold = 1000 # Or any other relevant value
@constrait(m, f(x,y) <= threshold)

- 1,800
- 11
- 28
-
-
@Oscar Dowson, yes I have made a mistake, I wanted to write `@constraint` – JKHA Dec 08 '21 at 15:06