GIS support for Jason

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

GIS support for Jason

Development-14
Hello,

is anywhere a GIS support for JasonAgents available? Like Repast for
example?  I am realy interessted in BDI Agtens implemented in Jade or
Jason using a Gis Environment (2D) for simulation aspects.

Best regards,
MArtin

------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
Jason-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jason-users
Reply | Threaded
Open this post in threaded view
|

Re: GIS support for Jason

Rafael H Bordini-2
Hi Martin,

Sorry for the delay in replying. I'm afraid there isn't direct GIS
support for Jason (that I know of), but since Repast is in Java, it
shouldn't be TOO difficult (*I guess*, and I hope :D) to use the Jason
interpreter within a Repast agent. The FAQ has something about how you
use the Jason interpreter as part of a normal Java system (without using
the Jason platform).

http://jason.sourceforge.net/faq/faq.html#SECTION00067000000000000000

HTH,

Rafael


Development wrote:

> Hello,
>
> is anywhere a GIS support for JasonAgents available? Like Repast for
> example?  I am realy interessted in BDI Agtens implemented in Jade or
> Jason using a Gis Environment (2D) for simulation aspects.
>
> Best regards,
> MArtin
>
> ------------------------------------------------------------------------------
> This SF.Net email is sponsored by the Verizon Developer Community
> Take advantage of Verizon's best-in-class app development support
> A streamlined, 14 day to market process makes app distribution fast and easy
> Join now and get one step closer to millions of Verizon customers
> http://p.sf.net/sfu/verizon-dev2dev 
> _______________________________________________
> Jason-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/jason-users

------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
Jason-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jason-users
Reply | Threaded
Open this post in threaded view
|

Re: GIS support for Jason

Development-14
Hi Rafael ,

thank you for answering! I am reading your  book "Programming ..." at
the moment . And One BIG question i have, during reading the chapter
about bulding up the agents beliefbase, is : Am I restcricted to  the
"methods"  you discribed  in chapter 3.1 pages  36,37?
Can i "only" build up the agents belief base per using constants,
variables and lists? Or is it possible to implement a beliefbase in java
per example a graph model? And yes i do know that i can describe a
graphmodel via a adjacenzmatrix and so also in agentspeak BUT when i am
trying to implement a BDI AGent who is able to move in space using gis
analysemethods it would be easier to use other data structers provided
by databasemanagment system or object programming paradigm  instead of
agentspeak!


Best regards,
Martin


Sorry for my  english ;-)
,

Rafael H Bordini schrieb:

> Hi Martin,
>
> Sorry for the delay in replying. I'm afraid there isn't direct GIS
> support for Jason (that I know of), but since Repast is in Java, it
> shouldn't be TOO difficult (*I guess*, and I hope :D) to use the Jason
> interpreter within a Repast agent. The FAQ has something about how you
> use the Jason interpreter as part of a normal Java system (without
> using the Jason platform).
>
> http://jason.sourceforge.net/faq/faq.html#SECTION00067000000000000000
>
> HTH,
>
> Rafael
>
>
> Development wrote:
>> Hello,
>>
>> is anywhere a GIS support for JasonAgents available? Like Repast for
>> example?  I am realy interessted in BDI Agtens implemented in Jade or
>> Jason using a Gis Environment (2D) for simulation aspects.
>>
>> Best regards,
>> MArtin
>>
>> ------------------------------------------------------------------------------
>>
>> This SF.Net email is sponsored by the Verizon Developer Community
>> Take advantage of Verizon's best-in-class app development support
>> A streamlined, 14 day to market process makes app distribution fast
>> and easy
>> Join now and get one step closer to millions of Verizon customers
>> http://p.sf.net/sfu/verizon-dev2dev 
>> _______________________________________________
>> Jason-users mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/jason-users
>


------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
Jason-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jason-users
Reply | Threaded
Open this post in threaded view
|

Re: GIS support for Jason

Rafael H Bordini-2
Hi Martin,

That's a question we love answering :) because, like most other things
in Jason, also the Belief Base can be customised. There is actually a
demo (see de "demos" folder in the distribution, then the folder called
"persistent belief base" or something like that) on how to use JDBC to
access a database for (all or part) of the belief base.

Great to hear you're reading the Jason book; since you have a copy of
the book, besides the demo you could also look at Section 7.4 if you are
going to create a Belief Base customisation to have direct (and
transparent) access to a GIS. BTW, this should be very useful to many
other users; if you have good results on this, do let us know.

All best wishes,

Rafael


Development wrote:

> Hi Rafael ,
>
> thank you for answering! I am reading your  book "Programming ..." at
> the moment . And One BIG question i have, during reading the chapter
> about bulding up the agents beliefbase, is : Am I restcricted to  the
> "methods"  you discribed  in chapter 3.1 pages  36,37?
> Can i "only" build up the agents belief base per using constants,
> variables and lists? Or is it possible to implement a beliefbase in java
> per example a graph model? And yes i do know that i can describe a
> graphmodel via a adjacenzmatrix and so also in agentspeak BUT when i am
> trying to implement a BDI AGent who is able to move in space using gis
> analysemethods it would be easier to use other data structers provided
> by databasemanagment system or object programming paradigm  instead of
> agentspeak!
>
>
> Best regards,
> Martin
>
>
> Sorry for my  english ;-)
> ,
>
> Rafael H Bordini schrieb:
>> Hi Martin,
>>
>> Sorry for the delay in replying. I'm afraid there isn't direct GIS
>> support for Jason (that I know of), but since Repast is in Java, it
>> shouldn't be TOO difficult (*I guess*, and I hope :D) to use the Jason
>> interpreter within a Repast agent. The FAQ has something about how you
>> use the Jason interpreter as part of a normal Java system (without
>> using the Jason platform).
>>
>> http://jason.sourceforge.net/faq/faq.html#SECTION00067000000000000000
>>
>> HTH,
>>
>> Rafael
>>
>>
>> Development wrote:
>>> Hello,
>>>
>>> is anywhere a GIS support for JasonAgents available? Like Repast for
>>> example?  I am realy interessted in BDI Agtens implemented in Jade or
>>> Jason using a Gis Environment (2D) for simulation aspects.
>>>
>>> Best regards,
>>> MArtin
>>>
>>> ------------------------------------------------------------------------------
>>>
>>> This SF.Net email is sponsored by the Verizon Developer Community
>>> Take advantage of Verizon's best-in-class app development support
>>> A streamlined, 14 day to market process makes app distribution fast
>>> and easy
>>> Join now and get one step closer to millions of Verizon customers
>>> http://p.sf.net/sfu/verizon-dev2dev 
>>> _______________________________________________
>>> Jason-users mailing list
>>> [hidden email]
>>> https://lists.sourceforge.net/lists/listinfo/jason-users
>>
>

------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
Jason-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jason-users
Reply | Threaded
Open this post in threaded view
|

Environment actions every step

Iain Wallace-2
I've a problem I can't seem to work out. I have a gridworld environment that can be dynamic - I need to call a function each step and possibly update the world based on this. However I can't work out where I should call this function. Most of the time it seems that it works, but if no agents do anything for a cycle then the environment also does nothing...

Suggestions would be welcome, I've been going through the code and can't seem to work out a sensible way to do this!

Cheers,

Iain
--
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.


------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
Jason-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jason-users
Reply | Threaded
Open this post in threaded view
|

Re: Environment actions every step

Jomi Hubner
Hi Iani,

Are you using TimeSteppedEnvironment? (as in examples/game-of-life and  
demo/sync-environment)
If so, you likely have defined a timeout for each step (the default is  
"infinity"). A step will finish when every agent has act or by timeout  
(if defined). When the step is finished, the method stepFinished is  
called, the new step is prepared, and then the method stepStarted is  
called. To run some procedures in the end (or begin) of a cycle, you  
simply override these methods in your environment class.

HTH,

Jomi




On 11/01/2010, at 11:48, Iain Wallace wrote:

> I've a problem I can't seem to work out. I have a gridworld  
> environment that can be dynamic - I need to call a function each  
> step and possibly update the world based on this. However I can't  
> work out where I should call this function. Most of the time it  
> seems that it works, but if no agents do anything for a cycle then  
> the environment also does nothing...
>
> Suggestions would be welcome, I've been going through the code and  
> can't seem to work out a sensible way to do this!
>
> Cheers,
>
> Iain
> --
> The University of Edinburgh is a charitable body, registered in
> Scotland, with registration number SC005336.
>
>
> ------------------------------------------------------------------------------
> This SF.Net email is sponsored by the Verizon Developer Community
> Take advantage of Verizon's best-in-class app development support
> A streamlined, 14 day to market process makes app distribution fast  
> and easy
> Join now and get one step closer to millions of Verizon customers
> http://p.sf.net/sfu/verizon-dev2dev
> _______________________________________________
> Jason-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/jason-users

--
Jomi Fred Hubner
Department of Automation and Systems Engineering
Federal University of Santa Catarina
PO Box 476, Florianópolis, SC
88040-900 Brasil
http://www.das.ufsc.br/~jomi


------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
Jason-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jason-users
Reply | Threaded
Open this post in threaded view
|

Re: Environment actions every step

Iain Wallace-2
Hi,

Thanks for the replies, they've been very helpful. I've gone with a solution like Rafael proposes below, which works well for my need except for one issue.

When the MAS is run in debug mode the "go something" continues to be called. This seems to be because in debug mode the agents are synchronised by the centralised architecture, which sends signals to them when they are to execute one (or more) reasoning cycles.

