You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have tried running several of the examples from the docs only to get the error that optimize! is undefined. Please see code taken from docs below. Hope someone can help? Probably need to inlcude another package?
Thanks,
Peter
import Pkg
Pkg.add("JuMP")
# Pkg.add("NLopt")
Pkg.add("Ipopt")
Pkg.add("Test")
using JuMP
import Ipopt
import Test
function example_qcp(; verbose = true)
model = Model(Ipopt.Optimizer)
set_silent(model)
@variable(model, x)
@variable(model, y >= 0)
@variable(model, z >= 0)
@objective(model, Max, x)
@constraint(model, x + y + z == 1)
@constraint(model, x * x + y * y - z * z <= 0)
@constraint(model, x * x - y * z <= 0)
optimize!(model)
if verbose
print(model)
println("Objective value: ", objective_value(model))
println("x = ", value(x))
println("y = ", value(y))
end
Test.@test termination_status(model) == MOI.LOCALLY_SOLVED
Test.@test primal_status(model) == MOI.FEASIBLE_POINT
Test.@test objective_value(model) ≈ 0.32699 atol = 1e-5
Test.@test value(x) ≈ 0.32699 atol = 1e-5
Test.@test value(y) ≈ 0.25707 atol = 1e-5
return
end
example_qcp()
ERROR: LoadError: UndefVarError: optimize! not defined
Stacktrace:
[1] example_qcp(; verbose::Bool)
@ Main c:\Users\peter\Documents\Julia_Code\MPC_Development\Quadratic_Optimization.jl:21
[2] example_qcp()
@ Main c:\Users\peter\Documents\Julia_Code\MPC_Development\Quadratic_Optimization.jl:12
[3] top-level scope
@ c:\Users\peter\Documents\Julia_Code\MPC_Development\Quadratic_Optimization.jl:36
in expression starting at c:\Users\peter\Documents\Julia_Code\MPC_Development\Quadratic_Optimization.jl:36
The text was updated successfully, but these errors were encountered:
optimize! was added in JuMP v0.19, I would guess you are using an older version. Maybe another package like JuMPeR is holding JuMP's version back. Try using a local project with Pkg.activate(".") to avoid any conflicts between packages used by different projects
Thanks for responding and help. I replaced all of the "import" statements with "using" and the program worked. Just to mention I am running the script using VScode under Windows 10 using Julia 1.6.2
Hi,
I have tried running several of the examples from the docs only to get the error that optimize! is undefined. Please see code taken from docs below. Hope someone can help? Probably need to inlcude another package?
Thanks,
Peter
The text was updated successfully, but these errors were encountered: