addPercept() method does not update the percept list

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

addPercept() method does not update the percept list

suralk
Hi All,
I am new to Jason programming and was playing with the examples first which worked fine. I have started to use Jason for my real research work and have faced a problem with the addPercept() method.

In the RetrievePercepts() method below, I try to call the addPercept() method, using the parameters received. As shown, I try to look into the set of percepts of the agent before and after adding a percept. also I make sure i clean the percept list at the beginning. As expected, the call to getPercepts after calling addPercept() shows the added percept.
I want to change some of the perceived percepts in my architecture customization class, and when I look at the percept list inside the perceive() method, the percept list is empty!
At the moment, I try to add two percepts in different occasions and adding one of them works while the other one does not.

It could be some small mistake that I am doing, but I just can't figure it out. Hope someone would be able to help me out.

thanks

/Suralk

public void RetrievePercepts(Literal percept, String agName){    
    clearPercepts(agName);        
    List<Literal> per =this.getPercepts(agName);
    try {
    if (per != null) {
    Iterator<Literal> ip = per.iterator();
    while (ip.hasNext()) {    
    Literal p = ip.next();
    String  ps = p.toString();  
       
    }
    }    
            }  catch (Exception e) {
               
            }
    addPercept(agName, percept);
   
    List<Literal> per1 =this.getPercepts(agName);
    try {
    if (per1 != null) {
    Iterator<Literal> ip = per1.iterator();
    while (ip.hasNext()) {    
    Literal p = ip.next();
    String  ps = p.toString();
    }
    }    
            } catch (Exception e) {
               
            }
    }
Reply | Threaded
Open this post in threaded view
|

Re: addPercept() method does not update the percept list

Jomi Hubner
Hi Suralk,

The getPercept is supposed to be called by the agent reasoning process and not to "consult" the current perceptions. It implements an optimisation strategy that returns null if nothing has changed since last call (so the reasoning does not need to revise beliefs based on perception). If you call this method in your environment class, you are indeed changing the way the reasoning "sees" the environment.

I wish you have a good continuation of your experiments with Jason.

Jomi

ps.: I'm adding a method for environment programmers to consult the perceptions.

On 22/07/2010, at 02:29, suralk wrote:

>
> Hi All,
> I am new to Jason programming and was playing with the examples first which
> worked fine. I have started to use Jason for my real research work and have
> faced a problem with the addPercept() method.
>
> In the RetrievePercepts() method below, I try to call the addPercept()
> method, using the parameters received. As shown, I try to look into the set
> of percepts of the agent before and after adding a percept. also I make sure
> i clean the percept list at the beginning. As expected, the call to
> getPercepts after calling addPercept() shows the added percept.
> I want to change some of the perceived percepts in my architecture
> customization class, and when I look at the percept list inside the
> perceive() method, the percept list is empty!
> At the moment, I try to add two percepts in different occasions and adding
> one of them works while the other one does not.
>
> It could be some small mistake that I am doing, but I just can't figure it
> out. Hope someone would be able to help me out.
>
> thanks
>
> /Suralk
>
> public void RetrievePercepts(Literal percept, String agName){    
>     clearPercepts(agName);        
>     List<Literal> per =this.getPercepts(agName);
>     try {
>     if (per != null) {
>     Iterator<Literal> ip = per.iterator();
>     while (ip.hasNext()) {    
>     Literal p = ip.next();
>     String  ps = p.toString();  
>        
>     }
>     }    
>    }  catch (Exception e) {
>        
>    }
>     addPercept(agName, percept);
>    
>     List<Literal> per1 =this.getPercepts(agName);
>     try {
>     if (per1 != null) {
>     Iterator<Literal> ip = per1.iterator();
>     while (ip.hasNext()) {    
>     Literal p = ip.next();
>     String  ps = p.toString();
>     }
>     }    
>    } catch (Exception e) {
>        
>    }
>    }
> --
> View this message in context: http://old.nabble.com/addPercept%28%29-method-does-not-update-the-percept-list-tp29233392p29233392.html
> Sent from the jason-users mailing list archive at Nabble.com.
>
>
> ------------------------------------------------------------------------------
> This SF.net email is sponsored by Sprint
> What will you do first with EVO, the first 4G phone?
> Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
> _______________________________________________
> Jason-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/jason-users

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


------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
Jason-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jason-users
Reply | Threaded
Open this post in threaded view
|

Re: addPercept() method does not update the percept list

suralk
Hi Jomi,
Thanks a lot for the reply. I tried to use the getPercept() method just to see what's in the agent's percept list because addition of some percepts did not work for me. Now I have found the problem with my code and it has got nothing to do with adding percepts.
Thanks once again for the explanation, I did not know about it.

/Suralk

Jomi Hubner wrote
Hi Suralk,

The getPercept is supposed to be called by the agent reasoning process and not to "consult" the current perceptions. It implements an optimisation strategy that returns null if nothing has changed since last call (so the reasoning does not need to revise beliefs based on perception). If you call this method in your environment class, you are indeed changing the way the reasoning "sees" the environment.

I wish you have a good continuation of your experiments with Jason.

Jomi

ps.: I'm adding a method for environment programmers to consult the perceptions.

On 22/07/2010, at 02:29, suralk wrote:

>
> Hi All,
> I am new to Jason programming and was playing with the examples first which
> worked fine. I have started to use Jason for my real research work and have
> faced a problem with the addPercept() method.
>
> In the RetrievePercepts() method below, I try to call the addPercept()
> method, using the parameters received. As shown, I try to look into the set
> of percepts of the agent before and after adding a percept. also I make sure
> i clean the percept list at the beginning. As expected, the call to
> getPercepts after calling addPercept() shows the added percept.
> I want to change some of the perceived percepts in my architecture
> customization class, and when I look at the percept list inside the
> perceive() method, the percept list is empty!
> At the moment, I try to add two percepts in different occasions and adding
> one of them works while the other one does not.
>
> It could be some small mistake that I am doing, but I just can't figure it
> out. Hope someone would be able to help me out.
>
> thanks
>
> /Suralk
>
> public void RetrievePercepts(Literal percept, String agName){    
>     clearPercepts(agName);        
>     List<Literal> per =this.getPercepts(agName);
>     try {
>     if (per != null) {
>     Iterator<Literal> ip = per.iterator();
>     while (ip.hasNext()) {    
>     Literal p = ip.next();
>     String  ps = p.toString();  
>        
>     }
>     }    
>    }  catch (Exception e) {
>        
>    }
>     addPercept(agName, percept);
>    
>     List<Literal> per1 =this.getPercepts(agName);
>     try {
>     if (per1 != null) {
>     Iterator<Literal> ip = per1.iterator();
>     while (ip.hasNext()) {    
>     Literal p = ip.next();
>     String  ps = p.toString();
>     }
>     }    
>    } catch (Exception e) {
>        
>    }
>    }
> --
> View this message in context: http://old.nabble.com/addPercept%28%29-method-does-not-update-the-percept-list-tp29233392p29233392.html
> Sent from the jason-users mailing list archive at Nabble.com.
>
>
> ------------------------------------------------------------------------------
> This SF.net email is sponsored by Sprint
> What will you do first with EVO, the first 4G phone?
> Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
> _______________________________________________
> Jason-users mailing list
> Jason-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jason-users

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


------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
Jason-users mailing list
Jason-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jason-users