jump-dev / Dualization.jl

Automatic dualization feature for MathOptInterface.jl
Other
97 stars 6 forks source link

Skip object dictionary setting if there are no name #138

Closed blegat closed 2 years ago

blegat commented 2 years ago

Getting the set and function repeatedly for each index of the same constraint is slower than getting it once for each constraint.

On the benchmark of https://github.com/jump-dev/MathOptInterface.jl/issues/1796, in terms of allocations:

theta1 thetaG11
v0.5.2 14.693 MB 793.687 GB
https://github.com/jump-dev/Dualization.jl/pull/135 0.395 MB 0.039 GB
https://github.com/jump-dev/Dualization.jl/pull/136 0.349 MB 0.029 GB
https://github.com/jump-dev/Dualization.jl/pull/137 0.349 MB 0.029 GB
https://github.com/jump-dev/Dualization.jl/pull/138 0.300 MB 0.019 GB
Reading https://github.com/jump-dev/Dualization.jl/issues/134#issuecomment-1086224548 0.538 MB 0.014 GB

and in terms of time:

theta1 thetaG11
v0.5.2 28.5 ms 232 s
https://github.com/jump-dev/Dualization.jl/pull/135 0.586 ms 0.108 s
https://github.com/jump-dev/Dualization.jl/pull/136 0.397 ms 0.068 s
https://github.com/jump-dev/Dualization.jl/pull/137 0.246 ms 0.029 s
https://github.com/jump-dev/Dualization.jl/pull/138 0.183 ms 0.016 s
Reading https://github.com/jump-dev/Dualization.jl/issues/134#issuecomment-1086224548 1.95 ms 0.021 s

Overall, for thetaG11, this gives a 40000x speedup in allocation and 14000x speedup in time. Moreover, it's now below the time for reading the SDPA file in geometric format so it's unclear that reading it in standard form would be a huge gain compared to reading it in geometric format + dualizing so it closes https://github.com/jump-dev/Dualization.jl/issues/134.

Closes https://github.com/jump-dev/Dualization.jl/issues/134

codecov[bot] commented 2 years ago

Codecov Report

Merging #138 (688ce41) into master (b11fc8a) will increase coverage by 0.27%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #138      +/-   ##
==========================================
+ Coverage   92.62%   92.90%   +0.27%     
==========================================
  Files          12       12              
  Lines         610      662      +52     
==========================================
+ Hits          565      615      +50     
- Misses         45       47       +2     
Impacted Files Coverage Δ
src/dualize.jl 96.42% <100.00%> (+0.42%) :arrow_up:
src/dual_model_variables.jl 86.95% <0.00%> (-1.14%) :arrow_down:
src/utils.jl 100.00% <0.00%> (ø)
src/dual_sets.jl 100.00% <0.00%> (ø)
src/structures.jl 100.00% <0.00%> (ø)
src/add_dual_cone_constraint.jl 100.00% <0.00%> (ø)
src/objective_coefficients.jl 96.84% <0.00%> (+0.13%) :arrow_up:
src/dual_equality_constraints.jl 90.07% <0.00%> (+0.39%) :arrow_up:
src/MOI_wrapper.jl 92.39% <0.00%> (+0.78%) :arrow_up:

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 b11fc8a...688ce41. Read the comment docs.

kocvara commented 2 years ago

Very fast after the update, thanks! Perhaps just one thing - the user could be made aware of the format read by read_from_file(?) .