### COSC-574: Automated Reasoning

Project 2
Fall 2017

Due: T 11/14 @ 5 PM
20 points

For this project, you will implement routines for efficiently manipulating factors based on Koller and Friedman's product-factor algorithm. You will then use these routines to implement Russell and Norvig's variable elimination algorithm.

You must implement the following classes and methods:

• public Variable( String label, int cardinality ), which constructs a variable with the specified label and cardinality.
• public Variable( String label, int cardinality, ArrayList<Variable> parents ), which creates a variable with the specified label, cardinality, and parents.
• public void Variable.instantiate( int value ), which instantiates the variable to the specified value.
• public void Variable.set( int[] assignments, double probability ), which sets the position in the dope vector specified by the assignments to the probability.
• public Network(), which constructs a Bayesian network.
• public void Network.add( Variable variable ), which adds the specified variable to the Bayesian network.
• public Factor Network.elimination( Variable query, ArrayList<Variable> evidence ), which uses the variable-elimination algorithm to compute the probability distribution of the query given the evidence.
• public double Factor.getProbability( int[] assignments ), which returns the probability specified by the assignments.
• public String Factor.toString(), which returns a string representation of the factor.
Note that you will need to implement additional classes and methods, which you can infer from Russell and Norvig's and from Koller and Friedman's algorithms.

1. Russell and Norvig's burglary network,
2. two problems of your choosing from reputable sources with three or more nodes
Implement these three problems as three separate executables: Example1, Example2, and Example3, respectively. The main function for these classes can construct the network through direct assignment. For the burglary network, the main function should instantiate that Mary called and that John called, compute the probability of the alarm sounding, and print its distribution to the console. For the examples that you choose, you are free to select the query and evidence variables. In comments, describe the reasoning problem, the network, its source, and the query and evidence variables. For output, it is sufficient to print the probability distribution of the query variable. Include with your submission a transcript of your program's output on the three problems.

#### Extra Credit

Implement these routines as methods of the Network class and demonstrate their use on the burglary problem by implementing the classes ExtraCredit1 and ExtraCredit2. Include runs of these routines in the the transcript you submit with your project.

#### Instructions for Electronic Submission

In a file named HONOR, provide the following information:
Name
NetID

In accordance with the class policies and Georgetown's Honor Code,
I certify that, with the exceptions of the course materials and those
items noted below, I have neither given nor received any assistance
on this project.


When you are ready to submit your program for grading, create a zip file named submit.zip containing your source files, honor statement, and transcript by typing

\$ zip submit.zip *.java transcript HONOR

Do not include these files in a subdirectory. Upload submit.zip to Autolab. You can submit your assignment to the compile check p2c seven times. You can submit your assignment p2 three times, and you will see the autograder's output for the drug-study problem that we discussed in class. After the deadline, I will use a different autograder to conduct a comprehensive evaluation.