[rules-users] Question about getObjects() on workspace with defeasible belief system

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

[rules-users] Question about getObjects() on workspace with defeasible belief system

Borris
I am trying the Defeasible belief system (it ties in pretty well with
some of how I want
to structure my project).

After fixing many typos, the rule behaviour seems to be what it should
for a defeasible
rule being correctly defeated (my clash spotter doesn't fire, which it
does if any
part of the defeasible chain is broken). Which is all jolly fun and good
and exciting.

But, my question.

I have a simple workspace dump based upon getting all objects (via
ksession.getObjects() )
and then doing my own tidy presentation. This still shows the defeated
fact as present.

So I know there is still record somewhere of the defeated fact, because
if the workspace
changed such that my defeater was retracted, then it needs to make the
fact visible again.

But I wasn't expecting to see it via getObjects(). Is that the intended
behaviour? If so,
is there a way to enquire whether a fact is in the "defeated state" or
not that I could
add to my tidy workspace dumper?

Thanks!

Borris

_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users
Reply | Threaded
Open this post in threaded view
|

Re: [rules-users] Question about getObjects() on workspace with defeasible belief system

Davide Sottara
Thanks for the feedback! The defeasible subsystem is still very
experimental,
and it's good to know that people are using it.

This said, as for your question. It is possible, but takes a little
effort since we
don't have a public API for that. You can do:

// get the handle for the object
InternalFactHandle handle = (InternalFactHandle) session.getFactHandle(
myObject );
// lookup the belief set, where all justifiers (pos and neg) are stored
and linked
DefeasibleBeliefSet dbs = (DefeasibleBeliefSet)
posHandle.getEqualityKey().getBeliefSet();
DefeasibilityStatus status = dbs.getStatus();

status now has 4 values:
DEFINITELY (strict), DEFEASIBLY, DEFEATEDLY (defeated), UNDECIDEDLY
(unresolved conflict)

Notice that "negatively" asserted facts end up in a "negative" entry
point, so you have to look them
up explicitly:
InternalFactHandle negHandle = (InternalFactHandle)
session.getEntryPoint( "neg" ).getFactHandle( myNegatedObject );

Again, we are currently working on this specific system even now, so
things may change in 6.2,
but this should work in 6.1.
Please report any issue that you might find.
Best
Davide

On 07/21/2014 08:57 PM, Borris wrote:

> I am trying the Defeasible belief system (it ties in pretty well with
> some of how I want
> to structure my project).
>
> After fixing many typos, the rule behaviour seems to be what it should
> for a defeasible
> rule being correctly defeated (my clash spotter doesn't fire, which it
> does if any
> part of the defeasible chain is broken). Which is all jolly fun and good
> and exciting.
>
> But, my question.
>
> I have a simple workspace dump based upon getting all objects (via
> ksession.getObjects() )
> and then doing my own tidy presentation. This still shows the defeated
> fact as present.
>
> So I know there is still record somewhere of the defeated fact, because
> if the workspace
> changed such that my defeater was retracted, then it needs to make the
> fact visible again.
>
> But I wasn't expecting to see it via getObjects(). Is that the intended
> behaviour? If so,
> is there a way to enquire whether a fact is in the "defeated state" or
> not that I could
> add to my tidy workspace dumper?
>
> Thanks!
>
> Borris
>
> _______________________________________________
> rules-users mailing list
> [hidden email]
> https://lists.jboss.org/mailman/listinfo/rules-users
>

_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users
Reply | Threaded
Open this post in threaded view
|

Re: [rules-users] Question about getObjects() on workspace with defeasible belief system

Borris
And thanks for the response!

A quick question on your example code before I try it:

