Skip to content

Faster version of longest_increasing_subsequences #31451

@petermoraw

Description

@petermoraw

The algorithm for the longest_increasing_subsequences function for permutations is currently very inefficient. I worked on a new version that vastly improves the run time of the function.
New version:

sage: %timeit Permutations(30).random_element().longest_increasing_subsequences()                                     
19.6 ms ± 2.28 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)

Old version:

sage: %timeit Permutations(30).random_element().longest_increasing_subsequences()                                     
The slowest run took 10.40 times longer than the fastest. This could mean that an intermediate result is being cached.
3min 34s ± 2min 47s per loop (mean ± std. dev. of 7 runs, 1 loop each)

follow-up: #34218

CC: @nadialafreniere @enadeau @tscrim

Component: combinatorics

Keywords: permutation, subsequences

Author: Peter Morawitz, Finn Hulse, Nadia Lafrenière

Branch/Commit: 5969eda

Reviewer: David Coudert, Vincent Delecroix

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions