creating new agents - runs amok

45 views
Skip to first unread message

Chris Harvey

unread,
Dec 9, 2019, 12:36:52 AM12/9/19
to GAMA
Hello everyone,

I have a bit of code where I am attempting to create new agents to imitate immigration.  What is occurring is that thousands of agents are being created and it's slowing my computer down significantly.  I have attached a screenshot of what I'm referring too.  Notice all the white....those are thousands of little agents.  Way too many agents.  I've tried several things but continue to create too many agents.  I've gone so far as to add a limit, where if the number of shrimp agents is greater than 15, that nothing happens.  From that little bit of code, I still get thousands of agents and the whole thing freezes.  Anyone have any idea's why I'm creating so many?

t The code that I'm using is as follows:

global
{


    init
    {
            create PS_shrimp number: 10;
    }
   
   
    species PS_shrimp parallel: true skills: [moving] control: fsm
   
    init
    {
            location <- any_location_in (my_hydro);
            PS_Size <- gauss(12,5);
    }
   
    reflex update
    {
        if (nb_s < 15)
        {
            do immigration();
        }
   
    }
   
   
    action immigration
    {
        create PS_shrimp number: 1
        {
            location <- one_of(Gate_ cell_list);
            PS_Size <- gauss(2.02, 0.2);
            PSColor <- #lime;
            gender <- rnd(1);
           
        }
   
   
    }
   
   
    aspect a {
        draw circle(30) color: PSColor at: {location.x, location.y, hyd_depth};
    }
   
    }
   
Screenshot from 2019-12-01 10-54-51.png

Alexis Drogoul (IRD)

unread,
Dec 9, 2019, 12:50:25 AM12/9/19
to gama-p...@googlegroups.com
Hi

In your code below, the value of nb_s is never changed. How it is defined ? How is it updated ?  

Cheers
Alexis



Chris Harvey

unread,
Dec 9, 2019, 7:45:35 AM12/9/19
to GAMA
The value nb_s is assigned in the global section as a constant.  The line nb_s < 15 ....is for the purpose of stopping the code from creating more agents once the number exceeds 15. I don't actually do anything with nb_s. I assumed that the 'create agent' code would increment the nb_s value when another agent is created.

In the PS_shrimp attribute table (when I view the population), I get possibly 20-30 records however in the display, I get thousands of agents.

Chris

You received this message because you are subscribed to a topic in the Google Groups "GAMA" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gama-platform/iYjuh6wuEio/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gama-platfor...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gama-platform/7756754C-F49E-4BCC-A18B-F4DC5F17B2D7%40ird.fr.

Youcef Sklab

unread,
Dec 10, 2019, 3:21:23 AM12/10/19
to GAMA
Hi, 
You can add a line of code to change the value of nb_s (nb_s <- nb_s + 1;)  every time you call the action to create a new agent.  Something like:

   action immigration
    {
        nb_s <- nb_s + 1;
To unsubscribe from this group and stop receiving emails from it, send an email to gama-platform+unsubscribe@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/gama-platform/2f3f2013-ca67-4c57-8e08-d465c8a60cad%40googlegroups.com.
<Screenshot from 2019-12-01 10-54-51.png>

--
You received this message because you are subscribed to a topic in the Google Groups "GAMA" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gama-platform/iYjuh6wuEio/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gama-platform+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages