FWIW, JuMP has no problem either:
julia> using JuMP
julia> import Ipopt
julia> function main(data)
model = Model(Ipopt.Optimizer)
@variable(model, 0 <= dt <= 1)
@variable(model, 1 <= a)
@variable(model, 0 <= b)
@NLconstraint(model, a <= 1 / dt)
variance = Any[]
push!(variance, 1.0)
for t in 2:length(data)
push!(
variance,
@NLexpression(model, (1 - dt * a) * variance[t-1] + dt * data[t-1]^2 + dt * b),
)
end
N = length(data)
@NLobjective(
model,
Min,
sum(log(2π * var) + d^2 / var for (d, var) in zip(data, variance)) / 2N,
)
optimize!(model)
return [value(dt), value(a), value(b)]
end
main (generic function with 1 method)
julia> data = [
2.1217711584057386, -0.28350145551002465, 2.3593492969513004, 0.192856733601849, 0.4566485836385113, 1.332717934013979, -1.286716619379847, 0.9868669960185211, 2.2358674776395224, -2.7933975791568098,
1.2555871497124622, 1.276879759908467, -0.8392016987911409, -1.1580875182201849, 0.33201646080578456, -0.17212553408696898, 1.1275285626369556, 0.23041139849229036, 1.648423577528424, 2.384823597473343,
-0.4005518932539747, -1.117737311211693, -0.9490152960583265, -1.1454539355078672, 1.4158585811404159, -0.18926972177257692, -0.2867541528181491, -1.2077459688543788, -0.6397173049620141, 0.66147783407023,
0.049805188778543466, 0.902540117368457, -0.7018417933284938, 0.47342354473843684, 1.2620345361591596, -1.1483844812087018, -0.06487285080802752, 0.39020117013487715, -0.38454491504165356, 1.5125786171885645,
-0.6751768274451174, 0.490916740658628, 0.012872300530924086, 0.46532447715746716, 0.34734421531357157, 0.3830452463549559, -0.8730874028738718, 0.4333151627834603, -0.40396180775692375, 2.0794821773418497,
-0.5392735774960918, 0.6519326323752113, -1.4844713145398716, 0.3688828625691108, 1.010912990717231, 0.5018274939956874, 0.36656889279915833, -0.11403975693239479, -0.6460314660359935, -0.41997005020823147,
0.9652752515820495, -0.37375868692702047, -0.5780729659197872, 2.642742798278919, 0.5076984117208074, -0.4906395089461916, -1.804352047187329, -0.8596663844837792, -0.7510485548262176, -0.07922589350581195,
1.7201304839487317, 0.9024493222130577, -1.8216089665357902, 1.3929269238775426, -0.08410752079538407, 0.6423068180438288, 0.6615201016351212, 0.18546977816594887, -0.717521690742993, -1.0224309324751113,
1.7748350222721971, 0.1929546575877559, -0.1581871639724676, 0.20198379311238596, -0.6919373947349301, -0.9253274269423383, 0.549366272989534, -1.9302106783541606, 0.7197247279281573, -1.220334158468621,
-0.9187468058921053, -2.1452607604834184, -2.1558650694862687, -0.9387913392336701, -0.676637835687265, -0.16621998352492198, 0.5637177022958897, -0.5258315560278541, 0.8413359958184765, -0.9096866525337141
];
julia> main(data)
This is Ipopt version 3.14.4, running with linear solver MUMPS 5.4.1.
Number of nonzeros in equality constraint Jacobian...: 0
Number of nonzeros in inequality constraint Jacobian.: 2
Number of nonzeros in Lagrangian Hessian.............: 7
Total number of variables............................: 3
variables with only lower bounds: 2
variables with lower and upper bounds: 1
variables with only upper bounds: 0
Total number of equality constraints.................: 0
Total number of inequality constraints...............: 1
inequality constraints with only lower bounds: 0
inequality constraints with lower and upper bounds: 0
inequality constraints with only upper bounds: 1
iter objective inf_pr inf_du lg(mu) ||d|| lg(rg) alpha_du alpha_pr ls
0 1.5131731e+00 0.00e+00 1.00e+00 -1.0 0.00e+00 - 0.00e+00 0.00e+00 0
1 1.5321040e+00 0.00e+00 5.05e-01 -1.0 1.01e-01 - 9.39e-01 9.89e-01f 1
2 1.5317504e+00 0.00e+00 2.48e+01 -1.7 6.55e-01 - 3.73e-01 4.95e-01f 2
3 1.5215004e+00 0.00e+00 2.73e+01 -1.7 9.03e-01 - 5.96e-01 4.95e-01f 2
4 1.5205462e+00 0.00e+00 6.79e+00 -1.7 6.96e-02 0.0 1.00e+00 9.92e-01h 1
5 1.5181044e+00 0.00e+00 4.94e-02 -1.7 1.46e-01 -0.5 1.00e+00 1.00e+00h 1
6 1.5132940e+00 0.00e+00 4.74e+04 -5.7 1.93e-01 - 6.26e-01 1.00e+00f 1
7 1.5112242e+00 0.00e+00 4.61e+00 -5.7 1.09e-01 -1.0 8.87e-01 1.00e+00f 1
8 1.5089847e+00 0.00e+00 3.52e+01 -5.7 4.53e+00 - 1.83e-01 8.56e-02f 1
9 1.5063204e+00 0.00e+00 1.74e+04 -5.7 1.09e+00 - 6.30e-03 1.00e+00f 1
iter objective inf_pr inf_du lg(mu) ||d|| lg(rg) alpha_du alpha_pr ls
10 1.5061881e+00 0.00e+00 6.16e-02 -5.7 3.85e-02 -1.4 9.99e-01 1.00e+00h 1
11 1.5060385e+00 0.00e+00 1.19e-02 -5.7 1.54e-02 -0.1 1.00e+00 1.00e+00f 1
12 1.5054644e+00 0.00e+00 2.89e+01 -5.7 2.56e+01 -0.6 4.07e-03 2.56e-03f 1
13 1.5043945e+00 0.00e+00 8.41e+04 -5.7 1.02e+00 - 1.51e-03 1.00e+00f 1
14 1.5029687e+00 0.00e+00 3.43e-03 -5.7 1.20e+00 - 1.00e+00 1.00e+00f 1
15 1.5027443e+00 0.00e+00 3.28e-03 -5.7 1.08e+00 - 1.00e+00 1.00e+00f 1
16 1.5027038e+00 0.00e+00 4.11e-04 -5.7 6.30e-01 - 1.00e+00 1.00e+00f 1
17 1.5027011e+00 0.00e+00 6.90e-05 -5.7 2.29e-01 - 1.00e+00 1.00e+00h 1
18 1.5027011e+00 0.00e+00 5.66e-07 -5.7 2.21e-02 - 1.00e+00 1.00e+00h 1
19 1.5027011e+00 0.00e+00 2.87e-08 -8.6 4.55e-03 - 1.00e+00 1.00e+00h 1
iter objective inf_pr inf_du lg(mu) ||d|| lg(rg) alpha_du alpha_pr ls
20 1.5027011e+00 0.00e+00 3.72e-14 -8.6 4.75e-06 - 1.00e+00 1.00e+00h 1
Number of Iterations....: 20
(scaled) (unscaled)
Objective...............: 1.5027011040525426e+00 1.5027011040525426e+00
Dual infeasibility......: 3.7163990047232110e-14 3.7163990047232110e-14
Constraint violation....: 0.0000000000000000e+00 0.0000000000000000e+00
Variable bound violation: 0.0000000000000000e+00 0.0000000000000000e+00
Complementarity.........: 2.5059035572090069e-09 2.5059035572090069e-09
Overall NLP error.......: 2.5059035572090069e-09 2.5059035572090069e-09
Number of objective function evaluations = 23
Number of objective gradient evaluations = 21
Number of equality constraint evaluations = 0
Number of inequality constraint evaluations = 23
Number of equality constraint Jacobian evaluations = 0
Number of inequality constraint Jacobian evaluations = 21
Number of Lagrangian Hessian evaluations = 20
Total seconds in IPOPT = 0.014
EXIT: Optimal Solution Found.
3-element Vector{Float64}:
0.09968760243264961
6.941809365898011
6.817463190447395