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

Model.intVar() should accept enumerated domains provided in bitsets #1120

Open
fhermeni opened this issue Dec 13, 2024 · 1 comment
Open
Assignees
Milestone

Comments

@fhermeni
Copy link
Contributor

int[] is a confortable approach to state the domain but

  1. in terms of memory usage it is not necessarily concise
  2. it requires the solver to clone the array which can be costly (refer to point 1 as well)
  3. eventually, it is only used to populate a backtrackable bitset when we use a BitsetIntVarImpl backend

It would be great to be able to provide a bitset

  1. more concise
  2. faster and cheaper clone if needed
  3. can be reused by the caller given it is more flexible than an int[]
  4. no need to sort
  5. it should speed up BitsetIntVarImpl initialisation using bitset magic
@cprudhom cprudhom self-assigned this Feb 27, 2025
@cprudhom cprudhom added this to the 5.0.0 milestone Feb 27, 2025
@cprudhom
Copy link
Member

cprudhom commented Feb 27, 2025

At first sight, I can't see how to clone a java.util.BitSet into a IStateBitSet without calling bitset.toLongArray() which does a copy itself:

public long[] toLongArray() {
    return Arrays.copyOf(words, wordsInUse);
}

But I suppose it's still faster than the iteration over the values... (well it depends on the values)

cprudhom added a commit that referenced this issue Feb 28, 2025
Introduce a new API to declare enumerated variables based on a BitSet and on offset
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants