Quantcast

How to maintain the previous value of the an agent among many agents.

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

How to maintain the previous value of the an agent among many agents.

Meshal Al-Harbi
Hi All,

I have tow very basic technical questions in Repast, which I was hesitated to ask. 

1/ I have 10 agents, which last for 100 ticks. I want in every tick the counter increases by only one for all the agents, so in tick 50 the counter is 50. I set a normal counter, but I noticed that it increases by 10, as many as the agents, in every tick.

2/ how can I have a variable for every agent to maintain the previous value. For example, agent1  has a value=2 in tick=2 I want to compare it with agent1 value=3 in tick=3. When I use a normal variable, the noticed the value get changed by the second agent in the same tick.

Many thanks,


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to maintain the previous value of the an agent among many agents.

srcnick
See below.

On Mar 27, 2017, at 11:18 AM, Meshal Al-Harbi <[hidden email]> wrote:

Hi All,

I have tow very basic technical questions in Repast, which I was hesitated to ask. 

1/ I have 10 agents, which last for 100 ticks. I want in every tick the counter increases by only one for all the agents, so in tick 50 the counter is 50. I set a normal counter, but I noticed that it increases by 10, as many as the agents, in every tick.

There’s a few ways you could do this:

1. Use the current tick count instead of your own counter, if that’s appropriate.

2. Keep track of the tick when the counter was last updated. When that doesn’t match the current tick, then update the counter.

3. Designate a particular agent to increment the counter. For example, if you assign each agent a different id, then you could something like

if (id == 0) {
  // increment counter
}

4. Schedule an action that updates the counter at the appropriate time — this by passes the agent’s entirely.




2/ how can I have a variable for every agent to maintain the previous value. For example, agent1  has a value=2 in tick=2 I want to compare it with agent1 value=3 in tick=3. When I use a normal variable, the noticed the value get changed by the second agent in the same tick.

How are you defining the variabile. If its a typical private field in a class, then it should only be accessible to the agent that is the instance of that class. Is the variable static?

Nick



Many thanks,

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to maintain the previous value of the an agent among many agents.

srcnick
In reply to this post by Meshal Al-Harbi
See below.

On Mar 27, 2017, at 11:18 AM, Meshal Al-Harbi <[hidden email]> wrote:

Hi All,

I have tow very basic technical questions in Repast, which I was hesitated to ask. 

1/ I have 10 agents, which last for 100 ticks. I want in every tick the counter increases by only one for all the agents, so in tick 50 the counter is 50. I set a normal counter, but I noticed that it increases by 10, as many as the agents, in every tick.

There’s a few ways you could do this:

1. Use the current tick count instead of your own counter, if that’s appropriate.

2. Keep track of the tick when the counter was last updated. When that doesn’t match the current tick, then update the counter.

3. Designate a particular agent to increment the counter. For example, if you assign each agent a different id, then you could something like

if (id == 0) {
  // increment counter
}

4. Schedule an action that updates the counter at the appropriate time — this by passes the agent’s entirely.




2/ how can I have a variable for every agent to maintain the previous value. For example, agent1  has a value=2 in tick=2 I want to compare it with agent1 value=3 in tick=3. When I use a normal variable, the noticed the value get changed by the second agent in the same tick.

How are you defining the variabile. If its a typical private field in a class, then it should only be accessible to the agent that is the instance of that class. Is the variable static?

Nick



Many thanks,

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to maintain the previous value of the an agent among many agents.

Meshal Al-Harbi
Thank you Nick for the explanation. It works now.

Thanks again,


On 28 March 2017 at 14:27, Nick Collier <[hidden email]> wrote:
See below.

On Mar 27, 2017, at 11:18 AM, Meshal Al-Harbi <[hidden email]> wrote:

Hi All,

I have tow very basic technical questions in Repast, which I was hesitated to ask. 

1/ I have 10 agents, which last for 100 ticks. I want in every tick the counter increases by only one for all the agents, so in tick 50 the counter is 50. I set a normal counter, but I noticed that it increases by 10, as many as the agents, in every tick.

There’s a few ways you could do this:

1. Use the current tick count instead of your own counter, if that’s appropriate.

2. Keep track of the tick when the counter was last updated. When that doesn’t match the current tick, then update the counter.

3. Designate a particular agent to increment the counter. For example, if you assign each agent a different id, then you could something like

if (id == 0) {
  // increment counter
}

4. Schedule an action that updates the counter at the appropriate time — this by passes the agent’s entirely.




2/ how can I have a variable for every agent to maintain the previous value. For example, agent1  has a value=2 in tick=2 I want to compare it with agent1 value=3 in tick=3. When I use a normal variable, the noticed the value get changed by the second agent in the same tick.

How are you defining the variabile. If its a typical private field in a class, then it should only be accessible to the agent that is the instance of that class. Is the variable static?

Nick



Many thanks,

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest




--
Eng.Meshal Al-beedhani

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest
Loading...