第1章搜索问题.pptVIP

  • 8
  • 0
  • 约1.69万字
  • 约 73页
  • 2016-11-22 发布于天津
  • 举报
第1章搜索问题.ppt

状态空间 计算机对传统的问题求解方法带来了根本性的改变。 传统方法, 由专家给出公式, 使用者的任务是理解公式, 应用公式。 有些问题用传统方法描述很困难, 例如本节的几个例子 公式的推导需要很高的水平, 与实际问题相差较远,对应用者要求很高。 2. 计算机利用自己强大的计算能力和存储能力, 采用”猜”的方式, 试探法. 能解决问题的领域更广, 更结合实际. 例 旅行推销员问题 旅行推销员问题的搜索空间 2.1 回溯算法Backtracking Strategies 递归过程A simple recursive procedure 输入: 问题的初始状态. . The input: the initial state. 输出:一个规则表. 应用这个规则表可以把初始状态变为目标状态. 否则回答FAIL. The output of the procedure, a list of rules, using it we can get the goal from the initial state. If the procedure can not find the solution, it return FAIL. 4 LOOP: if NULL(RULES), return FAIL; 5 R ← FIRST(RULES); 6 RULES ← TAIL(RULES); 7 RDATA ← R(DATA); 8 PATH ←BACKTRACK( RDATA); 9 if PATH = FAIL , go LOOP; 10 return CONS( R, PATH) In step 3, after get the list of rules using the function APPRULES, we need to order the rules in the lists. The ordering is very important. If the “better” rule is put in the front of the list, it can be used firstly, the efficiency of the system is high. If the “worse” rule is put in the front, the system needs to try more rules, the efficiency of the system is poor. The Example of Backtracking procedure. The 4 queen problem The problem representation the global database: 4*4 array the rule: Rij If i= 1 : there are no queen in the array 1 i= 4: There is a queen in the row i-1 then put a queen in the row i, column j We order the rules according to the column. 我们用Rij表示在棋盘的第 i 行第 j 列放一个王后. 按行的增加顺序依次放皇后, 在规则的排序上依列的上升次序排序. Termination condition: there are 4 queens in the chess board, they can not kill each other. 终止条件: 4 皇后都放到棋盘上, 且不能互相杀死. We can use more informed rule ordering using function diag(i,j) 我们可以采用含有较多信息的函数diag(i,j) . Diag(i,j) = the length of the longest diagonal passing through cell(i,j) diag(i,j) 是通过单元(i, j)的最长对角线的长度, 我们按diag(i,j)排序, we order

文档评论(0)

1亿VIP精品文档

相关文档