April7_StateOfProgram.docx

guitarchanceSoftware and s/w Development

Aug 15, 2012 (4 years and 4 months ago)

214 views

Osgood Decision Tree

By: Tony Leung

1.
Design


The program is designed with the MVC model in mind. The business logic
consists of classes that represents the decision tree. Main.java is used as the main
controller. The view is represented by the keyboard
handler and other various
handlers. The main controller has access of other controllers (DOTController.java
and XMLController, SimulationController) that are responsible for various inputs
and outputs.

2.
Functional

Parts

2.1 Business Logic


The business l
ogic that deals with the creation and manipulation of the tree
is complete. The business logic focuses on design through interfaces; interfaces
include the decision tree, basic edge and tree nodes interfaces.
The business logic is
controlled by the main c
ontroller which handles the creation, modification and
deletion of the decision tree.
At this moment the controller can handle only one
decision tree at a time.

2.1.1 DecisionTree


BasicDecisionTree.java inherits from decision tree interface.
This class i
s
responsible for validating and performing the rollback on the decision tree.

2.1.2

Edge


ChanceEdge and BasicEdge inherits from the edge interface. These classes
represent the connection and action between tree nodes.

2.1.3 TreeNodes


Terminal node, cha
nce node and decision node inherits from tree node
interface. These classes represent the different type tree nodes supported by
decision

tree.

2.2 Vensim


The
simulation model that is responsible for running the simulations in the
decision tree is comple
te.
Currently the simulation model is only functional for
vensim.
The simulation model focuses on design through interfaces; interfaces
include simulation controller interface, modeling agent object interface and
modeling agent action stack interface.


2.
2.1 Simulation Controller



VensimSimulationController.java inherits from the simulation controller
interface. This controller is responsible for creating the vensim action objects from
the decision tree and use these actions to run the simulation using ve
nsim to
calculate each of the terminal values.

2.2.2 Modeling Agent Object


Vensim Object inherits from the modeling agent action object interface. This
object represents the action that a specific node takes. This action is then used by
the simulation co
ntroller to run the simulation of the decision tree.

2.2.3 Modeling Agent Action Stack


VensimActionStack inherits from the modeling agent action stack interface.
This stack is contains all the vensim objects that are used to run the simulation of
the deci
sion tree.

2.3 XML Handler


The xml handler tha
t

is responsible for loading and writing
of the decision
tree
to XML is complete. The package include
s

a XMLController and a write and load
class. The xml controller is responsible for managing the loading and writing

of the
decision

to xml. The xml format is specified
XMLConventions.doc.

2.4 DOT Handler


The dot handler that is responsible for writing of

the decision tree to DOT is
complete. The package includes a DOTController and a write and load class. For the
presentation, the application “Graphviz” was used to display the output DOT file.

2.5 Keyboard Handler


The keyboard handler was put in place fo
r the purpose of the presentation. It
simply parses out command line arguments and call the corresponding actions with
the main controller. Currently the keyboard handler can only handle these
commands: load xml, write xml, simulation setup, running simula
tion, perform
rollback and output to DOT.


3. Testing


The project was designed by using test driven development in mind. To
accommodate the use of interface focus design, testing was done using mock objects
and unit testing. JMock 2.2 and JUnit 4.4 was
used. The business logic and
simulation model was completed using the test driven approach. However, due to
time constraints, testing was not completed for the XML, DOT and keyboard
handlers.


4.
Future work

4.1 Testing


As mentioned above, the testing of

the XML, Dot and ke
yboard handler is not
complete. The use of mock objects and unit test should be implemented for these
packages in order to completely finish these packages.

4.2

GUI Implementation


A gui interface is needed to communicate with the main
controller. This gui
will be similar to the keyboard handler in that it will take in commands from the
user (inputs), parse this information and call the corresponding methods in the
main controller. This gui needs to allow the users to build, manipulate,
delete, load
and write trees in various formats.


5.
Manual

5.1 Setup


The XML handler, DOT handler and simulation model require the user to
hardcode the path of which the xml files, dot files and simulation models are stored.
To change this path, the use
r must change the filePath global variable in the
XMLController.java, DOTController.java and VensimSimulationController.java.

5.2 Running the Program


To run the program hit the run button in the netbeans project. By default,
this will load up the keyboard

handler to allow users to enter commands from the
command line.

5.2.1 Load/Write XML


To load a file from XML, type “load
filename
”. This will try to load the
specified xml file from the file path specified in the XMLController. For the purpose
of the
presentation, if the filename is not specified, the controller will load
“RabbitExample.xml” located in the file path. When load is performed, the xml
handler will parse out the xml file and create from scratch the tree specified by the
xml file. The decis
ion tree in the xml file does not have to be a valid tree. The loading
process will replace any unsaved decision tree that was created prior to the load
process.

To write a file from XML, type “write
filename
”. This will create the specified
xml file to th
e file path specified in the XMLController. When write is performed, the
xml handler will take each component of the decision tree and parse it to xml. The
write function will overwrite any existing files that have the same file name in the
file path. The
decision does not have to be a valid tree.

5.2.2 Write DOT

To write a file to DOT, type “dot
filename
”. This will create the specified xml
file to the file path specified in the DOTController. For the purpose of the
presentation, if the filename is not sp
ecified, the controller will create a file called
“outfile.dot” and place it in the file path. When write is performed, the DOT handler
will take each component of the decision tree and parse it to dot. The write function
will overwrite any existing files
that have the same file name in the file path.

5.2.3 Simulation


Before a simulation can be performed, the simulation must be initialized with
the simulation model. To initialize the simulation, type “sim init
simulationModel”.
This will load the specifie
d simulation model from the file path specified by the
VensimSimulationController. For the purpose of the presentation, if the simulation
model is not specified, the controller will load the default simulation model

RABBIT_Feb2008.vpm

. After the simulati
on has been initialized, the user can list
the simulation variables in the loaded model or run the simulation.


To list the simulation variables in the simulation model, type “sim list”. This
will display the list of variables that the simulation uses.


To run the simulation, type “sim run
simulationName
”. This will perform the
simulation starting at time 0 and calculate the value of all terminal nodes in the
decision tree. The decision tree must be a valid decision tree. The simulation will
also remove a
ll node values and replace them with the simulated values. For the
purpose of the simulation, if the simulation name is not given, “Default Simulation”
will be used as the simulation name.

5.2.3 Rollback


To perform a rollback, type “
rollback”. This will
perform rollback on the
current decision tree, which calculates each value of the intermediate tree nodes.
Rollback can only be performed on valid decision trees that have values to its
terminal nodes.


5.3 Running a sample script.


To run a sample script,

type “script”. This will load the default
RabbitExample.xml file from the specified path to create a decision tree. It will use
the default
RABBIT_Feb2008.vpm

as its simulation model and run the simulation as
“Default simulation” at time 0.0
.

It will crea
te a DOT file “outfile.dot” from the
decision tree.