Quantcast

unable to understand Jason Behavior.

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

unable to understand Jason Behavior.

karandeep
Hi,

I am trying to implement something which requires agent interaction and consequently, updating their BB.

I built two agents, male and female, 5 each, generated agents and sent the agent information to third agent decision.
I face no problems till here.
But when I try to access decision agent's BB and make decision, something goes wrong.
This is the code of decision agent.
I have two different problems.

First Problem:

+female(A,B,C,D)[source(A)] : (B =1) & male(E,F,G,H)[source(E)]<- .wait(100);
// 100 ms wait so that all male beliefs are added first.

if(F=1 | F =0 | F=2){
-male(E,_,_,_)[source(E)];
.print("match");
-female(A,_,_,_)[source(A)];
+found(A,E);
}.

What i mean here is, whenever female belief is added, such that value of B factor is one, then check all instances of BB which have format of male(_,_,_,_). If you find such belief that is male and has F factor as 0,1 or 2, delete that male belief, delete that female belief and add a found belief.
This process doesn't work as different found beliefs have same male agent, and I want them to be distinct.
Am I doing something wrong? This is the problematic part of decision agent's BB.

found(female4,male3)[source(self)].
found(female5,male3)[source(self)].
found(female8,male3)[source(self)].
found(female1,male3)[source(self)].
found(female9,male3)[source(self)].
found(female6,male3)[source(self)].
found(female3,male3)[source(self)].

------------------------------------------------------------
Second Problem:
The code of decision agent:

!start.
+!start: true <- .wait(500);
.count(male(_,_,_,_), N);

for ( .range(I, 1, N)) {
?male(A,B,C,D)[source(A)];
!match(A,B,C,D);
}.

+!match(A,B,C,D) : true <- if ( B = 0 | B=1){
.print("in if else ",A);
-male(A,_,_,_)[source(A)];
}.


or------------------------

!start.
+!start: true <- .wait(500);
.count(male(_,_,_,_), N);

for ( .range(I, 1, N)) {
?male(A,B,C,D)[source(A)];
if ( B = 0 | B=1){
.print("in if else ",A);
-male(A,_,_,_)[source(A)];
};
}.

+!match(A,B,C,D) : true <-
}.

If I try to run it, it either doesn't show any output. Or show the problematic output ( some instances of male with B= 0 or B = 1 are still present in the BB. Ideally it should delete all those.)

Am I doing something wrong? Please help.

Regards,
Karandeep
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: unable to understand Jason Behavior.

Jomi Fred Hübner
Dear Karandeep,

I am not sure I understood the problems… I’ll however comment some parts of your email.


> On 09/06/2015, at 08:50, karandeep <[hidden email]> wrote:
>
> Hi,
>
> I am trying to implement something which requires agent interaction and
> consequently, updating their BB.
>
> I built two agents, male and female, 5 each, generated agents and sent the
> agent information to third agent decision.
> I face no problems till here.
> But when I try to access decision agent's BB and make decision, something
> goes wrong.
> This is the code of decision agent.
> I have two different problems.
>
> First Problem:
>
> +female(A,B,C,D)[source(A)] : (B =1) & male(E,F,G,H)[source(E)]<-
> .wait(100);
> // 100 ms wait so that all male beliefs are added first.

Maybe this wait is doing what you expect. The context of the plan requires a male(….) belief, the plan is thus selected only if such belief already exists (and variable E is ground at the plan selection moment). This E value is later used to remove the male belief identified at plan selection moment.

>
> if(F=1 | F =0 | F=2){
> -male(E,_,_,_)[source(E)];
> .print("match");
> -female(A,_,_,_)[source(A)];
> +found(A,E);
> }.
>
> What i mean here is, whenever female belief is added, such that value of B
> factor is one, then check all instances of BB which have format of
> male(_,_,_,_). If you find such belief that is male and has F factor as 0,1
> or 2, delete that male belief, delete that female belief and add a found
> belief.
> This process doesn't work as different found beliefs have same male agent,
> and I want them to be distinct.
> Am I doing something wrong? This is the problematic part of decision agent's
> BB.
>
> found(female4,male3)[source(self)].
> found(female5,male3)[source(self)].
> found(female8,male3)[source(self)].
> found(female1,male3)[source(self)].
> found(female9,male3)[source(self)].
> found(female6,male3)[source(self)].
> found(female3,male3)[source(self)].
>
> ------------------------------------------------------------
> Second Problem:
> The code of decision agent:
>
> !start.
> +!start: true <- .wait(500);
> .count(male(_,_,_,_), N);
>
> for ( .range(I, 1, N)) {
> ?male(A,B,C,D)[source(A)];
> !match(A,B,C,D);
> }.
>
> +!match(A,B,C,D) : true <- if ( B = 0 | B=1){
> .print("in if else ",A);
> -male(A,_,_,_)[source(A)];
> }.

