Maximize the interval in clingo

559 views Asked by At

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?

3

There are 3 answers

0
NTP On

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)}.
0
Max Ostrowski On

A little bit more performant variant should be:

value(I) :- in(I,_).
value(I-1) :- value(I), I > 0.
#maximize {1,I : value(I)}.
0
William Smith On

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."?