Hi,
I am trying to run that small code that comes from Introduction to Julia
using JuMP, Clp
m = Model()
@variable(m, x >=0)
@variable(m, y >=0)
@objective(m, Min, 10x + 26y)
@constraint(m, const1, 11x + 3y >= 21)
@constraint(m, const2, 6x + 20y >= 39)
status = solver(m)
println("Status = $status")
println("Optimal Objective Function value: ", getobjectivevalue(m))
println("Optimal Solutions:")
println("x = ", getvalue(x))
println("y = ", getvalue(y))
Hower I get that error :
ERROR: UndefVarError: solver not defined
I tried to put :
m = Model(solver = ClpSolver())
but then I got the error:
UndefVarError: ClpSolver not defined
The versions installed are as follow:
[e2554f3b] Clp v1.0.2
[2e9cd046] Gurobi v1.0.0
[4076af6c] JuMP v1.10.0
Thanks a lot for your help !
It’s solve
instead of solver
odow
3
That documentation is unofficial and refers to a very old version of JuMP. You shouldn’t refer to it.
Use the official documentation instead. Here’s a tutorial to get started:
The proper syntax for your example is
using JuMP, Clp
m = Model(Clp.Optimizer)
@variable(m, x >= 0)
@variable(m, y >= 0)
@objective(m, Min, 10x + 26y)
@constraint(m, const1, 11x + 3y >= 21)
@constraint(m, const2, 6x + 20y >= 39)
optimize!(m)
status = termination_status(m)
println("Status = $status")
println("Optimal Objective Function value: ", objective_value(m))
println("Optimal Solutions:")
println("x = ", value(x))
println("y = ", value(y))
Thanks for your answer. But when running, Julia crashes . Would you know why ?
EDIT : Very briefly before crashing, this error appears.
EDIT 2 : I tried with GLPK optimizer, and it works. There seems to be an issue with Clp, could you help me understand that ?