Reputation: 13
I develop an application in clingo and here is my code:
conflicting_hours(Course1, Section1, Room, Start1, Hour1) :-
occupies(Course1, Section1, Room, Start1, Hour1),
occupies(Course2, Section2, Room, Start2, Hour2),
different_course(Course1,Course2,Section1,Section2),
check_hour_intersection(Start1,Start2,Hour1) ; check_hour_intersection(Start2,Start1,Hour2).
different_course(N1,N2,S1,S2) :-
course(N1,S1,_,_,_,_,_,_),
course(N2,S2,_,_,_,_,_,_),
(N1!=N2 ; S1!=S2).
and here is error:
soln.lp:62:8-10: error: syntax error, unexpected !=, expecting )
*** ERROR: (clingo): parsing failed
It gives this error when I try to put braces around (N1!=N2 ; S1!=S2). When I remove brackets it woks well but logic is wrong. Why it is invalid syntax.
Upvotes: 0
Views: 132
Reputation: 18663
Try:
different_course(N1,N2,S1,S2) :-
course(N1,S1,_,_,_,_,_,_),
course(N2,S2,_,_,_,_,_,_),
((N1 != N2) ; (S1 != S2)).
Also, in the first clause, should it be instead:
conflicting_hours(Course1, Section1, Room, Start1, Hour1) :-
occupies(Course1, Section1, Room, Start1, Hour1),
occupies(Course2, Section2, Room, Start2, Hour2),
different_course(Course1,Course2,Section1,Section2),
( check_hour_intersection(Start1,Start2,Hour1)
; check_hour_intersection(Start2,Start1,Hour2)
).
Upvotes: 0