Skip to content

Consider filtering functionality in ConstrainedQuadraticModel.iter_constraint_data() #1381

Description

@arcondello

Currently ConstrainedQuadraticModel.iter_constraint_data() always iterates over every constraint in the model.

We should consider adding some keyword arguments to make that a bit easier when handling constraints in bulk. I am imagining something like

     def iter_constraint_data(sample_like, *, filter_function=None):
        if callable(filter_function):
            yield from filter(filter_function, self.iter_constraint_data(sample_like))
            return

        ...

and/or

     def iter_constraint_data(sample_like, *, labels=None):
        ...

        if labels is None:
            labels = self.constraint_labels
            
        for label in labels:
            constraint = self.constraint(label)

            lhs = constraint.lhs.energy((sample, labels))
            rhs = constraint.rhs
            sense = constraint.sense
            ...

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions