How use the solver GLPKSolverLP ?
using JuMP, GLPKMathProgInterface
m = Model(solver = GLPKSolverLP())
...
solve(m)
There is a README https://github.com/JuliaOpt/GLPKMathProgInterface.jl
If you have integer variables, you will need to use GLPKSolverMIP()
.
Could you give us the errors that you see ?
This is the error message
: UndefVarError: GLPKSolverLP not defined
using JuMP
using GLPKMathProgInterface
myModel = Model(solver=GLPKSolverLP()) **
UndefVarError: GLPKSolverLP not defined
Just to be safe do Pkg.update("JuMP"); Pkg.update("GLPKMathProgInterface")
. Then do Pkg.status("GLPKMathProgInterface")
and make sure that it returns 0.4.0
. (The current package manager is extremely wonky, don’t worry, it is being replaced relatively soon.)
returned this error message for the update:
METADATA cannot be updated. Resolve problems manually in C:\Users\raquel.santos\Documents\JuliaPro-0.6.2.1\pkgs-0.6.2.1\v0.6\METADATA.
And for the Pkg.status, returned this error message:
GitError(Code:ENOTFOUND, Class:Repository, Could not find repository from ‘DocStringExtensions’)
Ugh, yeah sounds like the package manager has gotten badly screwed up. Unfortunately it’s way to easy for that to happen right now, like I said, it will be fixed but it’s still a bit of a ways off.
Ok, I think you should do the following
Pkg.update() # may error
# at this point try `GLPKSolverLP()` one more time
# if it doesn't work, do the following:
Pkg.rm("GLPKMathProgInterface")
Pkg.rm("JuMP")
Pkg.update() # hopefully won't error now
Pkg.add("JuMP")
Pkg.add("GLPKMathProgInterface")
Hopefully this will clean up your package metadata.
Do you by any chance have uncommitted changes in your METADATA or other packages? If so, the package manager avoids wiping those, so you will have to manually get everything on a real commit.
Now I saw that the Julia can’t find the file GLPK.ji. I’ve tryed to find this file manually but seems that it simply doesn’t exist. I’ve search in all the directories, but i had no success.
Now I saw that the Julia can’t find the file GLPK.ji. I’ve tryed to find this file manually but seems that it simply doesn’t exist. I’ve search in all the directories, but i had no success.
using JuMP
using GLPKMathProgInterface
myModel = Model(solver=GLPKSolverLP()) UndefVarError: GLPKSolverLP not defined # the error
#myModel = Model(solver=GLPKSolverMIP())
solve(myModel)
#VARIABLES
@defVar(myModel, x1 >= 0)
@defVar(myModel, x2 >= 0)
#OBJECTIVE
@setObjective(myModel, Max, 12x1 + 60x2)
#CONSTRAINTS
@addConstraint(myModel, 0.25x1 + 0.5x2 <= 36)
@addConstraint(myModel, 0.1x1 + 0.75x2 <= 22)
@addConstraint(myModel, 0.1x1 + 0.4x2 <= 15)
#THE MODEL IN A HUMAN-READABLE FORMAT
println(“The optimization problem to be solved is:”)
print(myModel)
#SOLVE IT AND DISPLAY THE RESULTS
status = solve(myModel) # solves the model
println("Objective value: ", getObjectiveValue(myModel))
println("x1 = ", getValue(x1))
println("x2 = ", getValue(x2))
I’m very confused. It shouldn’t need to find any *.ji
files, it should just recompile them. Have you made changes to the Julia directory structure? Assuming you are on 0.6, you should see .julia/lib/v0.6
(this stores the *.ji
binaries) and .julia/v0.6
(stores source code). You can try deleting lib
regardless, as Julia should just recompile anything that it doesn’t find there. Can you please post the explicit errors you are getting?
Also, your problem declaration doesn’t look right to me, see the JuMP documentation. Also note that you can do pretty much anything in your variable and constraint macros that you’d be able to do in regular Julia code, so for example, your problem could be
A = [0.25 0.50;
0.10 0.75;
0.10 0.40]
b = [36, 22, 15]
c = [12, 60]
@variable(m, x[1:2] ≥ 0)
@objective(m, Max, c⋅x)
@constraint(m, A*x .≤ b)
Sorry, I could not explain with clarity the error that was happening, but through your help I was able to compile the model that I needed. Thanks
Sorry, I could not explain with clarity the error that was happening, but through your help I was able to compile the model that I needed. Thanks.