クラス B には 3 つのインスタンスがあり、C には 2 つのインスタンスがあります。A のすべての暗黙的なインスタンスをカウントする JessTab ルールを記述できますか? つまり、5 を返しますか?
Jess でのクラス A のマッピング:
(mapclass http...#A)
A の直接のインスタンスがないため、0 になるインスタンスをカウントするルール:
元は:
(defrule countAinstances
?c <- (accumulate (bind ?count 0)
(bind ?count (+ ?count 1))
?count
(object (ís-a http...#A))
)
=>
(printout t ?c " number of class A instances." crlf))
これは、A のサブクラスのインスタンスをカウントしません。
修正版:
(defrule countAinstances
?c <- (accumulate (bind ?count 0)
(bind ?count (+ ?count 1))
?count
(object (OBJECT ?x&:(instanceof ?x http...#A)))
)
=>
(printout t ?c " number of class A instances." crlf))
次のエラーが表示されます。
Jess は、ルール LHS (TECT) の実行中にルール LHS (TEQ) の実行中に (instanceof ?_20_x(0,2,-1) http...#A) ルーチン instanceof でエラーを報告しました。メッセージ: クラスが見つかりません: http...#A. プログラムテキスト: ( defrule countAinstances ?c <- ( Accumulate ( bind ?count 0 ) ( bind ?count ( + ?count 1 ) ) ?count ( object ( OBJECT ?x & : ( instanceof ?x http...#A ) ) ) ) = > ( printout t ?c "number of class A instances." crlf ) ) at line 20.
ネストされた例外: http...#A