CLIPS には 2 つのルールがあり、両方とも true の場合に結合したいのですが、どうすればよいかわかりません。grant-eligible
...という属性があります。それを設定するとTRUE
、次のルールを読み取って'grant-eligible'
からFALSE
...に設定できると考えていましたが、コードが無限ループに陥っているようです。これを行う...
だからここに私のルールがあります:
(defrule complete "rule for app completeness"
?f <- (application (transcript-received Yes) (app-complete FALSE)
(gpa
?v_gpa&:(
> ?v_gpa 0)))
=>
(modify ?f (app-complete TRUE)))
(defrule denied "rule for admission - DENIED"
?f <- (application (app-complete TRUE) (app-decision FALSE)
(gpa
?v_gpa&:(
< ?v_gpa 3.0))
(ssat
?v_ssat&:(
>= ?v_ssat 0.0))
)
=>
(modify ?f (app-decision DENIED))
)
(defrule accepted "rule for admission - ACCEPTED"
?f <- (application (app-complete TRUE) (app-decision FALSE)
(gpa
?v_gpa&:(
>= ?v_gpa 3.5))
(ssat
?v_ssat&:(
>= ?v_ssat 1500))
)
=>
(modify ?f (app-decision ACCEPTED))
)
これは私が今実装しようとしているものです
(defrule female-finaid "rule for finaid applications for female students"
?f <- (application (app-decision ACCEPTED)
(gender F) (grade-entry Freshman) (country USA)
(grant-eligible TRUE)
(grant ?v_grant)
)
=>
(modify ?f
(grant (+ ?v_grant 5000))
(grant-eligible TRUE)
)
)
(defrule great-students-finaid "rule for finaid applications for female students"
?f <- (application (app-decision ACCEPTED)
(country USA)
(grant-eligible TRUE)
(grant ?v_grant)
(gpa
?v_gpa&:(
>= ?v_gpa 4.0))
)
=>
(modify ?f
(grant (+ ?v_grant 4500))
(grant-eligible FALSE)
)
)
これらのルールが両方とも当てはまる場合、授与される助成金は 9500、5000、または 4500 になるはずです...何かアイデアはありますか?
解決策: (どこにff-grant-eligible
とes-grant-eligible
私のコントロール ファクトがあります...それらは ff=女性フィナイド、および es=優秀な学生の略です)
(defrule female-finaid "rule for finaid applications for female students"
?f <- (application (app-decision ACCEPTED) (ff-grant-eligible TRUE)
(gender F) (grade-entry Freshman) (country USA)
(grant ?v_grant)
)
=>
(modify ?f
(grant (+ ?v_grant 5000))
(ff-grant-eligible FALSE)
)
)
(defrule great-students-finaid "rule for finaid applications for female students"
?f <- (application (app-decision ACCEPTED) (es-grant-eligible TRUE)
(country USA)
(grant ?v_grant)
(gpa
?v_gpa&:(
>= ?v_gpa 4.0))
)
=>
(modify ?f
(grant (+ ?v_grant 4500))
(es-grant-eligible FALSE)
)
)