How to implment `logsumexp` function in JuMP?

You typically can’t use arbitrary nonlinear function in JuMP without registering them as user-defined functions: Nonlinear Modeling · JuMP.

Do you have a reproducible example of what you’re trying to achieve?

The Mosek modeling cookbook 5 Exponential cone optimization — MOSEK Modeling Cookbook 3.3.0 has a conic formulation of logsumexp:

N = 10
model = Model()
@variable(model, x[1:N])
@NLobjective(model, Min, log(sum(exp(x[i]) for i in 1:N)))
# becomes
model = Model()
@variable(model, x[1:N])
@variable(model, u[1:N])
@variable(model, t)
@constraint(model, sum(u) <= 1)
@constraint(model, [i=1:N], [x[i] - t, 1, u[i]] in MOI.ExponentialCone())
@objective(model, Min, t)
1 Like