ñòð. 105 |

string +

"The problem is to move the disks from spindle #1 to #3\,";

string +

"one disk at a time, never placing a larger disk on a

smaller. \n";

string +

"HANOI will solve this problem recursively, in that

rules ";

string +

"make themselves refireable until a desired state is ";

string +

"reached. Rule weights ensure that rules fire in the ";

string +

"proper sequence. HANOI.FPS has one rule for input,";

string +

" one to quit, and only three to solve the problem. \n";

message "<string>";

fire all off;

fire block 0 on;

message "Ready to run...\n";

:run;

TEAM LinG - Live, Informative, Non-cost and Genuine !

306 APPENDIX

:Exercise Imply.fps - calculates truth value of P->Q for

several implication operators.

declare Data P flt Q flt Imply1 flt Imply2 flt Imply3

flt;

:rule r0

rule (goal Input initial truth values)

IF (in Data P.cf = 0)

THEN

input "Enter truth value of P" 1 P,

input "Enter truth value of Q, negative to quite" 1 Q;

:rule r1

rule (goal Calculate truth value of P implies Q for P <= Q)

IF (in Data P = <P> AND Q = <Q> AND Q >= 0 AND P <= <Q>

AND Imply1.cf = 0)

THEN

in 1 Imply1 = 1 Imply2 = (min(1, 1 - <P> + <Q>)) Imply3

= (max(1 - <P>, min(<P>, <Q>)));

:rule r2

rule (goal Calculate truth value of P->Q for P > Q)

IF (in Data P = <P> AND Q = <Q> AND Q >= 0 AND P > <Q> AND

Imply1.cf = 0)

THEN

in 1 Imply1 = 0 Imply2 = (min(1, 1 - <P> + <Q>)) Imply3

= (max((1 - <P>), min(<P>, <Q>)));

:rule r3

rule (goal Quit on negative Q)

IF (in Data Q < 0) THEN exit;

:rule r4

rule (goal Print results)

IF (in Data P = <P> AND Q = <Q> AND Imply1 = <I1> AND

Imply2 = <I2> AND Imply3 = <I3>)

THEN

message "P <P> Q <Q> \nP->Q(1) <I1> : P->Q(2)<I2> :

P->Q(3) <I3>",

delete 1,

make Data;

make Data;

string = "Program IMPLY.FPS to evaluate implications is

ready to run.\n";

TEAM LinG - Live, Informative, Non-cost and Genuine !

307

APPENDIX

string + "Comparison of different fuzzy implication

operators:\n";

string + "See Klir and Yuan(1995, p. 309).\n";

string + "1) P->Q = 1 if P <= Q, else = 0 (Gaines-

Rescher)\n";

string + "2) P->Q = min(1, 1 - P + Q) (Lukasiewicz)\n";

string + "3) P->Q = max(1 - P, min(P, Q)) (Early Zadeh)";

message "<string>";

REM Sample fuzzy control program IRC.bas

REM Intersection rule matrix

REM 9 rules

DECLARE FUNCTION MIN (A, B)

DECLARE FUNCTION MAX (A, B)

DECLARE FUNCTION Process (Y0, Z, dT)

DECLARE FUNCTION Pause ()

REM****************************************************

REM IRC.BAS: Explanatory information

CLS

PRINT "Sample fuzzy control program with non-linear process"

PRINT "Uses conventional IRC method with nine rules"

PRINT "System output is Y"

PRINT "inputs: error E, fuzzy set Error (Negative Zero

Positive)"

PRINT "rate R, fuzzy set Rate (Negative Zero Positive)"

PRINT "Control value is Z"

PRINT "Control increment DZ, fuzzy set Control (Negative,

Zero, Positive)"

PRINT "Dt is time interval between input sample value"

PRINT "Press any key to continue..."

WHILE INKEY$ = "": WEND

REM****************************************************

PRINT "Default membership functions"

PRINT "ERROR:"

PRINT "1.0 n z p"

PRINT " -n zz p"

PRINT " -n z z p"

TEAM LinG - Live, Informative, Non-cost and Genuine !

308 APPENDIX

PRINT " - n z z p"

PRINT " - n z z p n = Negative"

PRINT "0.5 + n z z p z = Zero"

PRINT " - nz zp p = Positive"

PRINT " - zn pz"

PRINT " - zn p z"

PRINT " - z n p z"

PRINT "0.0 +zpzpzpzpz+ppppppppp+nnnnnnnnn+znznznznz+"

PRINT " 2LLEZ LLEZ 0 ULEZ 2ULEZ"

PRINT " (-10) (-5) 0 (5) (10) (Defaults)"

PRINT "Press any key to continue..."

WHILE INKEY$ = "": WEND

PRINT "RATE:"

ñòð. 105 |