Reputation: 4448
I have the following clingo code that generates the search space, followed by constraints.
{in(I,1..4)}=1 :- I=1..n.
:- [constraint1]
:- [constraint2]
This code works. But I need clingo to find the largest value of n for which a stable model exists. What is the best way to do that?
Upvotes: 1
Views: 683
Reputation: 11
I don't know how to do with n, so I just wrote in the following way.
{in(I,1..4)}=1 :- I=1..100.
:- [constraint1]
:- [constraint2]
v(I) :- in(I, _).
:- not v(I), v(I + 1), I > 0.
#maximize { 1, I : v(I).
Is there a more elegant way to replace the first sentence "{in(I,1..4)}=1 :- I=1..100."?
Upvotes: 0
Reputation: 623
A little bit more performant variant should be:
value(I) :- in(I,_).
value(I-1) :- value(I), I > 0.
#maximize {1,I : value(I)}.
Upvotes: 1
Reputation: 4448
You can use the #min aggregate to find min n.
value(I) :- I = #min {I:in(I,X) }.
and use #maximize directive to find stable models in which the value of aggregate experission is larger.
#maximize {I: value(I)}.
Upvotes: 0