I wrote an agent that was triggering self regulating plans based on a belief (ie. @Trigger(factchangeds="belief")). then I tried using this same belief in a goal condition (@GoalCreationCondition). When I ran the agent with the Goal implemented, the plans associated with triggers senstive to this belief would not execute. I created a test case Agent to observe this behaviour.
I have implemented a belief called number which triggers the numberChangedPlan plan with the factchangeds propertyListener in the trigger.
I have also created a dummy goal GenericGoal which uses the belief number in the @GoalCreationCondition. If you run the agent with the goal present in the agent description class, then the numberChangedPlan will not be triggered. with the Goal commented out, numberChangedPlan is triggered.
Is this expected behaviour?
publicclassSelectiveBeliefChangeBDI{@Beliefprotecteddoublenumber;@AgentCreatedpublicvoidinit(IInternalAccessagent){number=9.2;}@AgentBodypublicvoidbody(IInternalAccessagent){number=9.4;number=9.5;}@Plan(trigger=@Trigger(factchangeds="number"))publicvoidnumberChangedPlan(ChangeEventevent){ChangeInfo<Double>change=(ChangeInfo<Double>)event.getValue();System.out.println(agentName+"number has changed to: "+change.getValue()+" from "+change.getOldValue());}@GoalpublicclassGenericGoal{protecteddoublenum1;protecteddoubleresult;@GoalCreationConditionpublicbooleanpreCheckNumber(){returnnumber>20.0;}publicGenericGoal(){this.num1=number;}}}
EDIT: I removed unrelated code from the example
Last edit: sdr3 2017-03-08
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The @GoalCreationCondition is only supported on constructors and static methods.
Unfortunately, instead of reporting an error, the init of the agent silently fails, such that
the plans are not executed. I will try to include better error reporting in the next release
and also provide more documentation on the @GoalCreationCondition annotation.
Meanwhile, the following code should do what you want:
Note the static modifier on the goal class and the preCheckNumber method.
Being static also requires injecting the outer agent object as a parameter, which
is luckily assigned automatically by Jadex.
Cheers,
Alex
Last edit: Alexander Pokahr 2017-03-15
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello Alex,
Thankyou for the quick response. :) I assume that this will also apply for other Goal conditional annotations, such as @GoalRecur, @GoalMaintainCondition, etc. ?
I will test and post back :)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Alex,
can you please post the source code of your test, my implementation of your suggestion is resulting in the same issue. It looks eerily like you are passing something like an ExternalAccess object to the goal to monitor the belief set with.
for now I have made a work around by constructing extra redundant plans to trigger the goal in certain conditions, however in the future i want to utilize GoalRecur, GoalTarget, etc methods to control agent behaviour.
Kind Regards
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
it is already included in the latest nightly distributions.
You can find it, e.g., in:
- jadex-standard-3.0.69.zip in the file
- jadex-3.0.69/sources.zip and there in the folder
- sources/jadex-applications-bdiv3/src/main/java/jadex/bdiv3/testcases/semiautomatic as
- SelectiveBeliefChangeBDI.java
Regarding your previous question:
Only the creation condition method needs to be static (because there is no goal object, yet).
The other conditions are non-static and are executed seperately on each goal object (when there are multiple instances of the same goal).
Cheers,
Alex
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
I wrote an agent that was triggering self regulating plans based on a belief (ie.
@Trigger(factchangeds="belief")
). then I tried using this same belief in a goal condition (@GoalCreationCondition
). When I ran the agent with the Goal implemented, the plans associated with triggers senstive to this belief would not execute. I created a test case Agent to observe this behaviour.I have implemented a belief called
number
which triggers thenumberChangedPlan
plan with thefactchangeds
propertyListener in the trigger.I have also created a dummy goal
GenericGoal
which uses the beliefnumber
in the@GoalCreationCondition
. If you run the agent with the goal present in the agent description class, then thenumberChangedPlan
will not be triggered. with the Goal commented out,numberChangedPlan
is triggered.Is this expected behaviour?
EDIT: I removed unrelated code from the example
Last edit: sdr3 2017-03-08
Hi Steve,
I can confirm that I'm able to reproduce this behavior.
It looks odd and seems to be a bug. I will investigate further and come back to you.
Cheers,
Alex
Hi Steve,
I found the problem.
The @GoalCreationCondition is only supported on constructors and static methods.
Unfortunately, instead of reporting an error, the init of the agent silently fails, such that
the plans are not executed. I will try to include better error reporting in the next release
and also provide more documentation on the @GoalCreationCondition annotation.
Meanwhile, the following code should do what you want:
Note the static modifier on the goal class and the preCheckNumber method.
Being static also requires injecting the outer agent object as a parameter, which
is luckily assigned automatically by Jadex.
Cheers,
Alex
Last edit: Alexander Pokahr 2017-03-15
Hello Alex,
Thankyou for the quick response. :) I assume that this will also apply for other Goal conditional annotations, such as @GoalRecur, @GoalMaintainCondition, etc. ?
I will test and post back :)
Hi Alex,
can you please post the source code of your test, my implementation of your suggestion is resulting in the same issue. It looks eerily like you are passing something like an ExternalAccess object to the goal to monitor the belief set with.
for now I have made a work around by constructing extra redundant plans to trigger the goal in certain conditions, however in the future i want to utilize GoalRecur, GoalTarget, etc methods to control agent behaviour.
Kind Regards
Hi Steve,
it is already included in the latest nightly distributions.
You can find it, e.g., in:
- jadex-standard-3.0.69.zip in the file
- jadex-3.0.69/sources.zip and there in the folder
- sources/jadex-applications-bdiv3/src/main/java/jadex/bdiv3/testcases/semiautomatic as
- SelectiveBeliefChangeBDI.java
Regarding your previous question:
Only the creation condition method needs to be static (because there is no goal object, yet).
The other conditions are non-static and are executed seperately on each goal object (when there are multiple instances of the same goal).
Cheers,
Alex