In Python, you can do:
print(gurobipy.gurobi.version())
What is the equivalent for Julia and JuMP?
I tried
using Gurobi
Gurobi.version()
Without success. I am not trying to get Gurobi.jl package version which can be obtained with ] status Gurobi.
There are three integer variables for this you need to combine them to get the full version number:
julia> println("Grurobi version: $(Gurobi.GRB_VERSION_MAJOR).$(Gurobi.GRB_VERSION_MINOR).$(Gurobi.GRB_VERSION_TECHNICAL)")
Grurobi version: 9.5.0
#przemyslaw-szufel's answer is mostly correct, but it can be wrong with the minor version. The constants he refers to are actually the ones we copy from the gurobi.h file, not from the Gurobi library itself, so you might get v9.5.0 returned when the actual library is v9.5.1.
You can get the exact version using:
julia> using Gurobi
julia> const MOI = Gurobi.MOI
MathOptInterface
julia> v = MOI.get(Gurobi.Optimizer(), MOI.SolverVersion())
"9.1.0"
julia> VersionNumber(v)
v"9.1.0"
this is mostly solver-independent, although not all packages support MOI.SolverVersion.
Related
I have a problem with using packages in Julia. It has worked before, and I'm not really sure why this has changed or how to troubleshoot.
I have a folder
/my_path/julia/packages
with Julia packages. For example, there is a folder
/my_path/julia/packages/FFTW/
with the FFTW package.
Further, I have changed the depot path to point at this directory by assigning JULIA_DEPOT_PATH before starting julia, so that
Base.DEPOT_PATH = ["/my_path/julia/"]
However, if I run
julia> using FFTW
I get the following error message:
ERROR: ArgumentError: Package FFTW not found in current path:
- Run `import Pkg; Pkg.add("FFTW")` to install the FFTW package.
Any idea how I can troubleshoot or fix this?
Manipulating Base.DEPOT_PATH does not seem like a good idea.
The code proposed by #cmc will does not work (at least on Julia 1.3.1):
julia> Base.DEPOT_PATH = ["/some/path"]
ERROR: cannot assign variables in other modules
There is a workaround:
Base.DEPOT_PATH[1] = "/some/path"
However, the correct way is to assign the JULIA_DEPOT_PATH system variable before starting Julia, Windows:
set JULIA_DEPOT_PATH=c:\some\path
or
set JULIA_DEPOT_PATH=c:\some\path1;c:\some\path2
Linux/OSX:
export JULIA_DEPOT_PATH=/some/path
or
export JULIA_DEPOT_PATH=/some/path1:/some/path2
Unless you have a specific reason to do so (and if this is the case I'd be interested to hear it!), you don't need to fiddle with the DEPOT_PATH or LOAD_PATH variables: using Julia's package manager should be enough to cover your needs most of the time.
In this specific instance, have you tried to do what the error message suggests?
julia> import Pkg
julia> Pkg.add("FFTW")
LOAD_PATH, not DEPOT_PATH, will modify code loading.
You want to do something like push!(LOAD_PATH, /my_path/julia/packages).
I will echo #ffevotte and strongly suggest to not modify LOAD_PATH unless necessary. The benefits of organizing dependencies into Pkg environments far outweigh the small overhead of declaring them explicitly through Pkg.add.
Basically, I have an MIP completely defined, everything is working, until I attempt to solve via GLPK, when it gives me the following error: UndefVarError: floatmax not defined
I tried defining floatmax as anything, but to no avail. I'm completely stuck. Here's an image of my code and the problem:
1
It looks like you have an old version of Compat installed. Try running Pkg.update(). floatmax is defined on Julia 0.6 beginning with Compat 1.1.0. I fixed the version requirements here: https://github.com/JuliaOpt/GLPKMathProgInterface.jl/pull/55.
The problem is that you are working under Julia 0.6 and floatmax is internally used by the GLPKMathProgInterface.jl package.
Possible solutions are:
Swithch to Julia 1.0 (recommended)
Install an older version of GLPKMathProgInterface.jl before it was ported to Julia 1.0; release v0.4.2 should be ok
Manually add the following definition in the source file GLPKMathProgInterface.jl before include section:
floatmax(::Type{Float64}) = prevfloat(Float64(Inf))
(I have not run it as I do not have Julia 0.6 any more, but it should work; the risk is that even if you fix this some more fixes like this might be needed - so option 3 is not really recommended, but it might work so I am giving it)
I am trying to use JumP and Ipopt under Julia v0.7.0. When I try to construct a model:
julia> m = Model(solver=IpoptSolver())
I get the following error message:
Feasibility problem with:
* 0 linear constraints
* 0 variables
Solver is Error showing value of type Model:
ERROR: BoundsError: attempt to access 1-element Array{SubString{String},1} at index [2]
I am using the following versions of the packages:
Ipopt v0.4.0
JuMP v0.18.2
Any ideas? Thanks!
JuMP v0.18.2 does not support Julia v0.7, see this post.
If you want to use JuMP with Julia v0.7 or Julia v1.0 you should just the in-development version of JuMP that will be released as JuMP v0.19 when it is ready.
EDIT: JuMP v0.18.3 now supports Julia v1.0.
I have a pickle file that is written by using python (By using cPickle). I need to use it inside julia. I guess I can use PyCall for that purpose.Here is what I've done so far:
julia> using PyCall
julia> #pyimport cPickle as pickle
julia> f=open("mypicklefile.picle","r")
julia> PyTextIO(f)[:seek](0) #if I don't do this, I got error.
julia> trn,tst= pickle.load(PyTextIO(f))
Here,I have two questions. As far as I know, unlike Julia, python(numpy) is rowmajor. So, what should I do to read the content of file in a correct way? I guess somehow I have to tell the PyCall it is written in rowmajor order.
My second question is about performance. The pickle file is about 4.5GB. When I read it inside python, it is completed in a minute whereas in julia it takes at least 15 minutes. Am I doing something wrong ? Since the file is not created by me, I cannot use another format such as hdf5 or jld.
I am getting the weirdest error in using the write()function:
julia> write(0.1)
�8
julia>
������?
These are just the commands I'm writing in the console, as you can see. What could be going wrong?
Note: I'm using Julia Studio 0.4.4
From the documentation:
write(stream, x): Write the canonical binary representation of a value to the given stream.
I suspect that you want to use print rather than write.