julia> versioninfo()Julia Version 0.2.0Commit 05c6461 (2013-11-16 23:44 UTC)Platform Info:System: Windows (x86_64-w64-mingw32)WORD_SIZE:julia>64julia>BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY)LAPACK: libopenblasLIBM: libopenlibmjulia> Pkg.status()Required packages:- DataFrames 0.4.2- Distributions 0.3.0- GLM 0.2.4- GLPK 0.2.10- GSL 0.1.1- GnuTLS 0.0.0- MixedModels 0.2.3- NLopt 0.0.3- NumericExtensions 0.3.6- RDatasets 0.1.1- Stats 0.1.0- Winston 0.9.0Additional packages:- BinDeps 0.2.12- Blocks 0.0.2- Cairo 0.2.12- Color 0.2.9- DataArrays 0.0.2- GZip 0.2.12- HTTPClient 0.1.1- IniFile 0.2julia>.2- LibCURL 0.1.1- LibExpat 0.0.4- Nettle 0.1.3- SortingAlgorithms 0.0.1- StatsBase 0.2.10- Tk 0.2.11- URIParser 0.0.1- URLParse 0.0.0- WinRPM 0.0.13- Zlib 0.1.5
for i = 1:n
for j = 1:n
# ...
end
end
for i = 1:n, j=1:n
# ...
end
ia,ja,ar = findnz(sparse(A))
GLPK.load_matrix(lp, sparse(A))
About GLPK.exact it is not possible to get the rational number 3/28 instead of a decimal approximation ?
using JuMP
m = Model()
@defVar(m, p[1:n,1:n] >= 0)
@setObjective(m, Max, sum{p[i,j], i in 1:n; i != j})
for k in 1:n
@addConstraint(m, sum(p[k,:]) == μ[k])
@addConstraint(m, sum(p[:,k]) == ν[k])
end
solve(m)
println("Optimal objective value is:", getObjectiveValue(m))
By the way for another problem I need to get the vertices of the polyhedron defined by the linear constraints, as with the cddlib library, do you know how I could get that ?
There was a Julia age during which BigInt(3)/BigInt(28) was equal to the BigRational 3/28, why this feature has been removed ?
using RationalSimplex
using Base.Test
b = [1//7, 2//7, 4//7, 1//4, 1//4, 1//2]
c = [0//1, 1//1, 1//1, 1//1, 0//1, 1//1, 1//1, 1//1, 0//1]
c = [c, repmat([0//1], size(b)[1])] # surely clumsy
M = [1//1 1//1 1//1 0//1 0//1 0//1 0//1 0//1 0//1;
0//1 0//1 0//1 1//1 1//1 1//1 0//1 0//1 0//1;
0//1 0//1 0//1 0//1 0//1 0//1 1//1 1//1 1//1;
1//1 0//1 0//1 1//1 0//1 0//1 1//1 0//1 0//1;
0//1 1//1 0//1 0//1 1//1 0//1 0//1 1//1 0//1;
0//1 0//1 1//1 0//1 0//1 1//1 0//1 0//1 1//1]
Id = zeros(Rational{Int64}, size(M)[1], size(M)[1])
for i in 1:size(M)[1]
Id[i,i] = 1//1
end
M = hcat(M, Id)
julia> simplex(c, :Min, M, b, ['=','=','=','=','=','='])(:Optimal,[1//7,0//1,0//1,0//1,1//4,0//1,0//1,0//1,1//2,0//1,1//28,1//14,3//28,0//1,0//1])
using JuMP
mu = [1/7, 2/7, 4/7]
nu = [1/4, 1/4, 1/2]
n = length(mu)
m = Model()
@defVar(m, p[1:n,1:n] >= 0)
@setObjective(m, Min, sum{p[i,j], i in 1:n, j in 1:n; i != j})
for k in 1:n
@addConstraint(m, sum(p[k,:]) == mu[k])
@addConstraint(m, sum(p[:,k]) == nu[k])
end
solve(m)
julia> println("Optimal objective value is:", getObjectiveValue(m))
Optimal objective value is:0.10714285714285715
julia> 3/28
0.10714285714285714
using GLPKMathProgInterface
m = Model(solver=GLPKSolverLP(method=:Exact))
If I don't call GLPKMathProgInterface, does JuMP use an internal solver ?