I have the following code:
1{p(1..10)}10.
:- p(I*2).
and it shows 31 answers, But I just need the max subset p(1) p(3) p(5) p(7) p(9).
How can I do it?

I have the following code:
1{p(1..10)}10.
:- p(I*2).
and it shows 31 answers, But I just need the max subset p(1) p(3) p(5) p(7) p(9).
How can I do it?

Copyright © 2021 Jogjafile Inc.
You are searching for an optimization. Easiest fix would be adding
resulting in
Don't worry about the negative score, clingo converts
#maximizeinto#minimize, therefore the negation. So what does#maximize{I:p(I)}.do? In general you want to maximize overIfor allp(I), which in this case is the sum ofI. Just counting would beresulting in