Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use matrix fill mode when filling the formulations #427

Merged
merged 14 commits into from
Dec 29, 2020
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ TimerOutputs = "a759f4b9-e2f1-59dc-863e-4aeb61b1ea8f"
[compat]
BlockDecomposition = "1.2.3"
DataStructures = "0.17, 0.18"
DynamicSparseArrays = "0.2.4"
DynamicSparseArrays = "0.3.0"
MathOptInterface = "0.9.10"
Parameters = "0.12"
TimerOutputs = "0.5"
Expand Down
1 change: 0 additions & 1 deletion src/Algorithm/colgen.jl
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,6 @@ function updatereducedcosts!(reform::Reformulation, redcostsvec::ReducedCostsVec
end

for (i, varid) in enumerate(redcostsvec.varids)
# setcurcost!(redcostsvec.form[i], varid, redcosts[i] + sign * terms[varid])
setcurcost!(redcostsvec.form[i], varid, redcosts[i] - terms[varid])
end
return redcosts
Expand Down
1 change: 1 addition & 0 deletions src/Coluna.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Distributed
import TimerOutputs
import Base.Threads

using DynamicSparseArrays
using Logging, Parameters, Printf

global const BD = BlockDecomposition
Expand Down
13 changes: 5 additions & 8 deletions src/MathProg/clone.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,15 @@ function cloneconstr!(
)
end

function clonecoeffs!(originform::Formulation,
destform::Formulation)
function clonecoeffs!(originform::Formulation, destform::Formulation)
dest_matrix = getcoefmatrix(destform)
orig_matrix = getcoefmatrix(originform)
for (cid, constr) in getconstrs(destform)
if haskey(originform, cid)
for (vid, var) in getvars(destform)
if haskey(originform, vid)
val = orig_matrix[cid, vid]
if val != 0
dest_matrix[cid, vid] = val
end
row = @view orig_matrix[cid, :]
for (vid, val) in row
if haskey(destform, vid) && val != 0
dest_matrix[cid, getid(getvar(destform, vid))] = val
end
end
end
Expand Down
6 changes: 3 additions & 3 deletions src/MathProg/manager.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ function FormulationManager()
vars,
constrs,
dynamicsparse(ConstrId, VarId, Float64),
dynamicsparse(VarId, VarId, Float64),
dynamicsparse(VarId, VarId, Float64),
dynamicsparse(VarId, VarId, Float64; fill_mode = false),
dynamicsparse(VarId, VarId, Float64; fill_mode = false),
dynamicsparsevec(VarId[], Float64[]),
dynamicsparse(ConstrId, ConstrId, Float64),
dynamicsparse(ConstrId, ConstrId, Float64; fill_mode = false),
dynamicsparsevec(ConstrId[], Float64[]),
RobustConstraintsGenerator[]
)
Expand Down
7 changes: 7 additions & 0 deletions src/decomposition.jl
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,7 @@ function buildformulations!(
assign_orig_vars_constrs!(masterform, origform, annotations, ann)
create_side_vars_constrs!(masterform, origform, annotations)
create_artificial_vars!(masterform)
closefillmode!(getcoefmatrix(masterform))
initialize_optimizer!(masterform, getoptbuilder(prob, ann))
initialize_optimizer!(origform, getoptbuilder(prob, ann))
return
Expand All @@ -451,22 +452,28 @@ function buildformulations!(
origform = get_original_formulation(prob)
assign_orig_vars_constrs!(spform, origform, annotations, ann)
create_side_vars_constrs!(spform, origform, annotations)
closefillmode!(getcoefmatrix(spform))
initialize_optimizer!(spform, getoptbuilder(prob, ann))
return
end

function reformulate!(prob::Problem, annotations::Annotations)
closefillmode!(getcoefmatrix(prob.original_formulation))
decomposition_tree = annotations.tree
root = BD.getroot(decomposition_tree)
# Create reformulation
reform = Reformulation()
set_reformulation!(prob, reform)
buildformulations!(prob, annotations, reform, reform, root)

# println("*****------------*****")
# @show get_original_formulation(prob)
# println("---------")
# @show reform.master
# for (id, sp) in reform.dw_pricing_subprs
# println("*****")
# @show sp
# end
# println("*****------------*****")
return
end
2 changes: 1 addition & 1 deletion src/optimize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function optimize!(prob::MathProg.Problem, annotations::Annotations, params::Par

# Apply decomposition
reformulate!(prob, annotations)

# Coluna ready to start
_globals_.initial_solve_time = time()
@logmsg LogLevel(-1) "Coluna ready to start."
Expand Down
2 changes: 1 addition & 1 deletion test/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ MathOptInterface = "b8f27783-ece8-5eb3-8dc8-9495eed66fee"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
LightGraphs = "093fc24a-ae57-5d10-9952-331d41423f4d"
Parameters = "d96e819e-fc66-5662-9728-84c9c7592b0a"
Parameters = "d96e819e-fc66-5662-9728-84c9c7592b0a"