Skip to content

Add DisjointCover node#557

Open
smharwood wants to merge 4 commits into
dwavesystems:mainfrom
smharwood:feature/disjoint-node
Open

Add DisjointCover node#557
smharwood wants to merge 4 commits into
dwavesystems:mainfrom
smharwood:feature/disjoint-node

Conversation

@smharwood
Copy link
Copy Markdown
Contributor

Adds a logical-valued node that determines whether its predecessors are a disjoint cover of a given primary set

Reference issue

What does this implement/fix?

Implements a DisjointCover node, enabling construction of DisjointLists via List symbols

AI Generation Disclosure

No AI tools used

Copy link
Copy Markdown
Member

@arcondello arcondello left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple random aesthetic comments

public:
DisjointCoverNode(ssize_t primary_set_size, std::span<ArrayNode*> node_ptrs);

// Node overloads **********
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this is a pattern used by a lot of other nodes, but I want to move to just alphabetical for all methods going forward.


See Also:

.. versionadded::
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo

@arcondello arcondello added the enhancement New feature or request label Jun 1, 2026
@smharwood smharwood marked this pull request as ready for review June 1, 2026 17:39
@arcondello
Copy link
Copy Markdown
Member

Misc unhelpful notes from trying to find precedent for similar functions in other libraries we like to follow.

Maybe we want IsPartition? Though I am a little nervous about clashing with np.partition() which is a totally different thing. And I think a partition might actually requires that each subset be non-empty.

@arcondello
Copy link
Copy Markdown
Member

I think if we were writing this from scratch we'd want an API like

from dwave.optimization import Model, is_disjoint_cover

model = Model()

universe = 100
num_lists = 10

lists = [model.list(universe, min_size=0) for _ in range(num_lists)]

model.add_constraint(is_disjoint_cover(lists))

open to suggestions

@smharwood
Copy link
Copy Markdown
Contributor Author

Misc unhelpful notes from trying to find precedent for similar functions in other libraries we like to follow.

Maybe we want IsPartition? Though I am a little nervous about clashing with np.partition() which is a totally different thing. And I think a partition might actually requires that each subset be non-empty.

I'm convinced adding "Is" is the way to go. At least, its consistent with "IsIn", and its probably not a good idea to go the other way and rename that to just "In"

@smharwood
Copy link
Copy Markdown
Contributor Author

smharwood commented Jun 2, 2026

I think if we were writing this from scratch we'd want an API like

from dwave.optimization import Model, is_disjoint_cover

model = Model()

universe = 100
num_lists = 10

lists = [model.list(universe, min_size=0) for _ in range(num_lists)]

model.add_constraint(is_disjoint_cover(lists))

open to suggestions

So, add is_disjoint_cover to the mathematical namespace?

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

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants