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

Implement algorithm for enumerating ideals of a poset in O(log n) amortized time #37805

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

saatvikraoIITGN
Copy link
Contributor

Description

This PR implements an algorithm for enumerating ideals of a poset in the amortized time complexity of O(log n). The algorithm is based on a new approach that efficiently generates upsets using a recursive procedure. It reorders the elements of the poset and recursively generates upsets, significantly reducing the time complexity compared to previous methods.

This change is required to improve the efficiency of enumerating ideals of a poset, which is a common operation in various applications such as computational geometry, combinatorics, and optimization problems.

Fixes #37749

📝 Checklist

  • The title is concise and informative.
  • The description explains in detail what this PR is about.
  • I have linked a relevant issue or discussion.
  • I have created tests covering the changes.
  • I have updated the documentation and checked the documentation preview.

⌛ Dependencies

#37345 : the acyclic orientations function that is implemented here will have to be modified for better efficiency

src/sage/categories/posets.py Outdated Show resolved Hide resolved
src/sage/categories/posets.py Outdated Show resolved Hide resolved
src/sage/categories/posets.py Outdated Show resolved Hide resolved
@tscrim
Copy link
Collaborator

tscrim commented Apr 19, 2024

@saatvikraoIITGN Please use proper Python OOP. Mainly start methods with self and use self.generate_upsets. Although you are probably better utilizing the underlying digraph (i.e., Hasse diagram).

I am also not sure of your claim about the speed. How Sage constructs a single ideal is using a DFS on the Hasse diagram, which should be $O(\log n)$ amortized (with $n = |P|$ the size of the poset). The abstract of the reference (which I can't find, please provide a link or full citation info) makes a contradictory claim: amortized means you don't consider the worst case. I doubt you will be able to do better than that unless you are really taking advantage of the DAG property. On the other hand, if you want to enumerate all ideals, then I don't believe it can be done better than $O(n)$ since you have at least one ideal for each element in the poset. Please clarify this.

@kevindilks You might be interested in this PR too.

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

Successfully merging this pull request may close these issues.

generating the ideals of a poset in logarithmic time complexity
4 participants