{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Concepts+Techniques+and+Models+of+Computer+Programming_Part28

Concepts+Techniques+and+Models+of+Computer+Programming_Part28

This preview shows pages 1–4. Sign up to view the full content.

768 Constraint Programming fun {DFE S} case {Ask S} of failed then nil [] succeeded then [S] [] alternatives(2) then C={Clone S} in {Commit S 1} case {DFE S} of nil then {Commit C 2} {DFE C} [] [T] then [T] end end end % Given {Script Sol}, returns solution [Sol] or nil: fun {DFS Script} case {DFE {NewSpace Script}} of nil then nil [] [S] then [{Merge S}] end end Figure 12.3: Depth-first single solution search statement ::= {NewSpace x y } | {Choose x y } | {Ask x y } | {Commit x y } | {Clone x y } | {Inject x y } | {Merge x y } Table 12.1: Primitive operations for computation spaces A depth-first search engine Figure 12.3 shows how to program depth-first single solution search, in the case of binary choice points. This explores the search tree in depth-first manner and returns the first solution it finds. The problem is defined as a unary procedure {Script Sol} that gives a reference to the solution Sol , just like the examples of Section 12.2. The solution is returned in a one-element list as [Sol] . If there is no solution, then nil is returned. In Script , choice points are defined with the primitive space operation Choose . The search function uses the primitive operations on spaces NewSpace , Ask , Commit , Clone , and Merge . We will explain each operation in detail as it comes in the execution. Table 12.1 lists the complete set of primitive operations. Copyright c 2001-3 by P. Van Roy and S. Haridi. All rights reserved.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
770 Constraint Programming Space A Space B

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern