Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: THEend8_
Introduction
Computers can be used to build models of complex real world systems such as the weather, traffic and stock markets. Computer models can help us to understand the dynamics of these real world systems, and to make decisions about them. For example, a model that can predict Saturday’s weather could help us decide whether to go to the beach or not. A traffic model could help us plan where to build a new road to reduce traffic jams. A model of the stock market could help us decide when to buy and sell shares.
In this project, you will build a simple model of a bushfire spreading across a landscape represented as a two-dimensional grid. The speed and direction that a bushfire will spread in is affected by many factors, including the amount and type of fuel (trees)
available, the slope of the land, and the direction of the wind. Your model will help forecast how much damage (number of grid squares burnt) a fire will do before it burns out.
Models like this (but much more complicated!) are used to help predict which way a fire might spread, to assess where high risk fires are most likely to occur, and help understand how the damage cause by fires can be reduced via management practices.
See Phoenix rapid fire for an example of a much more complex model (developed at the University of Melbourne). Bushfires In this project we will look at three different probl ems related to a bushfire
How to build a bushfire model from a data file (Question 1)
How to determine if a cell in a specific location will ignite (Question 2)
How to model the spread of a bushfire (Question 3)
You will also need to
Write and submit a set of test cases for evaluating the function in Question 3 (Question
4) The bushfire model
We model a bushfire as occurring in a square grid made up of M by M cells. The cell ci,j refers to the cell in the ith row and the jth column of the grid. Each cell typically has eight adjacentcells (horizontally, vertically and diagonally). Cells on the edge of the grid are adjacent to only five other cells; cells in the corners of the grid are adjacent to only three other cells. For co nvenience, we take the top of the grid to be North, the right side to East, the bottom to be South and the left side to be West. Bushfire grid with M=5. The red cells with “X”s are the eight cells that are adjacent to the cell c2,3.
Each cell in the M by M grid has several attributes:
fuel load: the amount of combustible material (trees, leaf litter, etc) in that cell. The fuel load of a cell is represented as a non -negative integer, where 0 (zero) equates to no combustible material.
height: the elevation of the cell. Height is represented as a positive integer (a cell with height 3 is higher than a cell with height 2, which is in turn higher than a cell with height 1, and so on). Fires will tend to spread more rapidly uphill, and more slowly downhill, compared to flat ground.
burning: a Boolean value indicating whether the cell is currently burning or not. A cell can only be burning if it’s fuel load is greater than 0 (zero). In addition, the entire grid is characterised by two further attributes:
ignition threshold: how combustible the landscape is (for instance, a dry landscape would be more combustible than a wet landscape, and have a lower ignition threshold). The ignition threshold is represented by an integer greater than 0 (zero). A non -burning cell will start burning if its ignition factor (explained below) is greater than or equal to the ignition threshold.
ignition factor: the intensity of fire around a particular non -burning cell at a given point in time that, in combination with the ignition threshold described above, will be used to determine whether a cell will start burning. The ignition factor is floating point number; details of how to calculate the ignition factor are provided on the following slides.
wind direction: if a wind is blowing, it can carry embers that allow a fire to spread more rapidly in a particular direction. Wind may blow from one of eight directions: North, Northeast, East, Southeast, South, Southwest, West or Northwest (abbreviated N, NE, E, SE, S, SW, W, NW) or there ma y be no wind. How the wind affects ignition will be explained further on the following slides. Question 1. Parse a bushfire scenario file
Your task is to write a function parse_scenario(filename) that parses a file with the structure described below, validates the contents and returns either a dictionary containing all values required to specify a model scenario if the contents are valid, or None if any of the contents are invalid.
The structure of the file is as follows:
an integer specifying the width and height (M) of the square landscape grid
M lines, each containing M integer values (separated by commas), defining the initial fuel load of the landscape (a visual representation of the M by M grid)
M lines, each containing M integer values (separated by commas), defining the height of the landscape (again, a visual representation of the M by M grid)
an integer specifying the ignition threshold for this scenario
a one or two character string specifying the wind direction for this scenario
one or more lines, each containing the (i,j) coordinates (row number, column number) of a cell which is burning at the start of the simulation
For example, the file ‘bf0.dat’:
bf0.dat
specifies a 2 by 2 landscape:
there is an initial fuel load of 2 in three of the four cells, with a fuel load of 0 in the cell c1,0
the height of all cells in the first column ( j=0) is 1, while the height of all cells in the second column (j=1) is 2 (ie, the landscape slopes up toward the East)
the ignition threshold is 1
a wind is blowing from the North