0

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).
1
  • Please edit your question title to something that actually describes a problem or asks a question. It should be clear and descriptive enough to be of use to a future user of this site who is scanning through a list of search results looking for a problem solution. Your current title provides nothing meaningful that will help that user. Thanks. Commented Mar 11, 2020 at 12:29

2 Answers 2

1

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?

Sign up to request clarification or add additional context in comments.

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.