# Error in InfiniteOpt.jl quick start example

Hi everyone,
I have tried to run a tutorial example in InfiniteOpt.jl.

``````using InfiniteOpt, Distributions, Ipopt

# DEFINE THE PROBLEM CONSTANTS

μ = 1; σ = 0.2

x0 = [0, 0]; v0 = [0, 0]

p = [1 4 6 1; 1 3 0 1]; tw = [0, 25, 50, 60]

I = 1:2; W = 1:4

# INITIALIZE THE MODEL

model = InfiniteModel(Ipopt.Optimizer)

# INITIALIZE THE PARAMETERS

@finite_parameter(model, ϵ == 10)

@infinite_parameter(model, t in [0, 60], num_supports = 61,

derivative_method = OrthogonalCollocation(2))

@infinite_parameter(model, ξ ~ Normal(μ, σ^2), num_supports = 10)

# INITIALIZE THE VARIABLES

@variable(model, x[I], Infinite(t, ξ), start = 0)

@variable(model, v[I], Infinite(t, ξ), start = 0)

@variable(model, u[I], Infinite(t), start = 0)

@variable(model, y[W] >= 0, Infinite(ξ), start = 0)

# SET THE OBJECTIVE

@objective(model, Min, integral(sum(u[i]^2 for i in I), t))

# SET THE INITIAL CONDITIONS

@constraint(model, [i in I], x[i](0, ξ) == x0[i])

@constraint(model, [i in I], v[i](0, ξ) == v0[i])

# SET THE PROBLEM CONSTRAINTS

@constraint(model, c1[i in I], @deriv(x[i], t) == v[i])

@constraint(model, c2[i in I], ξ * @deriv(v[i], t) == u[i])

@constraint(model, c3[w in W], y[w] == sum((x[i](tw[w], ξ) - p[i, w])^2 for i in I))

@constraint(model, c4, expect(sum(y[w] for w in W), ξ) <= ϵ)

# SOLVE THE MODEL

optimize!(model)

# GET THE RESULTS

termination_status(model)

opt_obj = objective_value(model)

u_opt = value.(u)

u_ts = supports.(u)
``````

But I got an error:

``````type Model has no field nlp_data

Stacktrace:
[1] setproperty!(x::Model, f::Symbol, v::Nothing)
@ Base ./Base.jl:39
[2] clear_optimizer_model_build!(model::Model)
@ InfiniteOpt ~/.julia/packages/InfiniteOpt/k0mve/src/optimize.jl:489
[3] clear_optimizer_model_build!(model::InfiniteModel)
@ InfiniteOpt ~/.julia/packages/InfiniteOpt/k0mve/src/optimize.jl:506
[4] build_optimizer_model!(model::InfiniteModel, key::Val{:TransData}; check_support_dims::Bool)
@ InfiniteOpt.TranscriptionOpt ~/.julia/packages/InfiniteOpt/k0mve/src/TranscriptionOpt/optimize.jl:32
[5] build_optimizer_model!(model::InfiniteModel, key::Val{:TransData})
@ InfiniteOpt.TranscriptionOpt ~/.julia/packages/InfiniteOpt/k0mve/src/TranscriptionOpt/optimize.jl:26
[6] build_optimizer_model!(model::InfiniteModel; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
@ InfiniteOpt ~/.julia/packages/InfiniteOpt/k0mve/src/optimize.jl:536
[7] build_optimizer_model!(model::InfiniteModel)
@ InfiniteOpt ~/.julia/packages/InfiniteOpt/k0mve/src/optimize.jl:530
[8] #optimize!#475
@ ~/.julia/packages/InfiniteOpt/k0mve/src/optimize.jl:926 [inlined]
[9] optimize!(model::InfiniteModel)
@ InfiniteOpt ~/.julia/packages/InfiniteOpt/k0mve/src/optimize.jl:924
[10] top-level scope
@ ~/Julia_projects/Maintenance_EMS/RUL_dist.ipynb:38
``````

Thanks for checking my problem!

What is the output of:

``````import Pkg
Pkg.status()
``````

It looks like you’ve managed to install some incompatible versions of JuMP and InfiniteOpt.

Here are the versions of JuMP and InfiniteOpt:

Thanks!

You’ll need to update InfiniteOpt to `v0.5.6`. JuMP changed the way it handled nonlinear expressions with `v1.2`. Hence, `v0.5.5` and older versions of InfiniteOpt are not compatible with newer versions of JuMP.

1 Like

Thank you very much!
I can not install it for my base environment:

But I have tried with a new environment and managed to work with Infinite@0.5.6 and JuMP@v1.6.0. It works!

It is good practice to work with environments to avoid these compatibility issues.

In a fresh environment, I am able to install the latest version of all the packages needed for the quick start (i.e., InfiniteOpt v0.5.6 and JuMP v1.7).

``````(Test) pkg> add InfiniteOpt@0.5.6, JuMP@1.7, Ipopt, Distributions
Resolving package versions...
Updating `C:\Users\bbgui\Test\Project.toml`
[31c24e10] + Distributions v0.25.80
[20393b10] + InfiniteOpt v0.5.6
[b6b21f68] + Ipopt v1.1.0
[4076af6c] + JuMP v1.7.0
Updating `C:\Users\bbgui\Test\Manifest.toml`
[1520ce14] + AbstractTrees v0.4.4
[6e4b80f9] + BenchmarkTools v1.3.2
[49dc2e85] + Calculus v0.5.1
[d360d2e6] + ChainRulesCore v1.15.7
[9e997f8a] + ChangesOfVariables v0.1.5
[523fee87] + CodecBzip2 v0.7.2
[944b1d66] + CodecZlib v0.7.1
[bbf7d656] + CommonSubexpressions v0.3.0
[34da2185] + Compat v4.6.0
[9a962f9c] + DataAPI v1.14.0
[864edb3b] + DataStructures v0.18.13
[b429d917] + DensityInterface v0.4.0
[163ba53b] + DiffResults v1.1.0
[b552c78f] + DiffRules v1.12.2
[31c24e10] + Distributions v0.25.80
[ffbed154] + DocStringExtensions v0.9.3
[fa6b7ba4] + DualNumbers v0.6.8
[1a297f60] + FillArrays v0.13.7
[f6369f11] + ForwardDiff v0.10.34
[34004b35] + HypergeometricFunctions v0.3.11
[20393b10] + InfiniteOpt v0.5.6
[3587e190] + InverseFunctions v0.1.8
[b6b21f68] + Ipopt v1.1.0
[92d709cd] + IrrationalConstants v0.1.1
[692b3bcd] + JLLWrappers v1.4.1
[682c06a0] + JSON v0.21.3
[4076af6c] + JuMP v1.7.0
[2ab3a3ac] + LogExpFunctions v0.3.21
[1914dd2f] + MacroTools v0.5.10
[b8f27783] + MathOptInterface v1.11.5
[e1d29d7a] + Missings v1.1.0
[d8a4904e] + MutableArithmetics v1.1.0
[77ba4419] + NaNMath v1.0.1
[bac558e1] + OrderedCollections v1.4.1
[90014a1f] + PDMats v0.11.16
[69de0a69] + Parsers v2.5.5
[21216c6a] + Preferences v1.3.0
[189a3867] + Reexport v1.2.2
[79098fc4] + Rmath v0.7.1
[66db9d55] + SnoopPrecompile v1.0.3
[a2af1166] + SortingAlgorithms v1.1.0
[276daf66] + SpecialFunctions v2.1.7
[90137ffa] + StaticArrays v1.5.12
[1e83bf80] + StaticArraysCore v1.4.0
[82ae8749] + StatsAPI v1.5.0
[2913bbd2] + StatsBase v0.33.21
[4c63d2b9] + StatsFuns v1.1.1
[3bb67fe8] + TranscodingStreams v0.9.11
[ae81ac8f] + ASL_jll v0.1.3+0
[6e34b625] + Bzip2_jll v1.0.8+0
[9cc047cb] + Ipopt_jll v300.1400.400+0
[d00139f3] + METIS_jll v5.1.2+0
[d7ed1dd3] + MUMPS_seq_jll v5.4.1+0
[656ef2d0] + OpenBLAS32_jll v0.3.17+0
[efe28fd5] + OpenSpecFun_jll v0.5.5+0
[f50d1b31] + Rmath_jll v0.4.0+0
[56f22d72] + Artifacts
[2a0f44e3] + Base64
[b77e0a4c] + InteractiveUtils
[b27032c2] + LibCURL
[76f85450] + LibGit2
[8f399da3] + Libdl
[37e2e46d] + LinearAlgebra
[56ddb016] + Logging
[d6f4376e] + Markdown
[ca575930] + NetworkOptions
[44cfe95a] + Pkg
[de0858da] + Printf
[9abbd945] + Profile
[3fa0cd96] + REPL
[9a3f8284] + Random
[ea8e919c] + SHA
[9e88b42a] + Serialization
[6462fe0b] + Sockets
[2f01184e] + SparseArrays
[10745b16] + Statistics
[4607b0f0] + SuiteSparse
[fa267f1f] + TOML
[a4e569a6] + Tar
[8dfed614] + Test
[cf7118a7] + UUIDs
[4ec0a83e] + Unicode
[e66e0078] + CompilerSupportLibraries_jll
[deac9b47] + LibCURL_jll
[29816b5a] + LibSSH2_jll
[c8ffd9c3] + MbedTLS_jll
[14a3606d] + MozillaCACerts_jll
[4536629a] + OpenBLAS_jll
[05823500] + OpenLibm_jll
[83775a58] + Zlib_jll
[8e850b90] + libblastrampoline_jll
[8e850ede] + nghttp2_jll
[3f19e933] + p7zip_jll
``````
1 Like