我在 CLIPS 中有两条规则,如果它们都是真的,我想将它们结合起来……但不知道该怎么做。我有一个名为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=female finaid,并且 es=excellent student)
(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)
)
)