7.7 Measure the time needed by the program in Figure 7.5 to solve the cryptarithmetic puzzle. Then...

Question:

7.7 Measure the time needed by the program in Figure 7.5 to solve the cryptarithmetic puzzle. Then replace the labelling goal by: labeling( [ff], Vars) The labelling option 'ff' stands for 'first fail'. That is, the variable with currently the smallest domain will be assigned a value first. Having the smallest domain, this variable is generally the most likely one to cause a failure. This labelling strategy aims at discovering inconsistency as soon as possible, thus avoiding futile search through inconsistent alternatives. Measure the execution time of the modified program. It will be helpful to use the built-in predicate to measure computation time: statistics( runtime, V) A call of this predicate instantiates V to a list of the form [T1, T2] where T1 is the program's run time in milliseconds since the start of the Prolog session, and T2 is the run time since the last call of statistics (runtime,...). A question to measure time Time to solve the puzzle is then, for example: ?- statistics( runtime, ), solve(...), statistics( runtime, [Time]). In fact, the time needed by the program to solve this puzzle will probably be too small (something like one or a few milliseconds) for reliable measurement with the statistics predicate. Therefore, to obtain reliable measurements, the call of solve should be repeated, say, a thousand times. Write also a timing predicate repeat(Goal,N) that N times repeats the execution of Goal.

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question
Question Posted: