%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Bayesian updating applied to boiler control. %
% Derived from "Intelligent Systems for Engineers and %
% Scientists", 3rd edition, A.A.Hopgood, CRC Press, 2012. %
% See Chapter 3. %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
/*
To run the programme, compile, then enter a query like this in the Console:
bayes_boiler( 0, 1, 1, 0.1, 0.02, P ).
Of course, you can change the numerical values.
*/
group bayes_boiler_rules
r3_4b ,
r3_3b ,
r3_2b ,
r3_1b .
uncertainty_rule r3_1b
if release_valve is stuck
then task becomes clean_release_valve.
uncertainty_rule r3_2b
if warning_light is on (affirms 2.20; denies 0.20)
then release_valve becomes stuck.
uncertainty_rule r3_3b
if pressure is high (affirms 85.0; denies 0.15)
then release_valve becomes stuck.
uncertainty_rule r3_4b
if temperature is high (affirms 18.0; denies 0.11)
and water_level is low (affirms 0.10; denies 1.90)
then pressure becomes high.
relation bayes_boiler( P1, P2, P3, P4, P5, P6 )
% Use P1, P2, P3, P4, and P5 for prior probabilities.
% Use P6 to return probability of "release_valve is needs_cleaning";
% its prior probability is the default value, i.e. 0.5
if reset all probability values
and trace propagation % switches on the trace
and the probability that the water_level is low = P1
and the probability that the warning_light is on = P2
and the probability that the temperature is high = P3
and the probability that the pressure is high = P4
and the probability that the release_valve is stuck = P5
and propagate bayes_boiler_rules probability rules
and the probability that the release_valve is needs_cleaning = P6 .