# 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

## Upcoming Webinar

### Getting Started with DevOps - Including New Data on IT Performance from Puppet Labs 2015 State of DevOps Report

August 27, 2015

12:00 PM CDT

DevOps represents a profound change from the way most IT departments have traditionally worked: from siloed teams and high-anxiety releases to everyone collaborating on uneventful and more frequent releases of higher-quality code. It doesn't matter how large or small an organization is, or even whether it's historically slow moving or risk averse — there are ways to adopt DevOps sanely, and get measurable results in just weeks.

Free to *Linux Journal* readers.

August 2015 Issue of Linux Journal: Programming | Aug 03, 2015 |

August 2015 Video Preview | Aug 03, 2015 |

Django Models and Migrations | Jul 30, 2015 |

Secure Server Deployments in Hostile Territory, Part II | Jul 29, 2015 |

Hacking a Safe with Bash | Jul 28, 2015 |

KDE Reveals Plasma Mobile | Jul 28, 2015 |

- August 2015 Issue of Linux Journal: Programming
- Django Models and Migrations
- Hacking a Safe with Bash
- Secure Server Deployments in Hostile Territory, Part II
- The Controversy Behind Canonical's Intellectual Property Policy
- Huge Package Overhaul for Debian and Ubuntu
- Shashlik - a Tasty New Android Simulator
- Embed Linux in Monitoring and Control Systems
- KDE Reveals Plasma Mobile
- diff -u: What's New in Kernel Development