Javalanche: An Avalanche Predictor
To see how a Fuzzy Logic algorithm works, we'll make an example calculation. Of course, such calculations are done by the program, but hand calculations are essential for understanding and for debugging the program. The steps we'll go through are:
Start with three crisp input values.
Fuzzify those three values.
Evaluate the appropriate rules from the 36 available, obtaining fuzzy outputs.
Defuzzify the outputs to obtain a crisp output.
Let's say we have measured/estimated the three input variables to be Slope_Pitch = 17 degrees, Water_Equiv = 5 centimeters, and Current_Temp = 3 Celsius. These are the crisp values.
To fuzzify an input variable means finding its doms in all its fuzzy sets. Using Figure 2, we find that Slope_Pitch has these doms in its fuzzy sets:
Novice dom = 0.3
Intermediate dom = 0.7
Advanced dom = 0.0
Expert dom = 0.0
Similarly, from Figure 3, the Water_Equiv values are
Small dom = 0.0
Medium dom = 1.0
Big dom = 0.0
Below_Freezing dom = 0.0
Near_Freezing dom = 0.5
Above_Freezing dom = 0.5
After fuzzification, the rules are evaluated. Not all the rules will apply in each instance. In particular, if any of the three inputs has a dom = 0.0, then that rule does not apply. From the preceding dom calculation we see that two fuzzy sets for Slope_Pitch, one fuzzy set for Water_Equiv, and two fuzzy sets for Current_Temp have nonzero dom values. Consequently, four ( = 2x1x2) rules apply; namely, the first two in the middle row of Figure 7 and the first two in the middle row of Figure 8.
We'll continue our sample calculation by evaluating only one of the four rules. Let's consider the rule that has a consequence of Moderate Avalanche_Danger, from Figure 7: “If Water_Equiv is Medium AND Slope_Pitch is Intermediate AND Current_Temp is Near_Freezing, then Avalanche_Danger is Moderate.”
To evaluate this rule, we combine the doms of the antecedent fuzzy sets by forming their product:
Slope_Pitch has Intermediate dom = 0.7
Water_Equiv has Medium dom = 1.0
Current_Temp has Near_Freezing dom = 0.5
The product = 0.35 is then assigned to the output, i.e., the Avalanche_Danger value has a dom of 0.35 in the Moderate fuzzy output set. Using the product of the doms to combine the fuzzy sets joined by the AND conjunction is called the “product AND”. Fuzzy Logic allows other choices (see Cox's book).
The other three rules which apply in our case must also be evaluated. We won't do those calculations here—they are quite similar to the evaluation of the first. Note that of the four rules that apply, two have a consequence of Moderate and two have a consequence of Low. We choose to combine the dom values for the Low fuzzy set by adding them together, thus allowing each rule that fires to have an effect. We do the same thing for the Moderate doms. This is often done in decision-making problems, but is not the only option possible (again, see Cox's book). Hence, we now have these dom values for Avalanche_Danger:
Low = 0.3
Moderate = 0.7
High = 0.0
Spontaneous = 0.0
These dom values are then “defuzzified”, as in Figure 5. After looking at the figure with these dom values, it seems reasonable to conclude that the resultant number will be between 10.0 and 20.0, and because the Moderate dom is stronger, it ought to be closer to 20.0 than to 10.0. In practice, we use a weighted average known as the “center of gravity”, and it yields 19.0 for this case. We won't do the detailed calculation here.
Thus, for our sample calculation, the input values of Slope_Pitch = 17 degrees, Water_Equiv = 5 centimeters, and Current_Temp = 3 have led to an output value of Avalanche_Danger = 19.0, a value mostly in the Moderate region, but with some membership in the Low region.
The software is available via anonymous FTP from ftp://turing.sirti.org/pub/ras/fuz3.tar.gz. When unzipped and unarchived, it will produce a directory tree with fuz3 as the top node. The top node contains a README file, enabling a user to both use and modify the package. To execute the software, it is assumed that the user's machine has Java properly installed. We used JDK1.1.1.
In the lowest subdirectory, io_n_sets, three files contain the fundamental classes chosen for the model, as follows:
ioput.java contains a class for input and output variables.
fz_set.java contains a class for the fuzzy sets.
cond_rule contains a class for the conditional rules.
These classes contain no information specific to the avalanche prediction model.
The parent directory of io_n_sets is init_n_run which contains two source files of interest: make_init_file.java and run_eng.java. The first of these creates an initialization file, fz_init.dat, which is read by run_eng.java to initialize its Fuzzy Logic “engine”. Only make_init_file.java contains the model for the avalanche predictor. Hence, it may be modified to apply the software to other decision-making problems. As expected, after initializing itself, run_eng.java requests the input variable selection from the user, then runs the Fuzzy Logic engine and produces an output result.
The software can be executed from a terminal window in the X Window System environment by entering the command:
|smbclient Security for Windows Printing and File Transfer||Mar 28, 2017|
|How to Calculate Flash Storage TCO||Mar 27, 2017|
|Non-Linux FOSS: Don't Drink the Apple Kool-Aid; Brew Your Own!||Mar 27, 2017|
|Three EU Industries That Need HPC Now||Mar 25, 2017|
|HOSTING Monitoring Insights||Mar 24, 2017|
|FinTech and SAP HANA||Mar 24, 2017|
- Non-Linux FOSS: Don't Drink the Apple Kool-Aid; Brew Your Own!
- How to Calculate Flash Storage TCO
- smbclient Security for Windows Printing and File Transfer
- Returning Values from Bash Functions
- Two Ways GDPR Will Change Your Data Storage Solution
- Preseeding Full Disk Encryption
- Hodge Podge
- Three EU Industries That Need HPC Now
- GRUB Boot from ISO
- Tech Tip: Really Simple HTTP Server with Python