I'm attempting project scheduling with SWI prolog and CLP. I managed to support sequential dependencies but I'm struggling with avoiding double booking people.
I have a list called Schedule containing elements like [taskname, starttime] where starttime is a free variable for the constraint solver. They're already constrained by sequential dependencies.
I'm trying to write a loop like this to rule out double bookings:
forall /* or maybe foreach*/ (isa(P,person), (
% Filter scheduled tasks on that person...
include(\[T,S]^(assigned(T,P)), Schedule, HisSchedule),
% Present what serialized expects..
maplist(\[T,S]^S^true, HisSchedule, Sts),
% duration is just user-defined data...
maplist(\[T,S]^D^(duration(T,D)), HisSchedule, Dus),
% Hit it...
serialized(Sts, Dus)
)),
With foreach it always fails and with forall it always succeeds without constraining anything.
Schedule is global as far as this loop is concerned, and the purpose is to constrain its starttime elements using serialized. OTOH, HisSchedule, Sts and Dus depend on the particular person. So I think I need foreach to make Schedule happy but forall to make HisSchedule etc happy. Is that the problem? And if so how do I fix it?