jump-dev / HiGHS.jl

A Julia interface to the HiGHS solver
https://highs.dev
MIT License
108 stars 15 forks source link

Simple model run issues #129

Closed nemoincognito closed 2 years ago

nemoincognito commented 2 years ago

I am running a very mickey mouse model using HiGHS and JuMP:

using JuMP, HiGHS
m = Model(HiGHS.Optimizer)
set_optimizer_attribute(m, "presolve","on")
set_optimizer_attribute(m, "time_limit", 60.0)
set_optimizer_attribute(m, "solver", "simplex")
@variable(m, 0<= x1 <= 10)
@variable(m, x2>= 0)
@variable(m, x3>=0)
@objective(m, Max, x1 + 2x2 + 5x3)
@constraint(m, constraint1, -x1 + x2 + 3x3 <= -5)
@constraint(m, constraint2, x1+ 3x2 -7x3 <= 10)
print(m)
solve(m)
println("Optimal Solutions:")
println("x1 = ", getvalue(x1))
println("x2 = ", getvalue(x2))
println("x3 = ", getvalue(x3))

println("Dual Variables")
println("dual1 = ", getdual(constraint1))
println("dual2 = ", getdual(constraint2))

But keep getting the error below:

UndefVarError: solve not defined

Any suggestions as to what might be going on here? Running Julia in VSCode, installation of JuMP and HiGHS packages went fine.

blegat commented 2 years ago

The functions solve, getvalue and getdual belong to old versions of JuMP. Make sure you get the documentation by going to https://jump.dev/ and then clicking on "Documentation"

odow commented 2 years ago

Closing because this is not a bug in JuMP or HiGHS.

The documentation is here: https://jump.dev/JuMP.jl/stable/

In particular, you might want to read https://jump.dev/JuMP.jl/stable/manual/solutions/.

If you have more questions, please post on the community forum: https://discourse.julialang.org

nemoincognito commented 2 years ago

Many thanks, looks like the Julia Programming for OR book is now very out of date!

odow commented 2 years ago

looks like the Julia Programming for OR book is now very out of date!

Did you read the second edition? Can you point to which examples/chapters are out of date?

cc @chkwon

chkwon commented 2 years ago

@nemoincognito You can read the second edition for free here:

http://juliabook.chkwon.net

Please let me know if you find any code or content that needs to be updated!