On 21/07/2014 21:24, Davide Sottara wrote:
> Notice that "negatively" asserted facts end up in a "negative" entry
> point, so you have to look them
> up explicitly:
> InternalFactHandle negHandle = (InternalFactHandle)
> session.getEntryPoint( "neg" ).getFactHandle( myNegatedObject );
>
Is myNegatedObject just the set that getObjects() returned or is there
another enumeration method I should use? Ie do I Iook for a neg entry
point object for each object I get back from ksession.getObjects() or do
I need to acquire a collection from another place (as well) if I want to
enumerate everything in the workspace for my dumpWorkspace() pretty printer?

Thanks

Borris

_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users
Reply | Threaded
Open this post in threaded view
|

Re: [rules-users] Question about getObjects() on workspace with defeasible belief system

Davide Sottara
getObjects() will return all the objects. However, an object's HANDLE
will be in the default x-or in the "neg" entry-point, depending on whether
the object was asserted in the positive or negative form, and depending
on the conflict resolution by defeasibility.
In my snippet, "myNegatedObject" was supposedly an object in "negative"
form.

If you are trying to build a pretty printer, you may just want to iterate
the fact handles directly. Methods such as
session.getEntryPoints()
session.getEntryPoint( entryPointName ).getFactHandles();
will help

On 07/22/2014 12:41 AM, Borris wrote:

> And thanks for the response!
>
> A quick question on your example code before I try it:
>
> On 21/07/2014 21:24, Davide Sottara wrote:
>> Notice that "negatively" asserted facts end up in a "negative" entry
>> point, so you have to look them
>> up explicitly:
>> InternalFactHandle negHandle = (InternalFactHandle)
>> session.getEntryPoint( "neg" ).getFactHandle( myNegatedObject );
>>
> Is myNegatedObject just the set that getObjects() returned or is there
> another enumeration method I should use? Ie do I Iook for a neg entry
> point object for each object I get back from ksession.getObjects() or do
> I need to acquire a collection from another place (as well) if I want to
> enumerate everything in the workspace for my dumpWorkspace() pretty printer?
>
> Thanks
>
> Borris
>
> _______________________________________________
> rules-users mailing list
> [hidden email]
> https://lists.jboss.org/mailman/listinfo/rules-users
>

_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users
Reply | Threaded
Open this post in threaded view
|

Re: [rules-users] Question about getObjects() on workspace with defeasible belief system

Mark Proctor
In reply to this post by Borris
Easiest thing is to look at the code:
https://github.com/droolsjbpm/drools/blob/master/drools-core/src/main/java/org/drools/core/beliefsystem/defeasible/DefeasibleBeliefSet.java
https://github.com/droolsjbpm/drools/blob/master/drools-core/src/main/java/org/drools/core/beliefsystem/defeasible/DefeasibleBeliefSystem.java

And tests:
https://github.com/droolsjbpm/drools/blob/master/drools-compiler/src/test/java/org/drools/compiler/beliefsystem/defeasible/DefeasibilityTest.java

As Davide said, this is highly experimental. It’s likely we won’t use a ‘neg’ entry point in the future to handle negated facts, but instead provided a meta property.

Mark

On 21 Jul 2014, at 23:41, Borris <[hidden email]> wrote:

> And thanks for the response!
>
> A quick question on your example code before I try it:
>
> On 21/07/2014 21:24, Davide Sottara wrote:
>> Notice that "negatively" asserted facts end up in a "negative" entry
>> point, so you have to look them
>> up explicitly:
>> InternalFactHandle negHandle = (InternalFactHandle)
>> session.getEntryPoint( "neg" ).getFactHandle( myNegatedObject );
>>
> Is myNegatedObject just the set that getObjects() returned or is there
> another enumeration method I should use? Ie do I Iook for a neg entry
> point object for each object I get back from ksession.getObjects() or do
> I need to acquire a collection from another place (as well) if I want to
> enumerate everything in the workspace for my dumpWorkspace() pretty printer?
>
> Thanks
>
> Borris
>
> _______________________________________________
> rules-users mailing list
> [hidden email]
> https://lists.jboss.org/mailman/listinfo/rules-users


_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users