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

Reduce memory footprint for CompactTable #1017

Open
cprudhom opened this issue Mar 6, 2023 · 1 comment
Open

Reduce memory footprint for CompactTable #1017

cprudhom opened this issue Mar 6, 2023 · 1 comment

Comments

@cprudhom
Copy link
Member

cprudhom commented Mar 6, 2023

I think there is room to reduce CT+ structure initialization when tuples' ranges are smaller than domains' range.

For instance:

IntVar[] xs = model.intVarArray("X", 4, 0, 99_999);
Tuples comb = new Tuples(true);
comb.setUniversalValue(-1);
comb.add(1, 0, -1, 0);
comb.add(1, 3, -1, 3500);
comb.add(2, 3, -1, 3500);
comb.add(4, 3, -1, 3500);
model.table(xs, comb, "CT+").post();

CT will allocate supports array (of longs) of size 99_999, whereas smaller size would do the job.

I'm not saying it is easy to do, but it could be useful.

Note that I agree that the domain could be reduced at the first place, but sometimes (when parsing instances for instance) this is quite complicated.

PS: same goes for "STR2+"

@martins-avots
Copy link

martins-avots commented Jul 13, 2023

One could maybe add an array shrinking function inside the model#table method.
Alternatively, one could pass a Function<Integer, IntVar[]> to the model#table method,
in order to avoid any duplicate allocations.

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