-
Notifications
You must be signed in to change notification settings - Fork 183
matching algorithm for bipartite graphs (linear programming) #207
Conversation
looks like there is a problem on Julia 0.5 |
end | ||
|
||
""" | ||
As `maximum_weigth_maximal_matching`, with the difference that the edges `e` with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
weight not weigth
I don't like the idea of adding complex dependencies like JuMP for a single (set of) functions. If we can't eliminate the dependency, it looks like it might be better as a separate package. |
@sbromberger, there are lots of graph problems that can be solved with a general purpose optimization tool like jump. Once we have easy access to such a tool it will be easier to add new functionality that leverages it. Can we make it a Conditional dependency? It plays a similar role to spectral methods, once you have a good linear solver on Graphs there are lots of ways to use it for analyzing graphs. |
Conditional dependency is fine, but we should make sure that we've got more than one function that uses it. |
Why we need more than one function? Having an algorithm for matching should be reason enough. IHaving an algorithm for matching is a worthwhile addition, it is an important problem in combinatorial optimization, it has a lot of applications, and on top of that few libreries iimplemnt it, so it adds value to LightGraphs |
It just seems to me that requiring JuMP - which itself requires 4 different packages that are not part of LightGraphs REQUIRE (which themselves require 4+ packages that aren't part of LG REQUIRE) - just for a single function seems like it's too much extra baggage. |
But conditional dependence means it should not go into REQUIRE, right? |
That's right, and why I think we're ok with conditional dependence. But I think we still need to ensure we've got more than one function that will use it. This is a lot of baggage for a single enhancement. |
So, should I modify the PR to make it conditional? and how? |
I'd like @jpfairbanks to weigh in here – will this be useful for other functionality or is a JuMP conditional just good for matching? |
(as for "how" - check out how we do it for GraphMatrices: https://github.com/JuliaGraphs/LightGraphs.jl/blob/master/src/LightGraphs.jl#L12-L17 and |
Current coverage is
|
If I don't add JuMP to REQUIRE, how do I say to Travis to add it for testing? |
I think that matching is important and that using jump will support more functions in the future. You can have travis Pkg.add jump and the call the tests just like we do for graph matrices. Once you have a powerful tool like jump, you find ways to use it. :) |
status != :Optimal && error("Failure") | ||
sol = getValue(x) | ||
|
||
all(Bool[s == 1 || s == 0 for s in sol]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this statement supposed to do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is a continuous relaxation of an integer problem, here I check that the solution takes only integer values
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But the statement doesn't do anything. It evaluates to true
or false
and then discards the answer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, sure, that was meant to be in an assert. I'll fix it
this is ready for merge |
|
||
#matching | ||
maximum_weight_maximal_matching, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a duplicate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
I renamed pi and \pi to m. I didn't remove the Int[] constructors, since I like them, they are much more concise then Vector{Int}(), and moreover they are used all over the place, e.g. """Add a new vertex to the graph `g`."""
function add_vertex!(g::SimpleGraph)
n = length(vertices(g)) + 1
g.vertices = 1:n
push!(g.badjlist, Int[])
push!(g.fadjlist, Int[])
return n
end |
I've been weeding them out; please file issues if you see Int[] constructors. See also https://groups.google.com/d/msg/julia-users/BPPjnk20JgY/Ihq6KMqkS-UJ. |
@jpfairbanks - last call before merge. All good? |
Go for it.
|
matching algorithm for bipartite graphs (linear programming)
All done. Thanks, @CarloLucibello and @jpfairbanks !! |
I really think we need to revert this merge. It's causing travis to take > 10 mins to build all the JuMP dependencies, and we're seeing errors due to the macros and conditional dependencies. I'm in favor of revisiting once we understand the impact, but requiring JuMP in LightGraphs is making it too top-heavy right now. |
I'd say let's exclude matching just from testing, so that we don't also have to load JuMP. If this cannot be done easily, or if it would be bad practice to leave out from testing, let's just revert this. Also I don't know if it's possible to have codecov ignore the matching part, I wouldn't like it always complaining |
Can we find a way to make travis faster with JuMP? What about storing all the dependencies prebuilt for travis? The JuMP repo uses this travis.yml file which installs glpk from the apt repo on linux. language: julia
os:
- linux
- osx
julia:
- 0.4
- nightly
notifications:
email: false
sudo: false
addons:
apt_packages:
- gfortran
- liblapack-dev
- libgmp-dev
- libglpk-dev
script:
- if [[ -a .git/shallow ]]; then git fetch --unshallow; fi
- julia -e 'Pkg.clone(pwd())'
- julia -e 'Pkg.test("JuMP", coverage=true)'
- julia test/hygiene.jl
- julia -e 'Pkg.add("Ipopt")' # needed for below tests
- julia test/hockschittkowski/runhs.jl
after_success:
- echo $TRAVIS_JULIA_VERSION
- julia -e 'Pkg.add("Coverage"); cd(Pkg.dir("JuMP")); using Coverage; Coveralls.submit(process_folder()); Codecov.submit(process_folder())' For more info: http://docs.travis-ci.com/user/installing-dependencies/ |
See https://groups.google.com/d/msg/julia-users/L1_E5uuSj0M/rdtJ_3mdBQAJ for a possible solution to the dependency issue. |
yup that looks to be the right thing to allow LightGraphs to run without a dependence on JuMP. We should also use apt-get to test with JuMP on linux. |
partially fixes #194
This is meant to be a temporary solution, exploiting the fact that for bipartite graphs matching can be relaxed to linear programming, untill someone finds the courage and the will to implement a more effcient matching algorithm.
For the time being I added JuMP to REQUIRE, I don't know how to set them as optional dependences.