Digamma not defined in JuMP nonlinear optimization

Hello all,

I’m trying to familiarize myself with JuMP, especially in the context of using SpecialFunctions.

I’m struggling with gamma() and lgamma() specifically, so I’ve tried to implement the simple example from JuMP.jl issue #407 albeit with updated syntax:

using JuMP
using Ipopt
using SpecialFunctions

m = Model(with_optimizer(Ipopt.Optimizer))
@variable(m, 3.0 <= x <= 4.0)
@NLobjective(m, Max, lgamma(x))

optimize!(m)  # expect lgamma(4.0)

Running this results in:

UndefVarError: digamma not defined

I notice that I get the same error if I do not use the SpecialFunctions module, but in that case I haven’t been able to find from where lgamma() is made available.

Package versions here are:

JuMP v0.20.0
Ipopt v0.6.0
SpecialFunctions v0.7.2
Calculus v0.5.0

I feel that I’m missing something basic. Am I overlooking a module dependency or not understanding the functions which may be used in a nonlinear objective function? I’ve read through the nonlinear modeling documentation but I am inexperienced in this domain, so any links to relevant documentation are much appreciated.

See https://github.com/JuliaOpt/JuMP.jl/issues/1803

The cryptic comment to “register” the function means the following:

using JuMP, Ipopt, SpecialFunctions
m = Model(with_optimizer(Ipopt.Optimizer))
@variable(m, 3.0 <= x <= 4.0)
JuMP.register(m, :my_lgamma, 1, SpecialFunctions.lgamma, autodiff=true)
@NLobjective(m, Max, my_lgamma(x))

Here are the relevant docs: Nonlinear Modeling · JuMP


Thanks for the links and the example @odow, the register method did the trick.