FrameSet Management
John Zinky
jzinky at bbn.com
Mon Jun 23 16:39:33 EDT 2008
Alexander,
Please sign up to be a cougaar-developer. This will allow you to send
messages to cougaar-developer and not have them thrown away as spam.
It was a miracle that this message was found and not lost in the spam
filter.
Also I would be interested in knowing which inference engine you are
using and wether you are willing to share the code, if the engine is
open-source. (We use Jess, which is not open source, so we can't
release the rule engine part of FrameSets.)
In general, you should have only one plugin run the
FrameSet.processQueue method and the logical place is the same plugin
that created the FrameSet. FrameSetLoaderPlugin is the basic example
for creating a FrameSet instance and setting up the subscription to
have processQueue called in its execute().
Other plugins can use FrameSet.removeFrame(..) and
FrameSet.makeFrame(..) in their execute blocks and then
FrameSetLoaderPlugin will actually publish DatatFrames to the
blackboard and update the FrameSet inferences.
If another plugin wants to run code and guarantee that the
processQueue is not running, it should use FrameSet method:
/**
* Runs a body of code using a lock that prevents a
* simultaneous invocation of {@link #processQueue}.
* The runnable is executed in the caller's thread.
*/
public void runInTransaction(Runnable r);
We found that it works better to run the rule engine and FrameSet in
phases, letting each run to completion before starting the other.
1) So for our plugin that runs the rule engine, we have the following
steps in execute()
a) insert/delete ShadowFacts into the rule engine for each DataFrame
that was added/deleted for this run of execute()
b) run the rule engine
i) queue up all DataFrame add/deletes specified by the rule engine
ii) let all the rules fire until there are no more matches for
this batch of ShadowFacts
c) insert/delete queued DataFrames into FrameSet.
This is done in a FrameSet.runInTransaction()
2) After the RuleEnginPlugin runs, the FrameSetLoaderPlugin processes
its queue and puts the RuleEngines DataFrames on the blackboard.
3) OtherPlugins process the blackboard changes created by the
RuleEngine and add/delete their own DataFrames to the FrameSet.
4) The FrameSetLoaderPlugin processes its queue, now with the
OtherPlugins' DataFrames.
and the cycle repeats.
Hope this helps
zinky
> From: "Alexander Claus" <styjdt at claus4joy.de>
> Date: June 2, 2008 3:43:56 AM EDT
> To: <cougaar-developers at cougaar.org>
> Subject: FrameSet Management
>
>
> Hello,
>
> I'm working with the FrameSet stuff of Cougaar. The frames are used
> as facts
> in a rule engine.
> I have 2 agents, each agent has its own rule engine and some other
> plugins.
>
> There is a plugin, which creates the DataFrames via
> FrameSet.makeFrame(..).
> One plugin, which consumes the DataFrames from the blackboard and
> put them
> into the rule engine. And there is a plugin which "cleans" from time
> to time
> the blackboard and the rule engine's knowledge base. This means,
> that the
> DataFrames are retracted from the rule engine and removed from the
> FrameSet
> via FrameSet.removeFrame(..).
>
> I found that after makeFrame(..) one has to call
> FrameSet.processQueue() to
> publish the events on the blackboard and the same after
> removeFrame(..) to
> remove them from the blackboard.
> But: I got some Exceptions while calling processQueue() ("... called
> outside transaction ..."), so I refactored the system in such a way,
> that processQueue() is now always called from the same plugin which
> created the frameset. Now there are no Exceptions...
> Here are my questions:
>
> 1. Is it true, that this is the only way of doing this? Must
> processQueue() always be called from the plugin which created the
> frameset?
>
> 2. What is the purpose of the FrameSetLoaderPlugin? Should one
> extend this plugin to a "FrameSetManagerPlugin" which is responsible
> for all frameset-related operations?
>
> Thanks in advance
> Alexander Claus
More information about the Cougaar-developers
mailing list