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

Refactor pool of solutions for DwSp & insertion of a column #609

Merged
merged 10 commits into from
Oct 25, 2021

Conversation

guimarqu
Copy link
Contributor

@guimarqu guimarqu commented Oct 6, 2021

Changes

  1. Move the pool of primal solutions from the Formulation to the DwSp duty because it's specific to pricing problems.

  2. Refactor column insertion.
    Before, we had to call two methods to insert a new column in the master formulation. These two methods were always called together.

var_was_inserted, sol_id = ClMP.setprimalsol!(cbdata.form, sol)
if var_was_inserted
    mc_1 = ClMP.setcol_from_sp_primalsol!(
        masterform, cbdata.form, sol_id, string("MC_", ClA.getsortuid(sol_id)), ClMP.MasterCol
    )
else
    mc_1 = ClMP.getvar(masterform, sol_id)
end

Now, one method does the job.

_, col_id = ClMP.insert_column!(masterform, sol, "MC")

Consequence

In column generation, the insertion of a column in the pool is not parallelized anymore.

it's not possible to parallelize column insertion because of concurrent access to the master formulation. Therefore, we created setprimalsol! method to insert the solution in the pool because we wanted to parallelized insertions of solutions in the pool of subproblems. However, I think that we do not gain a lot of performance because Coluna spends most of the time solving the subproblem. Since the tradeoff performance/code simplicity is in favor of the latter, I think we can drop parallelized insertion.

About the data structure of the pool

My initial idea was to replace the dynamic sparse matrix that stores the pool with a dict of dict.
This is more complicated than I thought.

First, we use column and row views (i.e. variables used by a given column and columns that contain a given variable). It makes the change more complicated because we need to maintain two data structures, a col-major one and a row-major one.

Second, I thought Dictionary was supporting Sorted Dict. Actually, it's an OrderedDict that preserves only the order of insertion. We may use a SortedDict from DataStructures but it does not implement math operations with arrays.

So I suggest to not change the data structure for now and improve the performance of DynamicSparseArrays.

@codecov
Copy link

codecov bot commented Oct 6, 2021

Codecov Report

Merging #609 (b4f137b) into master (a4d23e1) will increase coverage by 0.00%.
The diff coverage is 87.20%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #609   +/-   ##
=======================================
  Coverage   86.24%   86.25%           
=======================================
  Files          48       48           
  Lines        5047     5057   +10     
=======================================
+ Hits         4353     4362    +9     
- Misses        694      695    +1     
Impacted Files Coverage Δ
src/Coluna.jl 100.00% <ø> (ø)
src/MathProg/manager.jl 61.76% <ø> (ø)
src/Algorithm/colgen.jl 83.54% <70.00%> (-1.25%) ⬇️
src/MathProg/formulation.jl 78.59% <98.24%> (+0.39%) ⬆️
src/Algorithm/preprocessing.jl 76.68% <100.00%> (-0.25%) ⬇️
src/MOIwrapper.jl 85.48% <100.00%> (ø)
src/MathProg/clone.jl 100.00% <100.00%> (ø)
src/MathProg/duties.jl 69.23% <100.00%> (+2.56%) ⬆️
src/MathProg/projection.jl 95.23% <100.00%> (ø)
src/MathProg/vcids.jl 81.48% <100.00%> (+2.31%) ⬆️
... and 6 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a4d23e1...b4f137b. Read the comment docs.

@guimarqu guimarqu mentioned this pull request Oct 9, 2021
5 tasks
@guimarqu guimarqu marked this pull request as ready for review October 19, 2021 16:49
src/Algorithm/colgen.jl Outdated Show resolved Hide resolved
src/Algorithm/colgen.jl Outdated Show resolved Hide resolved
@guimarqu guimarqu merged commit 7679fcb into master Oct 25, 2021
@guimarqu guimarqu deleted the setprimalsol_perf branch October 25, 2021 19:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants