原文地址:语言生成器
Introduction
实现一个语言生成器,能自动根据单词写诗。
General instructions
- This is an individual assignment. You can discuss solutions with your classmates, but should only exchange information orally, or else if in writing through the discussion board on myCourses. All other forms of written exchange are prohibited.
- Unless otherwise mentioned, the only sources you should need to answer these questions are your course notes, the textbook, and the links provided. Any other source used should be acknowledged with proper referencing style in your submitted solution.
- For each problem, you can solve manually, or write a program to help you. You can use a programming language of your choice. You can modify code from other sources if you provide adequate citation; this cannot be code from other students in the class.
- Submit a single pdf document containing all your pages of your written solution on your McGill's myCourses account. You can scan-in hand-written pages. If necessary, learn how to combine many pdf files into one.
- Submit any code developed to answer questions as a separate file to McGill's myCourses.
Question 1: Language Generation
We would like to design a simple language generation system which can generate sensible and grammatically correct sentences of English. The system is able to generate these five words: the, cat, sat, on, mat.
Thus, the sentences that we would want the system to generate are (we ignore capitalization and punctuation issues):
the cat sat
the cat sat on the mat
The system also incurs a cost for generating each word, equal to the number of consonants the word contains.
- a) Formulate the sentence generation process as a search problem, stating each of the parts of the search problem as shown in class.
- b) Draw the search graph of this problem.
- c) Draw the search tree down to a depth of 2 (i.e., the tree has 3 levels in total, including the root.)
-
d) Trace the run of the search process using the following algorithms. Given multiple states to explore that are otherwise equivalent in priority, the algorithm should prefer to generate the word that comes first alphabetically.
- i. Breadth first search
- ii. Uniform cost search
- iii. Depth first search
- iv. Iterative deepening
Question 2: Search algorithms (Adapted from Russell & Norvig)
- a) Describe a state space in which iterative deepening search performs much worse than depth-first search (for example, O(n^2) vs O(n)).
Prove each of the following statements, or give a counterexample:
- b) Breadth-first search is a special case of uniform-cost search.
- c) Depth-first search is a special case of best-first tree search.
- d) Uniform-cost search is a special case of A* search.
- e) A* search is optimal in the case where negative edge weights are allowed.
Question 3: Optimization
Consider the following functions:
f1(x, y) = sin(x / 2) + cos(2y)
f2(x, y) = -|x - 2| - |0.5y + 1| + 3
We would like to maximize these functions within the range of 0 ≤ x, y ≤ 10. For each part below and each setting, report the mean and standard deviation of the number of steps to convergence and of the final value f1, f2 for each case. Use plots and/or tables to report your results in an organized manner.
- a) For each function, apply hill climbing, starting from 100 random points in the range. Repeat this procedure for each choice of step size in [0.01, 0.05, 0.1, 0.2]. What patterns do you see?
- b) Repeat using local beam search with beam width in [2, 4, 8, 16], performing 100 runs of each. Were you able to improve performance over hill climbing for each function, as measured by the mean and standard deviation of the number of iterations and/or final objective function value?
(本文出自csprojectedu.com,转载请注明出处)
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。