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

ITotalizer does not accept an `IDPool #173

Open
Jaxan opened this issue Jun 5, 2024 · 2 comments
Open

ITotalizer does not accept an `IDPool #173

Jaxan opened this issue Jun 5, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@Jaxan
Copy link

Jaxan commented Jun 5, 2024

Hi all,

Previously I used the CardEnc class to encode size constraints. I need multiple constraints and so I used a single IDPool and passed it along all of the CardEnc instances. Then I wanted to make the size constraints incremental, and switched to ITotalizer. But this class does not take an IDPool, only a top_id.

Currently, my workaround is as follows:

vpool = IDPool()
...
with ITotalizer(lits, ubound=upper_bound, top_id=vpool.top) as cnf_optim:
  vpool.occupy(vpool.top + 1, cnf_optim.top_id)
  vpool.top = cnf_optim.top_id
  ...

Is this a correct workaround?

And would it be possible to add a vpool variable to the ITotalizer class, just like the CardEnc class? I find it much easier (and less error-prone) to use than passing around a top variable.

Thanks for the pysat package! It is really a wonderful interface to work with!

@alexeyignatiev
Copy link
Collaborator

Hi @Jaxan,

Yes, at first glance this workaround looks okay although it might be simpler to give the range from 1 to cnf_optim.top_id when declaring it as occupied. (The method should take care of the fact that the new range is a superset of the previous.)

As for adding a vpool argument to ITotalizer, this would make perfect sense to me. So I will definitely do it at some point when and if I get a chance. Thanks for the suggestion!

Best,
Alexey

@alexeyignatiev alexeyignatiev added the enhancement New feature or request label Jun 5, 2024
@Jaxan
Copy link
Author

Jaxan commented Jun 13, 2024

Hi Alexey,

thanks for confirming my workaround!

kind regards,
Joshua

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

No branches or pull requests

2 participants