# Javalanche: An Avalanche Predictor

The model is to be applied when there has been snowfall during the last 24-hour period. There are three input variables:

Slope_Pitch, the average slope angle (degrees) in the region of the suspected avalanche danger

Water_Equiv, the snowfall's water content (centimeters of equivalent water)

Current_Temp, the current temperature (Celsius)

To introduce fuzzy sets, we'll start with the input variable, Slope_Pitch. Wild slopes do not, of course, have constant pitch and even a measurement of average pitch is approximate. Nor is it clear that the distinction between a number like 15.2 degrees and 17.3 degrees is all that useful. Fuzzy sets provide a way to incorporate that inherent fuzziness into a model. We somewhat arbitrarily classify the Slope_Pitch variable into four categories, based loosely on the corresponding skiing ability needed to competently negotiate the terrain. These categories are Novice, Intermediate, Advanced and Expert.

**Figure 1. Fuzzy
Set for Novice Slope_Pitch**

**Figure 2. The
Four Fuzzy Sets for Slope_Pitch**

There is no widely accepted ski industry standard for these terms, but there is an approximate agreement on what they imply. For example, most skiers would consider the pitch range of 0 to 10 degrees as Novice, but there would be less agreement on the angle at which the slope would be considered no longer Novice, but Intermediate. Fuzzy Logic would accommodate this uncertainty by defining a fuzzy set for novice slope pitch as shown in Figure 1, where the vertical axis is called the degree of membership (dom). In Figure 2, the fuzzy sets for Intermediate, Advanced and Expert are incorporated as well. Looking at Figure 2, an input Slope_Pitch of 17.5 degrees would have a degree of membership of 0.25 in the Novice category and of 0.75 in the Intermediate category, reflecting the fuzzy transition from Novice to Intermediate Slope_Pitch. Ascertaining the doms of the various input values is called the fuzzification process.

**Figure 3. The
Three Fuzzy Sets for Water_Equiv**

**Figure 4. The
Three Fuzzy Sets for Current_Temp**

Figures 3 and 4 show fuzzy set choices for the other two input variables, Water_Equiv and Current_Temp. The choices of fuzzy set ranges and shapes are somewhat arbitrary, but should be guided by the knowledge of the expert. From Figures 2, 3, and 4 we see that the model has the following sets:

Four fuzzy sets for Slope_Pitch

Three fuzzy sets for Water_Equiv

Three fuzzy sets for Current_Temp

There is only one output variable, Avalanche_Danger. It is scaled from 0 to 100. It is tempting to interpret this as the probability of avalanche, but at this current stage of development it is an arbitrary scale. If the model were significantly enhanced and then used both extensively and successfully, this parameter could be calibrated and perhaps be rather like a probability. Figure 5 depicts the four fuzzy set categories for Avalanche_Danger.

**Figure 5. The
Four Fuzzy Sets for Avalanche_Danger**

Note that the expert snow scientist must be consulted by the programmer to construct the fuzzy sets. It can be expected that these would be modified and additional inputs incorporated as experience with the model is gained.

Rules come in both conditional and unconditional varieties.
For Javalanche, only conditional rules are currently implemented. A
typical rule might be “If Water_Equiv is Small AND Slope_Pitch is
Novice AND Current_Temp is Below_Freezing, then Avalanche_Danger is
Low.” The **if** clause (antecedent)
of the rule contains input fuzzy sets, while the
**then** clause (consequent) contains
output fuzzy sets. Each of the rules here links three fuzzy sets in
the antecedent with the “AND” conjunction. Each consequent
involves a single output fuzzy set.

**Figure 6. Rules
for Current_Temp = Below_Freezing**

**Figure 7. Rules for Current_Temp = Near_Freezing**

**Figure 8. Rules for Current_Temp = Above_Freezing**

Recall that the multiplicity of fuzzy sets for the three input variables is 4, 3 and 3, so that the total number of rules is the product, 36. Rather than quote each of the 36 rules, we represent them with the three tables shown in Figures 6, 7 and 8. Extracting a rule from a table is straightforward. The table entries show Avalanche_Danger for two inputs, Water_Equiv (row) and Slope_Pitch (column) while the third input is contained in the figure label. For example, in Figure 6, the upper left corner entry is “Low” and the corresponding inputs are:

Water_Equiv = Small (row)

Slope_Pitch = Novice (column)

Current_Temp = Below_Freezing (Figure 6's label)

Hence the related rule is, “If Water_Equiv is Small AND Slope_Pitch is Novice AND Current_Temp is Below_Freezing, then Avalanche_Danger is Low”; the same rule quoted earlier.

Just as for the fuzzy sets, the expert snow scientist must be consulted by the programmer in order to compose adequate rules. As with the fuzzy sets, experience with applying the model in the real world will most likely result in adjustments to the rules.

## Geek Guides

Practical (and free!) books for the most technical people on the planet.

- NEW: Get in the Fast Lane with NVMe
- NEW: Take Control of Growing Redis NoSQL Server Clusters
- Linux in the Time of Malware
- Apache Web Servers and SSL Encryption
- Build a Private Cloud for Less Than $10,000!

**Plus many more.**

## Trending Topics

How to Deliver Hybrid Apps in 2 Weeks [Webcast] | Jul 07, 2015 |

One Port to Rule Them All! | Jul 06, 2015 |

Privacy Is Personal | Jul 02, 2015 |

July 2015 Issue of Linux Journal: Mobile | Jul 01, 2015 |

July 2015 Video Preview | Jul 01, 2015 |

PHP for Non-Developers | Jun 30, 2015 |

- One Port to Rule Them All!
- Privacy Is Personal
- PHP for Non-Developers
- Secure Server Deployments in Hostile Territory
- Linux Kernel 4.1 Released
- Django Templates
- July 2015 Issue of Linux Journal: Mobile
- A Code Boot Camp for Underprivileged Kids
- Practical Books for the Most Technical People on the Planet
- Attack of the Drones

## Free Training

### Integrating Linux in a Windows Enterprise Environment

**Enjoyed this preview? Get the full course FREE from**

*Linux Journal*and Pluralsight.