⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 readme

📁 人智算法基本程序
💻
字号:
				    Discrimination Tree ProgramWelcome to the wonderful world of the Discrimination Tree C++directory.  This program demonstrates building a discrimination tree givensome formulas, and accessing matching to a given formula. It is meant tobe a companion to chapter 4 of the "Artificial Intelligence"textbook. This code was written by Jon Monsarrat, jgm@cs.brown.edu.Five sections describe the program:1. The problem2. Building the program3. Making example files4. Running the program5. The solution, and how to read the source code----------------------------------------------------------------------1. The problemThe book goes into quite some detail about the problem, but here it isin a nutshell.We want to store a database of predicate calculus formulas, andperform fast lookups on matches. The formulas can contain variables,and a variable can match either a symbol, another variable, or asubexpression. The formulas can have arbitrarily nested subexpressions.Matching is not a unification matching. No attempt is made to filterout a match of ((? x) (? x)) and (a b), for example.This program reads in add (storage) and fetch (matching) commands from a file.----------------------------------------------------------------------2. Building the programThe source code in this directory is complete and does not depend uponany other source code from the textbook. It only uses standardand libraries which should come any C++ compiler.You can build this program in UNIX by simply typing      makeYou may need to edit the Makefile to change the name of the compiler,if you do not have a compiler named "CC".You do not need to recompile the program to change examples. Examplesare stored in files.----------------------------------------------------------------------3. Making example filesAn example file specifies the vertices and all the connections between them.It is laid out is this order:   1. Several commands, each on its own line:      a. The word "add" for storage, or the word "fetch" for lookup by matching      b. The formula to add or fetch:         i. a series of symbols, enclosed by at least one ( ) pair        ii. A word beginning with a '?' is a variable, otherwise it is a symbolThere is only one example file in this directory:    block.examplesHere is how it is laid out:add ( on block2 ( floor room17 ) )add ( on block1 table2 )add ( on ?x ?y )add ( on ?z ?z )add ( instance block block1 )add ( instance block block2 )fetch ( on ?w ?w )fetch ( instance block ?x )fetch ( on ?x ?y )fetch ( on a b )fetch ( on ?x ( floor ?y ) )----------------------------------------------------------------------4. Running the programRunning the program is very simple. Just type   dtree filenamewhere "filename" is the name of the example file you want to read in.----------------------------------------------------------------------5. The solution, and how to read the source codeThis solution is quite close to the Lisp version given in the textbook.The classes are:   DTree     -- Holds the entire discrimination tree. You can do add's, fetch's   Node      -- One node in the discrimination tree. Can hold formulas   Formula   -- A linked list of keys, with arbitrary nested subexpressions   Key       -- Part of a formula. May be a variable, symbol, or ( or )Additions to the DTree are performed by doing a depth first exact matchingof all the keys in the formula to be added. If no child of a node is foundexactly matching the next key, then a new child is created. When thedepth first search ends, the formula is added to the node if it is notalready present.Fetching from the DTree is done by a depth first search which matcheseach of the keys against the keys for each node's children. For any keysthat match, the search continues.Eventually, the program may say that no matches were found, orit will print out the list of resulting formulas from the match.This program is reasonably straightforward, but with a couple ofspecial cases when you want to match a variable against asubexpression, which may itself have nested subexpressions.There are 4 source files in this directory:   DTree.C      Holds the DTree class   Formula.C    Holds the Formula class   Key.C        Holds the Key class   Node.C       Holds the Node class   String.C     A generic strings library, a copy of the UNIX standard----------------------------------------------------------------------

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -