1

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?

Saqib Ali
  • 3,953
  • 10
  • 55
  • 100

3 Answers3

1

A little bit more performant variant should be:

value(I) :- in(I,_).
value(I-1) :- value(I), I > 0.
#maximize {1,I : value(I)}.
Max Ostrowski
  • 575
  • 1
  • 3
  • 15
0

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)}.
NTP
  • 4,338
  • 3
  • 16
  • 24
0

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