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

Avoid comparison of vertex labels in MIP (Step 2) #26282

Closed
dcoudert opened this issue Sep 14, 2018 · 16 comments
Closed

Avoid comparison of vertex labels in MIP (Step 2) #26282

dcoudert opened this issue Sep 14, 2018 · 16 comments

Comments

@dcoudert
Copy link
Contributor

Avoid comparison of vertex labels in graph.py.

CC: @tscrim @fchapoton

Component: graph theory

Author: David Coudert

Branch/Commit: 6acb781

Reviewer: Travis Scrimshaw

Issue created by migration from https://trac.sagemath.org/ticket/26282

@dcoudert dcoudert added this to the sage-8.4 milestone Sep 14, 2018
@dcoudert
Copy link
Contributor Author

Commit: 8e3e85c

@dcoudert
Copy link
Contributor Author

New commits:

8e3e85ctrac #26282: avoid comparison of vertex labels in MIP

@dcoudert
Copy link
Contributor Author

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Sep 15, 2018

Changed commit from 8e3e85c to 5221e6a

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Sep 15, 2018

Branch pushed to git repo; I updated commit sha1. New commits:

5221e6atrac #26282: resolve merge conflict with 8.4.beta5

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Sep 16, 2018

Branch pushed to git repo; I updated commit sha1. New commits:

2dfc524trac #26282: use def instead of lambdas

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Sep 16, 2018

Changed commit from 5221e6a to 2dfc524

@dcoudert
Copy link
Contributor Author

comment:4

I change frozenset wrappers from lambda to def. Should I try to do the same for remaining lambda statements like this ?

weight = lambda x: x if x in RR else 1

@tscrim
Copy link
Collaborator

tscrim commented Oct 3, 2018

comment:6

I think you can get rid of

        def B(e):
            return b[frozenset(e)]
        def R(e):
            return r[frozenset(e)]
        def S(e):
            return frozenset(e)

as they are not simplifying the code (or changing the readability IMO.

I would still use six.iteritems for better memory usage:

-        g_mad = g.subgraph([v for v,l in six.iteritems(p.get_values(d)) if l>m ])
+        d_val = p.get_values(d)
+        g_mad = g.subgraph([v for v,l in d_val.items() if l > m ])

In general, I don't get the point of that change.

More standard convention and faster:

-lists = dict((v, []) for v in self)
+lists = {v: [] for v in self}
sage: %timeit dict((i,-1) for i in range(100))
100000 loops, best of 3: 16.6 µs per loop
sage: %timeit {i:-1 for i in range(100)}
100000 loops, best of 3: 11.7 µs per loop

not fuv in L -> fuv not in L.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Oct 4, 2018

Branch pushed to git repo; I updated commit sha1. New commits:

7856e11trac #: Merged with 8.4.beta7
6acb781trac #26282: implement reviewer's comments

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Oct 4, 2018

Changed commit from 2dfc524 to 6acb781

@dcoudert
Copy link
Contributor Author

dcoudert commented Oct 4, 2018

comment:8

I have implemented all your comments.

@tscrim
Copy link
Collaborator

tscrim commented Oct 4, 2018

comment:9

Thanks. LGTM.

@tscrim
Copy link
Collaborator

tscrim commented Oct 4, 2018

Reviewer: Travis Scrimshaw

@dcoudert
Copy link
Contributor Author

dcoudert commented Oct 4, 2018

comment:10

Thank you !

@vbraun
Copy link
Member

vbraun commented Oct 5, 2018

Changed branch from public/26282_avoid_comparison_of_vertex_labels to 6acb781

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants