Reputation: 1
I am a beginner in Answer Set Programming and completely new to clingo. I tried the facts and constraints below on nurses shift on clingo, but I am not getting any model and clingo not flagging any error. I keep getting UNSAT. What am I not doing right?
nurselimits(x, min, max).
worklimits(min, max).
daylimits(x, t, min, max).
x(morning; afternoon; night; off; leave).
x(1..5).
day(1..28).
days(28).
nurse(1..40).
shift(1, morning, 8).
shift(2, afternoon, 14).
shift(3, night, 20).
shift(4, off, 0).
shift(5, leave, 10).
nurselimits(1,6,9).
nurselimits(2,6,9).
nurselimits(3,4,7).
daylimits(1,8,6,9).
daylimits(2,8,6,9).
daylimits(3,8,5,10).
worklimits(132,228).
{assign(N, X, D) : shift(X, Name, H), X != 4, X != 5} = 1:- nurse(N), day(D).
:- day(D), #count{N : assign(N, X, D)} > max, nurselimits(x, min, max).
:- day(D), #count{N : assign(N, X, D)} < min, nurselimits(x, min, max).
:- nurse(N), #sum{H, D : assign(N, X, D), shift(X, Name, H)} > max, worklimits(min, max).
:- nurse(N), #sum{H, D : assign(N, X, D), shift(X, Name, H)} < min, worklimits(min, max).
:- nurse(N), assign(N, X1, D), assign(N, X2, D+1), X2 < X1 , X1 <= 3.
:- nurse(N), day(D), days(DAYS), D <= DAYS-21,
#count{D1 : assign(N, 4, D1), D1 >= D, D1 <= D+21} = 1.
:- nurse(N), #count{D: assign(N, X, D)} > max, daylimits(x, t, min, max).
:- nurse(N), #count{D: assign(N, X, D)} < min, daylimits(x, t, min, max).
Upvotes: 0
Views: 355
Reputation: 2472
In this code
nurselimits(x, min, max).
worklimits(min, max).
daylimits(x, t, min, max).
x(morning; afternoon; night; off; leave).
x(1..5).
There are several problems. The symbols x
, min
, max
, t
. Are all non-numerical symbolic constants, much like morning
, afternoon
,etc. That is probably unintended, unless you are substituting them using the -c
command line option. Certainly, the x
in nurselimits
has nothing to do with the x(1..5)
in your code, which also seems unintended. Also, the constant min
is the same symbolic value in nurselimits
, worklimits
and daylimits
. Perhaps you wanted it to be variable instead?
Upvotes: 1
Reputation: 1
You should remove first three lines and add #show (e.g. #show assign/3.) of any predicate you want to see in the answer sets.
Upvotes: 0