I am working on a problem where I am solving a model and then trying to get an additional feasible solution for the model by reseting the objective function (there are more details behind this, but the general idea will suffice for my question). I am finding that the model seems to hold onto a solution even after changing the objective so that I am not getting a different feasible solution after reseting the objective. Is there a way to delete the existing solution from a JuMP model without deleting any of the model components (e.g., without deleting variables and constriants)?
For instance, in the code below, I reset the objective function after calling optimize!
. I even make sure start values are set (it is redundant with the variable call) and even try resetting to a different optimizer. However, sols1
and sols2
are still equal to each other. Any ideas of how to get the solver to ignore the previous solution?
using JuMP, Random, HiGHS, Gurobi
Random.seed!(10)
m = Model()
N = 100
r = rand(N)
@variable(m, x[1:N], start = 0)
@constraint(m, con1[i = 1:N], x[i] >= -r[i])
@objective(m, Min, sum(x))
set_optimizer(m, HiGHS.Optimizer)
optimize!(m)
sols1 = value.(x)
@objective(m, Min, sum(0.0 * x[i] for i in 1:N))
for i in 1:N
set_start_value(x[i], 0)
end
set_optimizer(m, Gurobi.Optimizer)
optimize!(m)
sols2 = value.(x)
For reference, I am using Julia 1.10 and JuMP v1.21.1