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

Grounding gets too slow with large constant numbers. #537

Open
see-mike-out opened this issue Feb 7, 2025 · 2 comments
Open

Grounding gets too slow with large constant numbers. #537

see-mike-out opened this issue Feb 7, 2025 · 2 comments
Labels

Comments

@see-mike-out
Copy link

see-mike-out commented Feb 7, 2025

Hello.

To summarize my situation, I'm having the following problem set.

cost(C) = C = #sum { W, X: cost_item(X, W) }.
#minimize { C : cost(C) }.

cost_item(W,X) :- cause_cost(X), cost_value(X,W).

% repeating the follow:
cost_value(a, 1000).
cost_value(b, 1001).
cost_value(c, 1002).
cost_value(d, 1003).
cost_value(e, 1004).
cost_value(f, 1005).
cost_value(g, 1006).
cost_value(h, 1007).
cost_value(i, 1008).
% ...
cost_value(Zxa, 2120).

Then, I run different problems with the following format:

cause_cost(a).
cause_cost(g).
% ...

It took a really long time, so I changed values in cost_value to be in the range of [0, 15], which made it faster.

Is it a known behavior of Clingo?

Thank you, and please redirect me to the original issue if its a duplicate question.

@rkaminsk
Copy link
Member

rkaminsk commented Feb 7, 2025

Assignment aggregates should ideally only be used over domain predicates and otherwise avoided.

I suppose that the cause_cost predicate in your example is meant to be derived by some other rules.

In the program above, it is easy to remove the assignment aggregate:

#minimize { W,X: cost_item(X,W) }.

@see-mike-out
Copy link
Author

I appreciate your response, yet I don't think the main issue was the assignment aggregate. When I rescaled the constants to lower values, it got faster. I mean, because I solved that way, it's not a big deal anymore, but I am wondering if that is the expected behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants