Clingo is unsatisfiable (forcing all combinations) even though it should not be

43 views Asked by At

In this Clingo program I was defining that there are 2 cars, 2 parcels and that there are assignments made of a parcel and a car but Clingo is forcing all possible combinations of assignments instead of just allowing them.

The following code is unsatisfiable:

parcel(1,a,1,110).
parcel(2,b,1,90).

%Define car predicate
car(1).
car(2).

%Define assign predicate
assign(P,C) :- parcel(P,_,_,_), car(C).
not assign(1,1).

Even if i remove the last line and add:

1 {car(C): assign(P,C)} 1 :- parcel(P,_,_,_).

Stating that every parcel should have exactly 1 car, it is still unsastisfiable. This does not make sense since the first Clingo code only defined "assign" as a predicate which has a parcel and a car, and not every possible combination.

1

There are 1 answers

0
damianodamiano On BEST ANSWER

If I've correctly understood your problem, you can remove the last two lines and add instead

1{assign(P,C) : car(C)}1 :- parcel(P,_,_,_).

Now you get 4 answer sets, that should solve your problem

Answer: 1
car(1) car(2) parcel(1,a,1,110) parcel(2,b,1,90) assign(1,2) assign(2,1)
Answer: 2
car(1) car(2) parcel(1,a,1,110) parcel(2,b,1,90) assign(1,2) assign(2,2)
Answer: 3
car(1) car(2) parcel(1,a,1,110) parcel(2,b,1,90) assign(1,1) assign(2,1)
Answer: 4
car(1) car(2) parcel(1,a,1,110) parcel(2,b,1,90) assign(1,1) assign(2,2)
SATISFIABLE