Skip to content

Speedup subposet and _vertex_to_element #11382

@hivert

Description

@hivert

A lot of unnecessary and redundant check were performed with a preliminary version of #10998. See a more precise
analyze on
this thread of sage-combinat-devel

sage: P = cutting_poset(WeylGroup(['A',3]))
sage: P.cardinality()
24

Before:

sage: %timeit P.subposet(P.list()[1:])
5 loops, best of 3: 214 ms per loop

After:

sage: %timeit P.subposet(P.list()[1:])
25 loops, best of 3: 24.8 ms per loop

Here is another timing for a bigger poset:

sage: P = cutting_poset(WeylGroup(['A',4]))
sage: P.cardinality()
120

Before:

sage: %timeit P.subposet(P.list()[1:])
5 loops, best of 3: 28.8 s per loop

After:

sage: %timeit P.subposet(P.list()[1:])
5 loops, best of 3: 597 ms per loop

This is basically fixed in the final version of #10998 (run on a
slightly slower machine than for the above timings):

sage: %timeit P.subposet(P.list()[1:])
5 loops, best of 3: 801 ms per loop

The attached patch optimizes it a tiny bit further and adds doctests:

sage: %timeit P.subposet(P.list()[1:])
5 loops, best of 3: 688 ms per loop

Apply: attachment: trac_11382-subposet_to_vertex_speedup-fh.patch

Depends on #10998

CC: @sagetrac-sage-combinat

Component: combinatorics

Keywords: poset, subposet, Cernay2012

Author: Florent Hivert

Reviewer: Nicolas M. Thiéry

Merged: sage-5.0.beta5

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions