JACK——BOM Exercise5

来源:http://aosgrp.com/

 

Exercise 5

Use a JACOB initialisation file to initialise the BOM beliefset.

 

Introduction

In this exercise, you will modify the Planner agent's constructor so that it no longer reads the data from the text file used in the earlier exercises. Instead, you will create a file in JACOB ASCII format that is read in either when the beliefset is constructed, or by using the beliefset read method in the agent's constructor.

 

Instructions

1. Edit the Planner.agent and remove the code to read the BOM data from the filename passed into the constructor.

2. Modify the #private data BOM bom() declaration so that the filename is now passed to the BOM constructor (#private data BOM bom("bom.dat")).

3. Edit the file bom.dat so that it contains the data in JACOB ASCII format. An example data file is shown below.

<TupleTable

:tuples(

<BOM__Tuple

:component "table"

:subcomponent "leg"

>

<BOM__Tuple

:component "table"

:subcomponent "table_top"

>

)

>

4. Compile and run the program.

5. It is also possible to explicitly invoke the beliefset's read method to read data in JACOB ASCII format. This means that the filename can then be passed as a parameter to the agent's constructor.

  • If necessary, modify the Planner.agent so that the filename is passed in to its constructor.
  • Add the line

bom.read(filename);

in the Planner agent's constructor.

  • Remove the filename from the #private data BOM bom("bom.dat") declaration.
  • Compile and run the program.

示例程序 

 

运行结果

(1) a1 added to orders db:

(2) chair 10 30/01/05

(3) a2 added to orders db:

(4) table 50 20/02/05

(5) a3 added to orders db:

(6) cupboard 60 20/03/05

(7) seat is a subcomponent of chair

(8) chair_back is a subcomponent of chair

(9) arm is a subcomponent of chair

(10) leg is a subcomponent of chair

(11) leg is a subcomponent of table

(12) table_top is a subcomponent of table

 

运行结果分析

运行结果与例4相同,本例着重阐述信念集如何来源于JACOB ASCII 格式的文件。两种方式:(1)可以在Planner Agent声明信念集的时候,将JACOB文件的文件名传入;(2)也可以在PlannerAgent构造时,通过显式调用read()方法读取。

你可能感兴趣的:(bom)