Modifying coefficient of quadratic term in objective function

Suppose I have this problem:

using JuMP, OSQP
m = Model(OSQP.Optimizer)
@variable(m, x[1:3] >= 0)
@constraint(m, sum(x) .>= 1)
@objective(m, Min, x[1] + 2x[2] + 3x[3]^2 + 2x[1]^2)
optimize!(m)
objective_value(m)

I can modify the objective coefficient term of x[1] without reinstantiating the all problem with

set_objective_coefficient(m, x[1], -5.0)
optimize!(m)
objective_value(m)

But can I modify the objective coefficient of x[1]^2 without reinstantiating the problem?

No. But you can just set a new objective with @objective.

1 Like