if you want to remove all beliefs where B=0 or 1, the internal action .abolish does the job (in two lines):

        .abolish( male(_,0,_,_) );
        .abolish( male(_,1,_,_) )

HTH,

Jomi

>
>
> or------------------------
>
> !start.
> +!start: true <- .wait(500);
> .count(male(_,_,_,_), N);
>
> for ( .range(I, 1, N)) {
> ?male(A,B,C,D)[source(A)];
> if ( B = 0 | B=1){
> .print("in if else ",A);
> -male(A,_,_,_)[source(A)];
> };
> }.
>
> +!match(A,B,C,D) : true <-
> }.
>
> If I try to run it, it either doesn't show any output. Or show the
> problematic output ( some instances of male with B= 0 or B = 1 are still
> present in the BB. Ideally it should delete all those.)
>
> Am I doing something wrong? Please help.
>
> Regards,
> Karandeep
>
>
>
> --
> View this message in context: http://jason.2324890.n4.nabble.com/unable-to-understand-Jason-Behavior-tp781.html
> Sent from the jason-users mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> _______________________________________________
> Jason-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/jason-users


------------------------------------------------------------------------------
_______________________________________________
Jason-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jason-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: unable to understand Jason Behavior.

karandeep
thanks
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: unable to understand Jason Behavior.

karandeep
Hi,

I was experimenting with Jason and couldn't figure out why the following is happening:

agent:

+!start : true <- .print("hello world  .").
+start[source(percept)] <- !start.
-start[source(percept)] : true <- .print("percepts removed").

environment:
public class prog extends jason.environment.TimeSteppedEnvironment {

        public static final Literal of  = Literal.parseLiteral("starting");
        private Logger logger = Logger.getLogger("prog."+prog.class.getName());

    /** Called before the MAS execution with the args informed in .mas2j */
    @Override
    public void init(String[] args) {
        super.init(args);
    }
       
    @Override
        protected void stepStarted(int step) {
    System.out.println("in step started"+step);
    addPercept(Literal.parseLiteral("start"));
   
    }
   
    @Override
        protected void stepFinished(int step, long time, boolean timeout) {
                if( timeout)
                {
    System.out.println("in step finished");
                }
        }
   
    @Override
    protected void updateAgsPercept() {
    System.out.println("in update");
    clearPercepts();
    }
       
    @Override
    public boolean executeAction(String agName, Structure action) {
    return true;
    }

    /** Called before the end of MAS execution */
    @Override
    public void stop() {
    super.stop();            
    }
}

i have set timeout as 1000, and following the is the output:

in step started0
Jason Http Server running on http://129.254.186.222:3274
[agent11] hello world  .
[agent14] hello world  .
[agent15] hello world  .
[agent110] hello world  .
[agent18] hello world  .
[agent16] hello world  .
[agent12] hello world  .
[agent13] hello world  .
[agent17] hello world  .
[agent19] hello world  .
in step finished
in update
in step started1
in step finished
in update
in step started2
in step finished
in update
in step started3
in step finished
in update
in step started4
in step finished
in update
in step started5

and so on...

Now, what I wanted was that hello world should have printed again and again. But it gets printed only once for all agents.
When timeout is reached, the steps are executed again and again, and agents' percepts should have added and removed, and hello world should have been printed again and again.
The agent never perceives removing of percepts, shouldn't it when clearPercepts() is executed?
It doesn't work with removePercepts() also.
What is the issue here.
Please guide.
Why is this happening and how can make it behave in desired manner.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: unable to understand Jason Behavior.

Jomi Hubner
Since you are using SteppedEnv, the environment gives perception to all agents at the “same” time (the begin of the step). What you do meanwhile is not seen by the agents.

To have the desired result, you have to add “start” in a step and remove it in the next (so that the agents stop perceiving it).

e.g.:

…. stepStarted(int step) {

        if (step % 2 == 0)
                addPercept(Literal.parseLiteral("start"));
        else
                clearPercepts();
}

HTH

Jomi



> On 04/08/2015, at 05:51, karandeep <[hidden email]> wrote:
>
> Hi,
>
> I was experimenting with Jason and couldn't figure out why the following is
> happening:
>
> agent:
>
> +!start : true <- .print("hello world  .").
> +start[source(percept)] <- !start.
> -start[source(percept)] : true <- .print("percepts removed").
>
> environment:
> public class prog extends jason.environment.TimeSteppedEnvironment {
>
> public static final Literal of  = Literal.parseLiteral("starting");
> private Logger logger = Logger.getLogger("prog."+prog.class.getName());
>
>    /** Called before the MAS execution with the args informed in .mas2j */
>    @Override
>    public void init(String[] args) {
>        super.init(args);
>    }
>
>    @Override
> protected void stepStarted(int step) {
>     System.out.println("in step started"+step);
>     addPercept(Literal.parseLiteral("start"));
>    
>    }
>
>    @Override
> protected void stepFinished(int step, long time, boolean timeout) {
> if( timeout)
> {
>     System.out.println("in step finished");
> }
> }
>
>    @Override
>    protected void updateAgsPercept() {
>     System.out.println("in update");
>     clearPercepts();
>    }
>
>    @Override
>    public boolean executeAction(String agName, Structure action) {
>     return true;
>    }
>
>    /** Called before the end of MAS execution */
>    @Override
>    public void stop() {
>     super.stop();            
>    }
> }
>
> i have set timeout as 1000, and following the is the output:
>
> in step started0
> Jason Http Server running on http://129.254.186.222:3274
> [agent11] hello world  .
> [agent14] hello world  .
> [agent15] hello world  .
> [agent110] hello world  .
> [agent18] hello world  .
> [agent16] hello world  .
> [agent12] hello world  .
> [agent13] hello world  .
> [agent17] hello world  .
> [agent19] hello world  .
> in step finished
> in update
> in step started1
> in step finished
> in update
> in step started2
> in step finished
> in update
> in step started3
> in step finished
> in update
> in step started4
> in step finished
> in update
> in step started5
>
> and so on...
>
> Now, what I wanted was that hello world should have printed again and again.
> But it gets printed only once for all agents.
> When timeout is reached, the steps are executed again and again, and agents'
> percepts should have added and removed, and hello world should have been
> printed again and again.
> The agent never perceives removing of percepts, shouldn't it when
> clearPercepts() is executed?
> It doesn't work with removePercepts() also.
> What is the issue here.
> Please guide.
> Why is this happening and how can make it behave in desired manner.
>
>
>
> --
> View this message in context: http://jason.2324890.n4.nabble.com/unable-to-understand-Jason-Behavior-tp781p787.html
> Sent from the jason-users mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> _______________________________________________
> 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


------------------------------------------------------------------------------
_______________________________________________
Jason-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jason-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: unable to understand Jason Behavior.

karandeep
This post has NOT been accepted by the mailing list yet.
Thank you so much. That solved the issue.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: unable to understand Jason Behavior.

karandeep
Hi,

I was trying some simulation in which there is multiple communication between the multiple agents of two types ( say A type agents and B type agents, 100 each). With your suggestion before, I was able to do it using a loop like this:

while ( v(X) & X <101){
.concat(agent, X, N);
-+v(X+1);
.send(N, achieve, match(A));

i.e. messages are sent to agent1, agnet2 and so on.

I have some requirement in which is need to remove the agents from simulation. I do that using .kill_agent.
But now, since some agents have been removed from simulation, .send throws up an error.
I tried solving it using it .all_names(L). If (.member(N,L)), then send the messages, this way each time, message would be sent only to the agents actually present.
But .member(N,L) doesn't work for me. N & L has correct values, I have checked them using .print.
Can you tell me the reason and possible workaround for this problem.

Thanks & Regards,
Karandeep
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: unable to understand Jason Behavior.

Jomi Hubner
Hi Karandeep,

I don’t think there is a bug in the .member internal action, since it is used quite a lot.

Could it be the case that the name N is a string? (the values in L are atoms an atoms are not equal to strings.

For instance,
        .member(“bob”, [alice,bob])
is false.

If that is the case, you can use .term2string to change the type of N.

HTH,

Jomi

> On 24/09/2015, at 08:59, karandeep <[hidden email]> wrote:
>
> Hi,
>
> I was trying some simulation in which there is multiple communication
> between the multiple agents of two types ( say A type agents and B type
> agents, 100 each). With your suggestion before, I was able to do it using a
> loop like this:
>
> while ( v(X) & X <101){
> .concat(agent, X, N);
> -+v(X+1);
> .send(N, achieve, match(A));
>
> i.e. messages are sent to agent1, agnet2 and so on.
>
> I have some requirement in which is need to remove the agents from
> simulation. I do that using .kill_agent.
> But now, since some agents have been removed from simulation, .send throws
> up an error.
> I tried solving it using it .all_names(L). If (.member(N,L)), then send the
> messages, this way each time, message would be sent only to the agents
> actually present.
> But .member(N,L) doesn't work for me. N & L has correct values, I have
> checked them using .print.
> Can you tell me the reason and possible workaround for this problem.
>
> Thanks & Regards,
> Karandeep
>
>
>
> --
> View this message in context: http://jason.2324890.n4.nabble.com/unable-to-understand-Jason-Behavior-tp781p791.html
> Sent from the jason-users mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> Monitor Your Dynamic Infrastructure at Any Scale With Datadog!
> Get real-time metrics from all of your servers, apps and tools
> in one place.
> SourceForge users - Click here to start your Free Trial of Datadog now!
> http://pubads.g.doubleclick.net/gampad/clk?id=241902991&iu=/4140
> _______________________________________________
> 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


------------------------------------------------------------------------------
Monitor Your Dynamic Infrastructure at Any Scale With Datadog!
Get real-time metrics from all of your servers, apps and tools
in one place.
SourceForge users - Click here to start your Free Trial of Datadog now!
http://pubads.g.doubleclick.net/gampad/clk?id=241902991&iu=/4140
_______________________________________________
Jason-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jason-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: unable to understand Jason Behavior.

karandeep
This post has NOT been accepted by the mailing list yet.
Hi Jomi,

I had already tried that and N is in fact a string. But I was using .term2String to convert list into strings and .member doesn't work with strings.
It worked with N.
Rookie mistake :(
Thanks for your quick reply and help.

Regards,
Karandeep
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: unable to understand Jason Behavior.

karandeep
Hello again.

With your help, I have implemented my project for certain number of agents :-).
But when I tried to increase number of agents, I faced some issues. I increased heap size and some other adjustments in code, but I wasn't very successful.
My project involves medium to large amount of communication between the agents. Right now, I am able to execute about 1500 agents.
I have two questions:

1) I came to know about 'pool' configuration from demos, but when I try to us that, I get this error:

[RunCentralisedMAS] Created 200 agents.
[RunCentralisedMAS] Error getting the number of thread for the pool.

and my simulation does not proceed. Without 'pool' configration, it runs alright. You can see that here I tried only for 200 agents, and still it threw this error.

2) My second question is, I am using time stepped environment and I am using timeout ( like 5000 ms) for each step. But this is not best solution since in my simulation, in first step there is relatively large amount of processing and then it is comparatively less in subsequent steps, so this standard time out for each step is a overhead. Can something be done about it. Does it have something to do with testEndCycle?
In each step, I have agents which satisfy certain conditions, and based on those, only certain no. of agents undergo processing. (e.g.,the age of agents increases in each step and they may become available based on that in coming steps).

Thanks & Regards,
Karandeep
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: unable to understand Jason Behavior.

Jomi Fred Hübner
Hi Karandeep,


> On 16/10/2015, at 10:58, karandeep <[hidden email]> wrote:
>
> Hello again.
>
> With your help, I have implemented my project for certain number of agents
> :-).
> But when I tried to increase number of agents, I faced some issues. I
> increased heap size and some other adjustments in code, but I wasn't very
> successful.
> My project involves medium to large amount of communication between the
> agents. Right now, I am able to execute about 1500 agents.
> I have two questions:
>
> 1) I came to know about 'pool' configuration from demos, but when I try to
> us that, I get this error:
>
> [RunCentralisedMAS] Created 200 agents.
> [RunCentralisedMAS] Error getting the number of thread for the pool.

this error means that jason could not parse the number of threads. Usually it should look like:

        ….
        Centralised(pool,4)   // 4 threads (usually we put the number of cores of the machine)
        ….


>
> and my simulation does not proceed. Without 'pool' configration, it runs
> alright. You can see that here I tried only for 200 agents, and still it
> threw this error.
>
> 2) My second question is, I am using time stepped environment and I am using
> timeout ( like 5000 ms) for each step. But this is not best solution since
> in my simulation, in first step there is relatively large amount of
> processing and then it is comparatively less in subsequent steps, so this
> standard time out for each step is a overhead. Can something be done about
> it. Does it have something to do with testEndCycle?

yes, you can override this method for special cases of end of cycle, like that you describe below.
(see the source src/jason/environment/TimeSteppedEnvironment.java for more details).

Otherwise, I can provide you a new implementation of jason where there will be a method like setTimeOut, that you can use to decrease the initial timeout.

HTH,

Jomi


> In each step, I have agents which satisfy certain conditions, and based on
> those, only certain no. of agents undergo processing. (e.g.,the age of
> agents increases in each step and they may become available based on that in
> coming steps).


>
> Thanks & Regards,
> Karandeep
>
>
>
> --
> View this message in context: http://jason.2324890.n4.nabble.com/unable-to-understand-Jason-Behavior-tp781p795.html
> Sent from the jason-users mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> _______________________________________________
> Jason-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/jason-users


------------------------------------------------------------------------------
_______________________________________________
Jason-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jason-users
Loading...