Hide menu

TDDC17 Artificial Intelligence

TDDC17-Lab4

Aim

The purpose of this lab is to provide you with a software platform that will enable you to construct Bayesian Networks and perform inference on them. In doing this, you will acquire hands-on experience in using Bayesian Networks as a tool for constructing probabilistic models and using them for probabilistic inference.

Preparation

Read chapter 13.1-6 and 14.1-4 in the course book before doing this lab. It is important that you do this. You should have an understanding what Bayesian Networks are, how they are constructed and their theoretical underpinnings before doing this lab.

Part I: Tutorial

The purpose of the first part of this lab is to introduce you to the Java Applet that will be used to construct Bayesian Networks. There are a number of tutorials which walk you through the process of this construction and explain different ways to query Bayesian Networks.

The software that you will use during the lab is called "Bayes Applet" and can be found at http://www.cs.ubc.ca/labs/lci/CIspace/Version3/bayes/index.html.To start the applet, just click on the "New window" button.

The tutorials you will go through can be found at http://www.cs.ubc.ca/labs/lci/CIspace/Version3/bayes/help/tutorials.html. It is strongly recommended that you read at least the first and the third tutorial. Tutorials 4 - 6 cover variable elimination algorithms and how to build decision networks with the tool. More on this may also be found in the course book. The topics in tutorials 4-6 are not covered in this lab so you can safely skip reading those tutorials unless you are interested.

Due to the nature of applets, you can not save your networks directly to your account. Instead you'll have to click on the "Edit/ViewEdit Text representation (.xml format)" in the applet and copy and paste the contents to a local file.

There is no examination on this part of the lab but you are encouraged to model the earthquake example on page 494 in the course book.

Part II: Querying an existing network

In this part of the lab, you will be provided with an existing Bayesian Network. The purpose is to provide you with a chance to query the Network and investigate probabilisitic inference on such networks.

Scenario

The local nuclear power plant has been running for a long time and now the owner wants to know whether there has been any degradation in the safety of the plant. He therefore hires safety experts who use Bayesian Networks as a modeling tool for prediction and explanation. After spending a number of weeks gathering empirical data they create the network in figure 1 and save the data in this file.


Figure 1: The Bayesian Network for the nuclear plant

Task for part II

The owner asks you to start experimenting with the network and find out how safe the plant is.
  1. Start the applet and choose "Edit/ViewEdit Text representation (.xml format)". A window with the XML representation of the current (empty) network will pop up. This window can be used to edit or save the current network.
  2. Copy and paste the network part of the file bayesian_net/nuclear_power_station.xml into the corresponding network tag in the empty network.
  3. Press the "Update Graph" button. You should now see that a network has been created in the original applet window.
  4. Set the "Query Control Options / Decimal Places for Monitoring" to 5. This means that you will be able to see small changes in probabilities.
  5. Use the applet and the loaded Bayesian Network to answer the following questions:
    • What is the risk of melt-down in the power plant during a day if no observations have been made? What if there is icy weather?
    • Suppose that both warning sensors indicate failure. What is the risk of a melt-down in that case? Compare this result with the risk of a melt-down when there is an actual pump failure and water leak. What is the difference? (The answer must be expressed in conditional probabilities)
    • The conditional probabilities for the stochastic variables are often estimated by repeated experiments or observations. Why is it sometimes very difficult to get accurate numbers for these? What conditional probabilites in the model of the plant do you think are difficult or impossible to estimate?
    • Assume that the "IcyWeather" variable is changed to a more accurate "Temperature" variable instead (don't change your model). What are the different alternatives for the domain of this variable? What will happen with the probability distribution of P(WaterLeak | Temperature) in each alternative?

Part III: Extending a network

Scenario

The owner of the nuclear plant is quite selfish and wants to optimize profit of the plant at the expense of safety, yet he is very worried about his future survival in case a problem with the plant arises. Instead of increasing the safety of the plant which is costly, he decides to analyse his chances of escaping from the plant in case of a melt-down. As an apprentice to the owner, the owner wants you to investigate the properties of his escape vehicle (his car). Your model of the car is the same as in exercise 14.1 in the course book with the extension of the "IcyWeather" variable, which of course is the same as we already have in our model of the plant. After a year of observations and subjective assumptions you come up with the following conditional and prior probabilities:
  • P(battery | icyWeather) = 0.8
  • P(battery | ¬icyWeather) = 0.95
  • P(radio | battery) = 0.95
  • P(ignition | battery) = 0.95
  • P(gas) = 0.95
  • P(starts | gas ∧ ignition) = 0.95
  • P(moves | starts) = 0.95
  • P(survives | moves ∧ melt-down) = 0.8
  • P(survives | moves ∧ ¬melt-down) = P(survives | ¬moves ∧ ¬melt-down) = 1.0
  • P(survives | ¬moves ∧ melt-down) = 0.0
Fill in the rest of the probabilities by using common sense reasoning about the domain.

Task for part III

  1. Model the car with the applet tool and integrate it with the model of the plant.
  2. Answer the following questions:
    • During the lunch break, the owner tries to show off for his employees by demonstrating the many features of his car stereo. To everyone's disappointment, it doesn't work. How did the owner's chances of surviving the day change after this observation?
    • The owner buys a new bicycle that he brings to work every day. The bicycle has the following properties:
      • P(bicycle_works) = 0.9
      • P(survives | ¬moves ∧ melt-down ∧ bicycle_works) = 0.6
      • P(survives | moves ∧ melt-down ∧ bicycle_works) = 0.9
      How does the bicycle change the owner's chances of survival?
    • It is possible to model any function in propositional logic with Bayesian Networks. What does this fact say about the complexity of exact inference in Bayesian Networks? What alternatives are there to exact inference?

Part IV: More extensions

Scenario

After your excellent analysis of the plant's Bayesian Network and the creation of the model of the owner's car, he realizes that he is still in great danger. He comes to the conclusion that he needs to hire someone who is in charge of the plant's safety. After some job interviews he decides that a Mr H.S. is the most suitable person for the job because he practically works for free. But Mr H.S. has some less appealing properties:
  • He sleeps a lot during work which means that he can not react that rapidly to warning signals and so on.
  • He is very incompetent. Even if he is awake it doesn't mean that he knows what to do in case of an emergency.
You volunteer for the task of modeling Mr H.S.'s behavior with the help of the "Bayes Applet" tool.

Task for part IV

  1. Using your own modeling creativity, create a model of Mr H.S. with the Applet tool. The requirements of the model are the following:
    • It must be integrated with the model of the nuclear plant and must depend on the "WaterLeakWarning" and "PumpFailureWarning" stochastic variables.
    • It must contain at least four stochastic variables.
    • It should match fairly well with the informal description of Mr H.S.'s properties given in the scenario description.
  2. Answer the following questions using your model:
    • The owner had an idea that instead of employing a safety person, to replace the pump with a better one. Is it possible, in your model, to compensate for the lack of Mr H.S.'s expertise with a better pump?
    • Mr H.S. fell asleep on one of the plant's couches. When he wakes up he hears someone scream: "There is one or more warning signals beeping in your control room!". Mr H.S. realizes that he does not have time to fix the error before it is to late (we can assume that he wasn't in the control room at all). What is the chance of survival for Mr H.S. if he has a car with the same properties as the owner? (notice that this question involves a disjunction which can not be answered by querying the network directly)
    • What unrealistic assumptions do you make when creating a Bayesian Network model of a person?
    • Describe how you would model a more dynamic world where for example the "IcyWeather" is more likely to be true the next day if it was true the day before. You only have to consider a limited sequence of days.

Part V: Meltdown

Scenario

Disaster strikes the power plant and fortunately every worker manage to escape the plant before it is too late. The owner, however, is stuck in his office with no way out. Suddenly he becomes aware of a possible escape path through a trap door (where he used to drop unwanted visitors). The trap door leads to a cave which contains bottomless pits. The lights are out (due to the meltdown) and the owner has no map of the cave which means that he must rely on his other sensors to get by in the cave. To summarize the situation, the cave is very similar to the wumpus world described in section 7.2 in the course book with the main difference that the gold is replaced with an exit and the agent (owner) does not have to return to square (1, 1). The cave contain bottomless pits with a probability of 0.2.

Task for part V

  1. Model a 3x3 wumpus-like world which only contains pits and breeze sensors (see section 13.7 in the course book) with the Applet tool. Warning: It is possible to create a network and a set of observations that is inconsistent. Take for example a network where a breeze has been observed but no adjacent pit exists. When this happens in the Applet tool, it is sometimes impossible to monitor or query random variables in the model (possibly due to division by zero in the implementation).
  2. Verify that the model returns the same probabilities for all the possible query variables in the situation depicted in figure 13.6 in the course book.
  3. Model the relation between the possible adjacent pits and the breeze sensor as a noisy-OR relation where P(breeze | adjacent_pit_1 ∧ ¬adjacent_pit_2 ∧ ¬adjacent_pit_3 ...) = 0.95.
  4. Trace the owner when he is (rationally) moving in the 3x3 environment given in figure 2 below.


Figure 2: The owner's cave

How to report

The examination for this lab will consist of the following:
  1. Demonstrate your networks to the lab assistant. The lab assistants may have some extra questions for you that you have to answer correctly during the demonstration.
  2. Write a report where you answer all the questions in part II-IV. In those answers where the applet is used for obtaining the result, you must clearly describe what variables you choose to observe and why.

Acknowledgements

This lab has been developed by Per Nyblom (perny@ida.liu.se)



Page responsible: Fredrik Heintz
Last updated: 2009-02-24