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

Added dual prices for the probability simplex and the unit simplex #15

Merged
merged 7 commits into from
Jan 15, 2021

Conversation

pokutta
Copy link
Member

@pokutta pokutta commented Jan 14, 2021

currently the rationelle is to pass both the objective (i.e., the direction) as well as the primal optimal point from a previous LP call to compute the dual solutions. This is because the primal solution is not unique and we want primal-dual pairs!

src/simplex_oracles.jl Outdated Show resolved Hide resolved
@pokutta
Copy link
Member Author

pokutta commented Jan 14, 2021

partially resolves Issue #7

@@ -13,11 +13,11 @@ const grad(x) = 2 * (x-xp)


function cf(x,xp)
return LinearAlgebra.norm(x-xp)^2
return @. LinearAlgebra.norm(x-xp)^2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure the broadcast will be needed here, x and xp should have the same dimensions right?
x - xp works for vectors x and xp, it will only error if one of them is a scalar

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point - saves half the memory though 126MB vs. 63

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok curious, well let's leave it as-is then

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i am not sure yet that i understand where the grossly different allocations come from with and without broadcasting. see numbers below

function cgrad(x,xp)
return 2 * (x-xp)
function cgrad(x,xp)
return @. 2 * (x-xp)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above I think

Copy link
Member Author

@pokutta pokutta Jan 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here: they basically halve the memory allocs when you broadcast:

without broadcast:

 Size of single vector (Float64): 0.762939453125 MB

─────────────────────────────────────────────────────────────────────────────
                                      Time                   Allocations      
                              ──────────────────────   ───────────────────────
 caching 100 points      100    1.65s  95.6%  16.5ms   7.68GiB  95.4%  78.6MiB
 lmo                     100   21.1ms  1.22%   211μs     0.00B  0.00%    0.00B
 update (blas)           100   18.3ms  1.06%   183μs    153MiB  1.85%  1.53MiB
 grad                    100   15.6ms  0.90%   156μs    153MiB  1.85%  1.53MiB
 f                       100   12.5ms  0.72%   125μs   76.3MiB  0.93%   781KiB
 update (memory)         100   6.46ms  0.37%  64.6μs     0.00B  0.00%    0.00B
 dual gap                100   2.11ms  0.12%  21.1μs     0.00B  0.00%    0.00B
 ─────────────────────────────────────────────────────────────────────────────

with broadcasting

 Size of single vector (Float64): 0.762939453125 MB

─────────────────────────────────────────────────────────────────────────────
                                      Time                   Allocations      
                              ──────────────────────   ───────────────────────
       Tot / % measured:           2.08s / 89.4%           8.57GiB / 92.2%    

 Section              ncalls     time   %tot     avg     alloc   %tot      avg
 ─────────────────────────────────────────────────────────────────────────────
 caching 100 points      100    1.79s  96.4%  17.9ms   7.60GiB  96.2%  77.8MiB
 lmo                     100   20.1ms  1.08%   201μs     0.00B  0.00%    0.00B
 update (blas)           100   19.6ms  1.05%   196μs    153MiB  1.89%  1.53MiB
 f                       100   9.52ms  0.51%  95.2μs   76.3MiB  0.94%   781KiB
 grad                    100   9.19ms  0.50%  91.9μs   76.3MiB  0.94%   781KiB
 update (memory)         100   6.46ms  0.35%  64.6μs     0.00B  0.00%    0.00B
 dual gap                100   2.01ms  0.11%  20.1μs     0.00B  0.00%    0.00B
 ─────────────────────────────────────────────────────────────────────────────

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done for the gradient here as example

@matbesancon matbesancon merged commit 2435dfb into master Jan 15, 2021
@matbesancon matbesancon deleted the dualPricesForReal branch January 15, 2021 10:23
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