How can i fix Julia error? - julia

I am using Julia version 0.5.2.
julia> addprocs(4);
julia> a=rand(8,8);
julia> distribute(a,2)
When I try to use this codes,I get the error:
ERROR: UndefVarError: distribute not defined
How do i must do?
thanks in advance.

You need to add the DistributedArrays.jl package.
Pkg.add("DistributedArrays"); using DistributedArrays

Related

How to determine Gurobi or solver version in JuMP

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.

How to fix LoadError for loading Escher in julia?

I'm a beginner to julia and I'm having the problem for loading Escher in julia. Every time when I wanted to import the Package Escher it always has the problems saying:
WARNING: could not import Base.writemime into Escher
ERROR: LoadError: LoadError: syntax: ""A Tile is the basic currency in Escher.
Most of the functions in the Escher API take Tiles
among other things as arguments, and return a Tile as the result.
Tiles are immutable: once created there is no way to mutate them.
"" is not a valid function argument name
Does anyone know how to fix it? Thanks. By the way I'm using julia v0.7. I've tried in julia 1.0 before and it also didn't work.

JULIA : LoadError: UndefVarError: add_vertex! not defined

I am trying to create a simple type of Graph before putting more efforts on the bigger one I will have to create with data implementation and I figured out that add_vertex! was exactly what I needed to add a special type of vertex into my graph.
Here is the simple example I tried and I get the reply that add_vertex! is not defined..
module VSRPGraphModule
using Graphs, LightGraphs, MetaGraphs
g = DiGraph()
println(g)
v=ExVertex(1,"ex")
port=VSRPPort()
FillPort(port,"La Havane",10)
v.attributes["port"]=port
println(v.attributes["port"].name)
add_vertex!(g,v)
println(g)
end
And the codes stops at the add_vertex! line returning:
LoadError: UndefVarError: add_vertex! not defined
I did Pkg.update()
I did put the package into julia.
I really don't know why it is not working, is it a problem of the new Julia version 0.6.9 ?
Thanks in advance for your help !
tl;dr Try just using LightGraphs + MetaGraphs (not Graphs).
LightGraphs and Graphs are separate packages and I don't think they work together. IIRC Graphs is no longer maintained so if you can then just use LightGraphs.
Regardless, if you try to use two packages that export the same method (add_vertex!) you'll need to specify which one you want to call.
e.g. Graphs.add_vertex! or LightGraphs.add_vertex!.

NameError: name 'Pkg' is not defined

In the IJulia Notebook I'm trying to add the packages, but I'm getting the error:
NameError: name 'Pkg' is not defined
Python was wrongly selected instead of Julia in Jupyter:
Here's what happens in Julia:
And here's what happens in Python:
For me I had a very similar error, and apparently you have to define Pkg if you're installing this for the first time. Just enter
using Pkg
It looks like in your case the issue was you were using python but this is a fix for another case where you get this exact same error.

Julia studio write() error

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.

Resources