-
Notifications
You must be signed in to change notification settings - Fork 81
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
Consider filtering functionality in ConstrainedQuadraticModel.iter_constraint_data()
#1381
Comments
Hi @arcondello, I am interested in this feature. I have some pre-processing and post-processing steps which start from a feasible solution and then make changes to it by changing the values of a few variables. Every time I make such a change I use the The second approach that you outlined above (passing a |
Yes exactly. If you know what specific constraints you're looking for by label, we can easily fetch those and only those. But if you want to filter by some other property, or by say a regex of the label, we need to iterate over all constraints. That said, there may be some performance benefit even in the latter case because you can bypass the energy calculation which is where most of the time is spent. If either/both would be a useful feature for you, we can look into making the change(s) soon. |
Both approaches seem useful, but the potential speedup of the second approach (passing a labels = [lbl for lbl in cqm.constraint_labels if filter_function(lbl)]
cqm.iter_constraint_data(sample, labels=labels) That would only allow me to filter based on the constraint label and not based on any other property. |
#1382 implements the |
@mirko-sof , #1382 has been merged with the |
I'll try installing from source. Thanks for the quick turnaround. |
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
and/or
The text was updated successfully, but these errors were encountered: