lanl-ansi / Juniper.jl

A JuMP-based Nonlinear Integer Program Solver
https://lanl-ansi.github.io/Juniper.jl/stable/
MIT License
179 stars 22 forks source link

Error: optimizer_with_attributes not defined, when trying to run the given example #205

Closed prottay closed 3 years ago

prottay commented 3 years ago

I am trying to run the basic example provided.

using LinearAlgebra # for the dot product m = Model(optimizer_with_attributes(optimizer, "nl_solver"=>nl_solver))

v = [10,20,12,23,42] w = [12,45,12,22,21] @variable(m, x[1:5], Bin)

@objective(m, Max, dot(v,x))

@NLconstraint(m, sum(w[i]*x[i]^2 for i=1:5) <= 45)

optimize!(m)

println(JuMP.value.(x)) println(JuMP.objective_value(m)) println(JuMP.termination_status(m))

This is the error message I am seeing.

ERROR: LoadError: UndefVarError: optimizer_with_attributes not defined

I am not quite sure how to tackle it, I am new with Julia and Juniper. Any help is appreciated.

Wikunia commented 3 years ago

Thanks for checking out Juniper and Julia.

Have you added Juniper, JuMP and Ipopt? This can be done with ] add Juniper in the REPL ( same for JuMP and Ipopt of course)

Afterwards you need to include them with

using JuMP, Juniper, Ipopt

Hope this helps you out!

prottay commented 3 years ago

That helps. Thanks. You're a savior.