Skip to content

Commit

Permalink
avoid generating rows for variables already in varcones
Browse files Browse the repository at this point in the history
  • Loading branch information
mlubin committed Jun 4, 2016
1 parent fcf1365 commit c7073c5
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 19 deletions.
2 changes: 1 addition & 1 deletion REQUIRE
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
julia 0.4
MathProgBase 0.5 0.6
MathProgBase 0.5.1 0.6
ReverseDiffSparse 0.5.3 0.6
ForwardDiff 0.1 0.2
Calculus
Expand Down
6 changes: 3 additions & 3 deletions src/JuMP.jl
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ function getdual(c::LinConstrRef)
return c.m.linconstrDuals[c.idx]
end

# Returns the number of non-infinity bounds on variables
# Returns the number of non-infinity and nonzero bounds on variables
function getNumBndRows(m::Model)
numBounds = 0
for i in 1:m.numCols
Expand All @@ -543,10 +543,10 @@ function getNumBndRows(m::Model)
end

if !seen
if lb != -Inf
if lb != -Inf && lb != 0
numBounds += 1
end
if ub != Inf
if ub != Inf && ub != 0
numBounds += 1
end
end
Expand Down
23 changes: 13 additions & 10 deletions src/solvers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,20 @@ end
function fillConicRedCosts(m::Model)
bndidx = 0
numlinconstr = length(m.linconstr)
vardual = MathProgBase.getvardual(m.internalModel)
if m.objSense == :Min
scale!(vardual, -1)
end
for i in 1:m.numCols
lower = false
upper = false
lb, ub = m.colLower[i], m.colUpper[i]

if lb != -Inf
if lb != -Inf && lb != 0.0
lower = true
bndidx += 1
end
if ub != Inf
if ub != Inf && ub != 0.0
upper = true
bndidx += 1
end
Expand All @@ -77,6 +81,7 @@ function fillConicRedCosts(m::Model)
elseif lower && upper
m.redCosts[i] = m.conicconstrDuals[numlinconstr + bndidx]+m.conicconstrDuals[numlinconstr + bndidx-1]
end
m.redCosts[i] += vardual[i]
end
end

Expand All @@ -91,15 +96,13 @@ function fillConicDuals(m::Model)
catch
fill(NaN, numRows+numBndRows+numSOCRows)
end
if m.conicconstrDuals[1] != NaN
if isfinite(m.conicconstrDuals[1]) # NaN could mean unavailable
if m.objSense == :Min
scale!(m.conicconstrDuals, -1)
end
m.linconstrDuals = m.conicconstrDuals[1:length(m.linconstr)]
m.redCosts = zeros(numCols)
if numBndRows > 0
fillConicRedCosts(m)
end
fillConicRedCosts(m)
end

end
Expand Down Expand Up @@ -725,10 +728,10 @@ function conicdata(m::Model)
end

if !seen
if lb != -Inf
if lb != -Inf && lb != 0
numBounds += 1
end
if ub != Inf
if ub != Inf && ub != 0
numBounds += 1
end
if lb == 0 && ub == 0
Expand Down Expand Up @@ -828,7 +831,7 @@ function conicdata(m::Model)
bndidx = 0
for idx in 1:m.numCols
lb = m.colLower[idx]
if lb != -Inf
if lb != -Inf && lb != 0
bndidx += 1
nnz += 1
c += 1
Expand All @@ -840,7 +843,7 @@ function conicdata(m::Model)
constr_dual_map[numLinRows + bndidx] = collect(c)
end
ub = m.colUpper[idx]
if ub != Inf
if ub != Inf && ub != 0
bndidx += 1
c += 1
push!(I, c)
Expand Down
6 changes: 3 additions & 3 deletions test/sdp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ context("With solver $(typeof(solver))") do
n = 100

mod = Model(solver=solver)
@variable(mod, x[j=1:p] >= 0, Int)
@variable(mod, u[i=1:q] >= 0)
@variable(mod, x[j=1:p] >= 1, Int)
@variable(mod, u[i=1:q] >= 1)
@objective(mod, Min, sum(u))
@constraint(mod, sum(x) <= n)
for i=1:q
Expand All @@ -187,7 +187,7 @@ context("With solver $(typeof(solver))") do
@fact length(f) --> 8
@fact size(A) --> (23,8)
@fact length(b) --> 23
@fact var_cones --> [(:NonNeg,[1,2,3,4,5,6,7,8])]
@fact var_cones --> [(:Free,[1,2,3,4,5,6,7,8])]
@fact con_cones --> [(:NonNeg,[1]),(:NonPos,[2,3,4,5,6,7,8,9]),(:SDP,10:15),(:Zero,16:16),(:SDP,17:22),(:Zero,23:23)]
end; end; end

Expand Down
2 changes: 1 addition & 1 deletion test/socduals.jl
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ context("With conic solver $(typeof(conic_solver))") do

inf_ray = getdual(c2)
@fact status --> :Infeasible
@fact (-inf_ray[1] - inf_ray[2]) --> less_than_or_equal(-TOL)
@fact inf_ray[1] abs(inf_ray[2]) - TOL --> true
@fact -(-inf_ray[1]) --> greater_than_or_equal(TOL)

end
Expand Down
2 changes: 1 addition & 1 deletion test/solvers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ cbc && push!(sos_solvers, Cbc.CbcSolver())
conic_solvers_with_duals = Any[]
eco && push!(conic_solvers_with_duals, ECOS.ECOSSolver(verbose=false))
scs && push!(conic_solvers_with_duals, SCS.SCSSolver(eps=1e-6,verbose=0))
#mos && push!(conic_solvers_with_duals, Mosek.MosekSolver(LOG=0))
mos && push!(conic_solvers_with_duals, Mosek.MosekSolver(LOG=0))
# Callback solvers
lazy_solvers, lazylocal_solvers, cut_solvers, cutlocal_solvers, heur_solvers, info_solvers = Any[], Any[], Any[], Any[], Any[], Any[]
if grb
Expand Down

0 comments on commit c7073c5

Please sign in to comment.