Consider a scheduling problem, where there are 5 activities to be scheduled in 4 time slots. Lets represent the activities by the variables A, B, C, D, and E, and suppose the domain of each variable is {1,2,3,4} and the constraints are: A>D, D>E, C \=A, C>E, C \=D, B>=A, B\=C, C\=D+1.
Here is a solution tree based on the variable ordering C,D,A,B,E.
At this stage arc consistency has stopped. Here is the arc-constraint graph:
Arc Relation Value(s) Removed <D,E> D > E D=1 <E,D> D > E E=4 <C,E> C > E C=1 <D,A> A > D D=4 <A,D> A > D A=1 & A=2 <B,A> B >=A B=1 & B=2 <E,D> D > E E=3
Note that, if you had one arc between C and D labelled with C \=D+1 &C\=D, then C=3 can be removed by considering the arc <C,D>. If you have two arcs, C=3 cannot be removed by arc consistency.
Here is the resulting constraint net.
Arc Relation Value(s) Removed <E,D> D > E E=2 <C,D> C \=D C=2 <C,D> C \=D+1 C=3 <A,C> C \=A A=4 <B,C> B \=C B=4
For example, given the segment database (from Assignment 3),
you also need to assume that you have a list of all segments:% segment(SegId,Time,Topics) is true if segment SegId takes time Time % and covers the topics in Topics. segment(seg0,10,[welcome]). segment(seg1,30,[skiing,views]). segment(seg2,50,[welcome,computational_intelligence,robots]). segment(seg3,40,[graphics,dragons]). segment(seg4,50,[skiing,robots]).
Suppose that a node is represented as vp(To_Cover,Segs) where Segs is a list of segments that must be in the presentation, and To_Cover is a list of topics that also must be covered, such that none of the segments in Segs covers any of the topics in To_Cover.% all_segments(L) is true if L is the list of all segments. all_segments([seg0,seg1,seg2,seg3,seg4]).
Write the neighbors relation, so that
has one answer (perhaps in the other order):ask neighbours(vp([welcome,robots],[]),Neighs).
You also need to define the cost predicate, where the cost of an arc is the time of the segment added, and an is_goal predicate.Answer: neighbours(vp([welcome,robots],[]), [vp([],[seg2]),vp([robots],[seg0])]).
Show how this can be used with the hsearch program.
The following query should give the shortest presentation:
Show that it works. (Note that asking "how" will show the steps of the search).ask hsearch(shortest,[node(vp([welcome,skiing,robots],[]),[],0,0)],P).