I've been digging through the code all afternoon, and can't figure out a good way to ensure my environment also pauses when the agents are stopped in the debugger. As far as I can see the only way I might do this is implementing my own architecture (and even then I'm not entirely sure how to make that work). Is there a way round this problem?

I think i'd still have a similar issue if I'd gone with a stepped environment too (which I may yet).

I'm starting to think that the dynamic part of my environment (a ball, that can be kicked and roll around) would've been better implemented as a special case agent! I went about it this way as it seemed more natural to have some part of the environment that the agents can interact with.

Cheers,

Iain


On 11 Jan 2010, at 16:27, Rafael H Bordini wrote:

> Hi Iain,
> Jomi even had some code template for the 2nd solution I mentioned, in case it helps.
> Best,
> Rafael
>
>    @Override
>    public void init(String[] args) {
>        new Thread() {
>            public void run() {
>                while (isRunning()) {
>                    try { sleep(1000);  } catch (InterruptedException e) {  }
>                    System.out.println("do something");
>                }
>            };
>        }.start();
>
>


--
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.


------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
Jason-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jason-users
Reply | Threaded
Open this post in threaded view
|

Re: Environment actions every step

Jomi Hubner

On 11/01/2010, at 20:22, Iain Wallace wrote:

> Hi,
>
> Thanks for the replies, they've been very helpful. I've gone with a  
> solution like Rafael proposes below, which works well for my need  
> except for one issue.
>
> When the MAS is run in debug mode the "go something" continues to be  
> called. This seems to be because in debug mode the agents are  
> synchronised by the centralised architecture, which sends signals to  
> them when they are to execute one (or more) reasoning cycles.

yes, that's the case.

>
> I've been digging through the code all afternoon, and can't figure  
> out a good way to ensure my environment also pauses when the agents  
> are stopped in the debugger. As far as I can see the only way I  
> might do this is implementing my own architecture (and even then I'm  
> not entirely sure how to make that work). Is there a way round this  
> problem?

You are right, no simple solution. You should create a controller that  
signals also the environment (the debug mode is indeed a controller).  
Another "solution" is to not run your system in debug mode and use  
other strategies (e.g. logging) to find bugs.

>
> I think i'd still have a similar issue if I'd gone with a stepped  
> environment too (which I may yet).

exact.

best,

Jomi

>
> I'm starting to think that the dynamic part of my environment (a  
> ball, that can be kicked and roll around) would've been better  
> implemented as a special case agent! I went about it this way as it  
> seemed more natural to have some part of the environment that the  
> agents can interact with.
>
> Cheers,
>
> Iain
>
>
> On 11 Jan 2010, at 16:27, Rafael H Bordini wrote:
>
>> Hi Iain,
>> Jomi even had some code template for the 2nd solution I mentioned,  
>> in case it helps.
>> Best,
>> Rafael
>>
>>   @Override
>>   public void init(String[] args) {
>>       new Thread() {
>>           public void run() {
>>               while (isRunning()) {
>>                   try { sleep(1000);  } catch (InterruptedException  
>> e) {  }
>>                   System.out.println("do something");
>>               }
>>           };
>>       }.start();
>>
>>
>
>
> --
> The University of Edinburgh is a charitable body, registered in
> Scotland, with registration number SC005336.
>
>
> ------------------------------------------------------------------------------
> This SF.Net email is sponsored by the Verizon Developer Community
> Take advantage of Verizon's best-in-class app development support
> A streamlined, 14 day to market process makes app distribution fast  
> and easy
> Join now and get one step closer to millions of Verizon customers
> http://p.sf.net/sfu/verizon-dev2dev
> _______________________________________________
> Jason-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/jason-users

--
Jomi Fred Hubner
Department of Automation and Systems Engineering
Federal University of Santa Catarina
PO Box 476, Florianópolis, SC
88040-900 Brasil
http://www.das.ufsc.br/~jomi


------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
Jason-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jason-users
Reply | Threaded
Open this post in threaded view
|

Re: Environment actions every step

Rafael H Bordini-2
In reply to this post by Iain Wallace-2
Hi Iain,

Just to say that I agree with you that modelling the ball as part of the
environment is intuitively more appropriate, unless you want a
pro-active, autonomous ball that's not like a normal ball in sports. But
then again, sometimes you might not want to use the most intuitive
design, that's your choice as desinger!

Cheers,

Rafael


Iain Wallace wrote:

> Hi,
>
> Thanks for the replies, they've been very helpful. I've gone with a solution like Rafael proposes below, which works well for my need except for one issue.
>
> When the MAS is run in debug mode the "go something" continues to be called. This seems to be because in debug mode the agents are synchronised by the centralised architecture, which sends signals to them when they are to execute one (or more) reasoning cycles.
>
> I've been digging through the code all afternoon, and can't figure out a good way to ensure my environment also pauses when the agents are stopped in the debugger. As far as I can see the only way I might do this is implementing my own architecture (and even then I'm not entirely sure how to make that work). Is there a way round this problem?
>
> I think i'd still have a similar issue if I'd gone with a stepped environment too (which I may yet).
>
> I'm starting to think that the dynamic part of my environment (a ball, that can be kicked and roll around) would've been better implemented as a special case agent! I went about it this way as it seemed more natural to have some part of the environment that the agents can interact with.
>
> Cheers,
>
> Iain
>
>
> On 11 Jan 2010, at 16:27, Rafael H Bordini wrote:
>
>> Hi Iain,
>> Jomi even had some code template for the 2nd solution I mentioned, in case it helps.
>> Best,
>> Rafael
>>
>>    @Override
>>    public void init(String[] args) {
>>        new Thread() {
>>            public void run() {
>>                while (isRunning()) {
>>                    try { sleep(1000);  } catch (InterruptedException e) {  }
>>                    System.out.println("do something");
>>                }
>>            };
>>        }.start();
>>
>>
>
>

------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
Jason-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jason-users
Reply | Threaded
Open this post in threaded view
|

Re: Environment actions every step

Iain Wallace-2
In reply to this post by Jomi Hubner
OK,

I've come up with a way to solve my problem just in the environment, without requiring a custom controller.

It's a bit of a hack, and a little messy, but basically:

Only "do something" once all the agents are loaded and initialised properly. Then test if the agents are running in sync mode like so:

RunCentralisedMAS.getRunner().getAg(agentNames.get(0)).getUserAgArch().getTS().getSettings().isSync()

then keep a list of the current cycle for each agent. Each time the "do something" thread executes, check for each agent if the current cycle:

RunCentralisedMAS.getRunner().getAg(name).getUserAgArch().getCycleNumber();

is greater than the last stored version. If it is, update that value, and do the "do something".

If not running in sync mode, then "do something" as normal.

I've not posted all my code, as it's a bit messy due to other things in it - however if anyone would find it useful, then I can. This method works well, and means that my ball rolls only when at least one agent is executing when in debug mode, and in normal mode moves as normal.

Iain

On 12 Jan 2010, at 00:24, Jomi Hubner wrote:

>
> On 11/01/2010, at 20:22, Iain Wallace wrote:
>
>> Hi,
>>
>> Thanks for the replies, they've been very helpful. I've gone with a solution like Rafael proposes below, which works well for my need except for one issue.
>>
>> When the MAS is run in debug mode the "go something" continues to be called. This seems to be because in debug mode the agents are synchronised by the centralised architecture, which sends signals to them when they are to execute one (or more) reasoning cycles.
>
> yes, that's the case.
>
>>
>> I've been digging through the code all afternoon, and can't figure out a good way to ensure my environment also pauses when the agents are stopped in the debugger. As far as I can see the only way I might do this is implementing my own architecture (and even then I'm not entirely sure how to make that work). Is there a way round this problem?
>
> You are right, no simple solution. You should create a controller that signals also the environment (the debug mode is indeed a controller). Another "solution" is to not run your system in debug mode and use other strategies (e.g. logging) to find bugs.
>
>>
>> I think i'd still have a similar issue if I'd gone with a stepped environment too (which I may yet).
>
> exact.
>
> best,
>
> Jomi
>
>>
>> I'm starting to think that the dynamic part of my environment (a ball, that can be kicked and roll around) would've been better implemented as a special case agent! I went about it this way as it seemed more natural to have some part of the environment that the agents can interact with.
>>
>> Cheers,
>>
>> Iain
>>
>>
>> On 11 Jan 2010, at 16:27, Rafael H Bordini wrote:
>>
>>> Hi Iain,
>>> Jomi even had some code template for the 2nd solution I mentioned, in case it helps.
>>> Best,
>>> Rafael
>>>
>>>  @Override
>>>  public void init(String[] args) {
>>>      new Thread() {
>>>          public void run() {
>>>              while (isRunning()) {
>>>                  try { sleep(1000);  } catch (InterruptedException e) {  }
>>>                  System.out.println("do something");
>>>              }
>>>          };
>>>      }.start();
>>>
>>>
>>
>>
>> --
>> The University of Edinburgh is a charitable body, registered in
>> Scotland, with registration number SC005336.
>>
>>
>> ------------------------------------------------------------------------------
>> This SF.Net email is sponsored by the Verizon Developer Community
>> Take advantage of Verizon's best-in-class app development support
>> A streamlined, 14 day to market process makes app distribution fast and easy
>> Join now and get one step closer to millions of Verizon customers
>> http://p.sf.net/sfu/verizon-dev2dev
>> _______________________________________________
>> Jason-users mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/jason-users
>
> --
> Jomi Fred Hubner
> Department of Automation and Systems Engineering
> Federal University of Santa Catarina
> PO Box 476, Florianópolis, SC
> 88040-900 Brasil
> http://www.das.ufsc.br/~jomi
>
>


--
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.


------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
Jason-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jason-users
Reply | Threaded
Open this post in threaded view
|

Re: Environment actions every step

Rafael H Bordini-2
Hi Iain,

It is a bit of a hack in that it only works in Centralised mode, but
it's a really cool hack! :) Very kind of you to offer the code, others
might well need it. Perhaps we should consider eventually introducing
some option for this in the Environment class.

Cheers,

Rafael


Iain Wallace wrote:

> OK,
>
> I've come up with a way to solve my problem just in the environment, without requiring a custom controller.
>
> It's a bit of a hack, and a little messy, but basically:
>
> Only "do something" once all the agents are loaded and initialised properly. Then test if the agents are running in sync mode like so:
>
> RunCentralisedMAS.getRunner().getAg(agentNames.get(0)).getUserAgArch().getTS().getSettings().isSync()
>
> then keep a list of the current cycle for each agent. Each time the "do something" thread executes, check for each agent if the current cycle:
>
> RunCentralisedMAS.getRunner().getAg(name).getUserAgArch().getCycleNumber();
>
> is greater than the last stored version. If it is, update that value, and do the "do something".
>
> If not running in sync mode, then "do something" as normal.
>
> I've not posted all my code, as it's a bit messy due to other things in it - however if anyone would find it useful, then I can. This method works well, and means that my ball rolls only when at least one agent is executing when in debug mode, and in normal mode moves as normal.
>
> Iain
>
> On 12 Jan 2010, at 00:24, Jomi Hubner wrote:
>
>  
>> On 11/01/2010, at 20:22, Iain Wallace wrote:
>>
>>    
>>> Hi,
>>>
>>> Thanks for the replies, they've been very helpful. I've gone with a solution like Rafael proposes below, which works well for my need except for one issue.
>>>
>>> When the MAS is run in debug mode the "go something" continues to be called. This seems to be because in debug mode the agents are synchronised by the centralised architecture, which sends signals to them when they are to execute one (or more) reasoning cycles.
>>>      
>> yes, that's the case.
>>
>>    
>>> I've been digging through the code all afternoon, and can't figure out a good way to ensure my environment also pauses when the agents are stopped in the debugger. As far as I can see the only way I might do this is implementing my own architecture (and even then I'm not entirely sure how to make that work). Is there a way round this problem?
>>>      
>> You are right, no simple solution. You should create a controller that signals also the environment (the debug mode is indeed a controller). Another "solution" is to not run your system in debug mode and use other strategies (e.g. logging) to find bugs.
>>
>>    
>>> I think i'd still have a similar issue if I'd gone with a stepped environment too (which I may yet).
>>>      
>> exact.
>>
>> best,
>>
>> Jomi
>>
>>    
>>> I'm starting to think that the dynamic part of my environment (a ball, that can be kicked and roll around) would've been better implemented as a special case agent! I went about it this way as it seemed more natural to have some part of the environment that the agents can interact with.
>>>
>>> Cheers,
>>>
>>> Iain
>>>
>>>
>>> On 11 Jan 2010, at 16:27, Rafael H Bordini wrote:
>>>
>>>      
>>>> Hi Iain,
>>>> Jomi even had some code template for the 2nd solution I mentioned, in case it helps.
>>>> Best,
>>>> Rafael
>>>>
>>>>  @Override
>>>>  public void init(String[] args) {
>>>>      new Thread() {
>>>>          public void run() {
>>>>              while (isRunning()) {
>>>>                  try { sleep(1000);  } catch (InterruptedException e) {  }
>>>>                  System.out.println("do something");
>>>>              }
>>>>          };
>>>>      }.start();
>>>>
>>>>
>>>>        
>>> --
>>> The University of Edinburgh is a charitable body, registered in
>>> Scotland, with registration number SC005336.
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> This SF.Net email is sponsored by the Verizon Developer Community
>>> Take advantage of Verizon's best-in-class app development support
>>> A streamlined, 14 day to market process makes app distribution fast and easy
>>> Join now and get one step closer to millions of Verizon customers
>>> http://p.sf.net/sfu/verizon-dev2dev
>>> _______________________________________________
>>> Jason-users mailing list
>>> [hidden email]
>>> https://lists.sourceforge.net/lists/listinfo/jason-users
>>>      
>> --
>> Jomi Fred Hubner
>> Department of Automation and Systems Engineering
>> Federal University of Santa Catarina
>> PO Box 476, Florianópolis, SC
>> 88040-900 Brasil
>> http://www.das.ufsc.br/~jomi
>>
>>
>>    
>
>
>  


------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
Jason-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jason-users
Reply | Threaded
Open this post in threaded view
|

Re: Environment actions every step

Iain Wallace-2
In reply to this post by Iain Wallace-2
Right, I've tried to clean up the code a bit for an example here. I've decided to include the whole init() function for my environment, as it makes things easier to explain:

 public void init(String[] args) {
       
        try {
                /*** First of all we use the FAQ code to get the agent names  
                *** (I need this for other reasons anyway)
                **/
                jason.mas2j.parser.mas2j parser =
                    new jason.mas2j.parser.mas2j(new FileInputStream(args[0]));
                MAS2JProject project = parser.mas();
         
                agentNames = new ArrayList<String>();
                for (AgentParameters ap : project.getAgents()) {
                   String agName = ap.name;
                   for (int cAg = 0; cAg < ap.qty; cAg++) {
                      String numberedAg = agName;
                      if (ap.qty > 1) {
                         numberedAg += (cAg + 1);
                      }
                   agentNames.add(numberedAg);
                   }
                }

                initWorld();
        } catch (Exception e) {
            logger.log(Level.SEVERE, "ERROR initialising the environment!");
            e.printStackTrace();
        }
       
        /** Now we initialise an array to keep track of agent cycles
        **/
        agCycles = new Integer[agentNames.size()];
        for (int i = 0;i < agentNames.size();i++) {
        agCycles[i] = 0;
        }
       
        /** Now the thread to carry out the periodic environment updates
        **/
    new Thread() {
            public void run() {
                while (isRunning()) {
                    try {
                    sleep(sleepTime);  
                    }
                    catch (InterruptedException e) {  }
   
                /**if we're running in sync mode (debugging) then only roll the ball if at least one agent is executing.
                 *** need to check all agents are init'd, so check the last.
                *** bit of a hack, as I'm just checking for null pointers to the last agent.
                **/

                if ((RunCentralisedMAS.getRunner().getAg(agentNames.get(agentNames.size()-1)) != null)
                        && (RunCentralisedMAS.getRunner().getAg(agentNames.get(agentNames.size()-1)).getUserAgArch() != null)
                        && RunCentralisedMAS.getRunner().getAg(agentNames.get(0)).getUserAgArch().getTS().getSettings().isSync()) {
                                               
                                                //Now if at least one agent is on a new cycle compared to last time, update the ball.
                                                for (String name : agentNames) {
                                                        int curCycle;
                                                       
                                                        curCycle = RunCentralisedMAS.getRunner().getAg(name).getUserAgArch().getCycleNumber();
                                                        if (curCycle > agCycles[agentNames.indexOf(name)] ) {
                                                                agCycles[agentNames.indexOf(name)] = curCycle;
                                                                model.rollBall();
                                                                break;
                                                        }
                                                }
                                                               
                                        } else {
                                                //this is the no-debug case
                                                "do something"
                                        }
                  }
            };
    }.start();

    }

The worst hack there is checking if the pointers to the last agent are null or not, to check if everything's loaded yet. There's probably a better way, but it eludes me at the moment!

Iain



On 13 Jan 2010, at 17:23, Rafael H Bordini wrote:

> Hi Iain,
>
> It is a bit of a hack in that it only works in Centralised mode, but it's a really cool hack! :) Very kind of you to offer the code, others might well need it. Perhaps we should consider eventually introducing some option for this in the Environment class
>
> Cheers,
>
> Rafael
>
>
> Iain Wallace wrote:
>> OK,
>>
>> I've come up with a way to solve my problem just in the environment, without requiring a custom controller.
>>
>> It's a bit of a hack, and a little messy, but basically:
>>
>> Only "do something" once all the agents are loaded and initialised properly. Then test if the agents are running in sync mode like so:
>>
>> RunCentralisedMAS.getRunner().getAg(agentNames.get(0)).getUserAgArch().getTS().getSettings().isSync()
>>
>> then keep a list of the current cycle for each agent. Each time the "do something" thread executes, check for each agent if the current cycle:
>>
>> RunCentralisedMAS.getRunner().getAg(name).getUserAgArch().getCycleNumber();
>>
>> is greater than the last stored version. If it is, update that value, and do the "do something".
>>
>> If not running in sync mode, then "do something" as normal.
>>
>> I've not posted all my code, as it's a bit messy due to other things in it - however if anyone would find it useful, then I can. This method works well, and means that my ball rolls only when at least one agent is executing when in debug mode, and in normal mode moves as normal.
>>
>> Iain
>>
>> On 12 Jan 2010, at 00:24, Jomi Hubner wrote:


--
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.


------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
Jason-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jason-users
Reply | Threaded
Open this post in threaded view
|

Higher order variables

Iain Wallace-2
In reply to this post by Rafael H Bordini-2
Another day, more obscure Jason questions!

I'm trying to make a set of plans apply in as many situations as possible, so ideally want to use higher order variables to match events. Only it doesn't seem to work properly.

Consider the example code below:

belief(a,b).

!test.

+!test : true
<- +b.

+P : belief(a,P)
<- .println("matched belief ").
+P : true
<- .println("didn't match").

I would expect this to work as follows:

belief(a,b). is added to the belief base, so "didn't match" is printed.
+b is added, so "matched belief " is printed.

However, this isn't the case. when "b" is added, for some reason it doesn't match the first rule. Is this a bug, or am I doing something wrong?

On a related note, consider the following code:

+!test : .relevant_plans({+plan(A)},LP) & .length(LP,L) & (L > 0)
<- .println("have plan!").

This should check if the agent has a plan to handle the event "+plan(A)". And it works as you'd expect. Unless the agent also has a plan with a higher order variable trigger, like:

+P : true
<- .println("didn't match").

This causes a null pointer error:
[InternalActionLiteral] Error in internal action '.relevant_plans({ +plan(A) },LP)' (test.asl:9): null
java.lang.NullPointerException
        at jason.asSyntax.Structure.setTerm(Structure.java:221)
        at jason.asSyntax.Structure.makeVarsAnnon(Structure.java:285)
        at jason.asSyntax.Structure.makeVarsAnnon(Structure.java:289)
        at jason.asSyntax.Structure.makeVarsAnnon(Structure.java:275)
        at jason.stdlib.relevant_plans.execute(relevant_plans.java:101)
        at jason.asSyntax.InternalActionLiteral.logicalConsequence(InternalActionLiteral.java:84)
        at jason.asSyntax.LogExpr$1.<init>(LogExpr.java:95)
        at jason.asSyntax.LogExpr.logicalConsequence(LogExpr.java:94)
        at jason.asSemantics.TransitionSystem.applyFindOp(TransitionSystem.java:322)
        at jason.asSemantics.TransitionSystem.applySemanticRule(TransitionSystem.java:130)
        at jason.asSemantics.TransitionSystem.reasoningCycle(TransitionSystem.java:967)
        at jason.infra.centralised.CentralisedAgArch.run(CentralisedAgArch.java:197)
        at java.lang.Thread.run(Thread.java:637)

Again is this a bug, or am I doing something wrong?

Thanks,

Iain
--
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.


------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
_______________________________________________
Jason-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jason-users
Reply | Threaded
Open this post in threaded view
|

Re: Higher order variables

Rafael H Bordini-2
Hi Iain,

Thanks for the excellent questions. The first one can be done easily
(see below) but the second is clearly a bug in Jason. I'm afraid only
Jomi can fix that kind of bug and he won't be reading email until next
week. I'll try to help you with the first question. I hope you can wait
for a fix of the 2nd issue.

When you use, say, "+b" in the body of a plan, that generates an event
of the form +b[source(self)]. When you use just a higher order variable
with an event annotation, it unifies the whole thing i.e. the predicate
AND the annotations. So you have two alternatives to do what you want.

Alternative 1:

+B : B =.. [P,Ts,As] & belief(a,P) <- .print("matched").

Alternative 2:

+B[As] : belief(a,B) <- .print("matched").

If you're not familiar with the =.. operator, I think it's described in
the book, if not, have a look at the similar Prolog operator except in
Jason the annotations are the 3rd component of the deconstructed literal.

Cheers,

Rafael


Iain Wallace wrote:

> Another day, more obscure Jason questions!
>
> I'm trying to make a set of plans apply in as many situations as possible, so ideally want to use higher order variables to match events. Only it doesn't seem to work properly.
>
> Consider the example code below:
>
> belief(a,b).
>
> !test.
>
> +!test : true
> <- +b.
>
> +P : belief(a,P)
> <- .println("matched belief ").
> +P : true
> <- .println("didn't match").
>
> I would expect this to work as follows:
>
> belief(a,b). is added to the belief base, so "didn't match" is printed.
> +b is added, so "matched belief " is printed.
>
> However, this isn't the case. when "b" is added, for some reason it doesn't match the first rule. Is this a bug, or am I doing something wrong?
>
> On a related note, consider the following code:
>
> +!test : .relevant_plans({+plan(A)},LP) & .length(LP,L) & (L > 0)
> <- .println("have plan!").
>
> This should check if the agent has a plan to handle the event "+plan(A)". And it works as you'd expect. Unless the agent also has a plan with a higher order variable trigger, like:
>
> +P : true
> <- .println("didn't match").
>
> This causes a null pointer error:
> [InternalActionLiteral] Error in internal action '.relevant_plans({ +plan(A) },LP)' (test.asl:9): null
> java.lang.NullPointerException
> at jason.asSyntax.Structure.setTerm(Structure.java:221)
> at jason.asSyntax.Structure.makeVarsAnnon(Structure.java:285)
> at jason.asSyntax.Structure.makeVarsAnnon(Structure.java:289)
> at jason.asSyntax.Structure.makeVarsAnnon(Structure.java:275)
> at jason.stdlib.relevant_plans.execute(relevant_plans.java:101)
> at jason.asSyntax.InternalActionLiteral.logicalConsequence(InternalActionLiteral.java:84)
> at jason.asSyntax.LogExpr$1.<init>(LogExpr.java:95)
> at jason.asSyntax.LogExpr.logicalConsequence(LogExpr.java:94)
> at jason.asSemantics.TransitionSystem.applyFindOp(TransitionSystem.java:322)
> at jason.asSemantics.TransitionSystem.applySemanticRule(TransitionSystem.java:130)
> at jason.asSemantics.TransitionSystem.reasoningCycle(TransitionSystem.java:967)
> at jason.infra.centralised.CentralisedAgArch.run(CentralisedAgArch.java:197)
> at java.lang.Thread.run(Thread.java:637)
>
> Again is this a bug, or am I doing something wrong?
>
> Thanks,
>
> Iain

------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
_______________________________________________
Jason-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jason-users
Reply | Threaded
Open this post in threaded view
|

Re: Higher order variables

Jomi Fred Hubner-4
In reply to this post by Iain Wallace-2
Hi Iain,

thanks for reporting the bug in .relevant_plan. I committed the fix in  
the source forge Subversion system. You find at
        http://jason.sourceforge.net/faq/faq.html#SECTION00081000000000000000
how to build a new jason.jar. If you has problem with that, I can  
provide that file for you.

HTH,

Jomi


On 15/01/2010, at 15:37, Iain Wallace wrote:

> Another day, more obscure Jason questions!
>
> I'm trying to make a set of plans apply in as many situations as  
> possible, so ideally want to use higher order variables to match  
> events. Only it doesn't seem to work properly.
>
> Consider the example code below:
>
> belief(a,b).
>
> !test.
>
> +!test : true
> <- +b.
>
> +P : belief(a,P)
> <- .println("matched belief ").
> +P : true
> <- .println("didn't match").
>
> I would expect this to work as follows:
>
> belief(a,b). is added to the belief base, so "didn't match" is  
> printed.
> +b is added, so "matched belief " is printed.
>
> However, this isn't the case. when "b" is added, for some reason it  
> doesn't match the first rule. Is this a bug, or am I doing something  
> wrong?
>
> On a related note, consider the following code:
>
> +!test : .relevant_plans({+plan(A)},LP) & .length(LP,L) & (L > 0)
> <- .println("have plan!").
>
> This should check if the agent has a plan to handle the event  
> "+plan(A)". And it works as you'd expect. Unless the agent also has  
> a plan with a higher order variable trigger, like:
>
> +P : true
> <- .println("didn't match").
>
> This causes a null pointer error:
> [InternalActionLiteral] Error in internal action  
> '.relevant_plans({ +plan(A) },LP)' (test.asl:9): null
> java.lang.NullPointerException
> at jason.asSyntax.Structure.setTerm(Structure.java:221)
> at jason.asSyntax.Structure.makeVarsAnnon(Structure.java:285)
> at jason.asSyntax.Structure.makeVarsAnnon(Structure.java:289)
> at jason.asSyntax.Structure.makeVarsAnnon(Structure.java:275)
> at jason.stdlib.relevant_plans.execute(relevant_plans.java:101)
> at  
> jason
> .asSyntax
> .InternalActionLiteral.logicalConsequence(InternalActionLiteral.java:
> 84)
> at jason.asSyntax.LogExpr$1.<init>(LogExpr.java:95)
> at jason.asSyntax.LogExpr.logicalConsequence(LogExpr.java:94)
> at  
> jason.asSemantics.TransitionSystem.applyFindOp(TransitionSystem.java:
> 322)
> at  
> jason
> .asSemantics
> .TransitionSystem.applySemanticRule(TransitionSystem.java:130)
> at  
> jason
> .asSemantics.TransitionSystem.reasoningCycle(TransitionSystem.java:
> 967)
> at  
> jason.infra.centralised.CentralisedAgArch.run(CentralisedAgArch.java:
> 197)
> at java.lang.Thread.run(Thread.java:637)
>
> Again is this a bug, or am I doing something wrong?
>
> Thanks,
>
> Iain
> --
> The University of Edinburgh is a charitable body, registered in
> Scotland, with registration number SC005336.
>
>
> ------------------------------------------------------------------------------
> Throughout its 18-year history, RSA Conference consistently attracts  
> the
> world's best and brightest in the field, creating opportunities for  
> Conference
> attendees to learn about information security's most important  
> issues through
> interactions with peers, luminaries and emerging and established  
> companies.
> http://p.sf.net/sfu/rsaconf-dev2dev
> _______________________________________________
> Jason-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/jason-users

--
Jomi Fred Hubner
Department of Automation and Systems Engineering
Federal University of Santa Catarina
PO Box 476, Florianópolis, SC
88040-900 Brasil
http://www.das.ufsc.br/~jomi


------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
_______________________________________________
Jason-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jason-users