How to use the Drools reverse chain to indicate which baseline facts are needed to achieve a goal?

I am trying to use the Drools reverse chain to find out what facts are needed in order to get an object inserted into working memory. In the following example, I expect to get the fact "go2".

rule "ins a"
when
    String( this == "go2" )
then 
    insert(new A());
end


rule "Run"
when
then
    insert(new String("go1"));
end

rule "Test isThereAnyA"
    when
        String( this == "go1" )
        isThereAnyA(a;)
    then
        System.out.println( "you can get " + a );   
end

query isThereAnyA (A a)
    a := A()
end

I looked at the examples in the official documentation http://docs.jboss.org/drools/release/6.1.0.Final/drools-docs/html_single/index.html#d0e21289 but they show a different situation (the rules in these examples do not create a new fact)

http://docs.jboss.org/drools/release/6.1.0.Final/drools-docs/html_single/index.html#d0e21240 , , , .

.

+4
2

:

, . "go2" .

:

Drools Backward chaining (BC) - WM , .

BC "" "isThereAnyA", , , , "" "A" "go2" . , "... ... .." , .

BC:

query isThereAnyA_InPresenceOfA_String( A a )
   isThereAnyString( $s ; )       
   a := A()
end 
query isThereAnyString( String $s )
   $s := String( this == "go2" )
end

, "go2" . , A , , .

, , . :

  • : new A ($ s)//$s "go2"
  • "insertLogical", "go2" "A", TruthMaintenanceSystem

TMS , .

, , , 6.3, . : - " "? , -? , " " ?

, Davide

+3

Backward Chaining , , , . , , - ? , . , . , , .

. , . , drools . Drools

+2
source

All Articles