distance

122 views
Skip to first unread message

Ancha

unread,
Jul 30, 2013, 8:41:57 AM7/30/13
to gama-p...@googlegroups.com
Hi,

Need you help!
I have a shape file with roads and two types of agents (A and B). How can I define that agents should be distributed as close as possible to the roads (but not exactly on them) and at the same time in some distance from each other (for example if the closest agent to A is A, the minimal distance between them should be 2, and if the closest agent to A is B, the minimal distance should be 10)?

Thank you!

Patrick Taillandier

unread,
Jul 30, 2013, 8:47:15 AM7/30/13
to gama-p...@googlegroups.com
Hi,

Just to be sure that I have well understood your problem, could you send us an image example of what you want to achieve.

Cheers,

Patrick


2013/7/30 Ancha <anechka.go...@gmail.com>

--
You received this message because you are subscribed to the Google Groups "GAMA" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gama-platfor...@googlegroups.com.
To post to this group, send email to gama-p...@googlegroups.com.
Visit this group at http://groups.google.com/group/gama-platform.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Ancha

unread,
Jul 30, 2013, 9:03:07 AM7/30/13
to gama-p...@googlegroups.com
Hi,

Thank you for reply!
I attach simple image of the problem.

BR, Ancha
Simple scatch.png

Patrick Taillandier

unread,
Jul 30, 2013, 9:35:59 AM7/30/13
to gama-p...@googlegroups.com
Hi,

Your problem is far to be simple, but I found a way that seems to work quite well and that is based on the use of several spatial operators of GAMA (in particular: union, buffer (+), difference (-)) and any_location_in). The only default of my method is that is quite slow (but if you do not have many agents, I think it is ok). I attached the example model.

Cheers,

Patrick
agent_placement.zip

Ancha

unread,
Jul 30, 2013, 10:14:40 AM7/30/13
to gama-p...@googlegroups.com
Dear Patrick,


Thank you very much! But I coudn`t open your model - I attach the log with errors.

What might cause this problem?

вторник, 30 июля 2013 г., 17:35:59 UTC+4 пользователь Patrick Taillandier написал:
problem.log

Patrick Taillandier

unread,
Jul 30, 2013, 10:27:06 AM7/30/13
to gama-p...@googlegroups.com
Which version of GAMA are you using? The model I sent to you works with GAMA 1.6.

Patrick


2013/7/30 Ancha <anechka.go...@gmail.com>

Ancha

unread,
Jul 30, 2013, 10:37:00 AM7/30/13
to gama-p...@googlegroups.com
Yes, the problem was in old version! I tried the new one and it works well!
Thank you very much! You helped me a lot!

BR,
Ancha

вторник, 30 июля 2013 г., 17:27:06 UTC+3 пользователь Patrick Taillandier написал:
Message has been deleted

Ancha

unread,
Aug 1, 2013, 7:30:48 AM8/1/13
to gama-p...@googlegroups.com
Dear Patrick,

Could you please explain why do you use in this code

exterior_road_current <- exterior_road_current - (shape + distance_same_species);

I understood that before you made a trick to cast geometry type for exterior_road, but I still can`t get how the upper expression works? What is the logic?

I will be very appreciate if you pay attention to my question! Thank you very much!


BR,
Ancha

вторник, 30 июля 2013 г., 17:27:06 UTC+3 пользователь Patrick Taillandier написал:
Which version of GAMA are you using? The model I sent to you works with GAMA 1.6.

Patrick

Ancha

unread,
Aug 1, 2013, 7:54:33 AM8/1/13
to gama-p...@googlegroups.com

And one more question, if you please! I want to work inside each sector of the road network (for example, define that inside one sector there will be just agents of one type). How it is possible to define the sectors of the road network (sub-graphs of the main graph)?


Thank you!

BR,
Ancha

вторник, 30 июля 2013 г., 17:27:06 UTC+3 пользователь Patrick Taillandier написал:
Which version of GAMA are you using? The model I sent to you works with GAMA 1.6.

Patrick

Patrick Taillandier

unread,
Aug 1, 2013, 7:55:06 AM8/1/13
to gama-p...@googlegroups.com
so to explain: in your model, all agents of species agentA and agentB have a point for geometry (default geometry).
by adding a buffer, you have the area that is reserved by this agent (no agent of agentA can be created in this area). Then, we remove this new area to the possible location where agents of species agentA can be located. See the attached file for a more illustrated explanation ;) .

Cheers,

Patrick


2013/8/1 Ancha <anechka.go...@gmail.com>
Dear Patrick,

Could you please explain why do you use in this code

exterior_road_current <- exterior_road_current - (shape + distance_same_species);

I understood that before you made a trick to cast geometry type for exterior_road, but I still can`t get how the upper expression works? What is the logic?

I will be very appreciate if you pay attention to my question! Thank you very much!

BR,
Ancha

вторник, 30 июля 2013 г., 17:37:00 UTC+3 пользователь Ancha написал:
explication.pdf

Patrick Taillandier

unread,
Aug 1, 2013, 7:59:58 AM8/1/13
to gama-p...@googlegroups.com
The best way to do that is to define 2 graphs, one for agent of species agentA and the other for agents of species agentB.
First, you can add one or two attributes to the road species that will define which species of agents can use it:
 species road {
     bool is_agentA <- true; 
     bool is_agentB <- false; 
}

then you can obtained the list of road accessible for agentA and agentB:
list<road> road_agentA <- road where (each.is_agentA);
list<road> road_agentB <- road where (each.is_agentB);

At last you build 2 graph:
graphA <- ad_edge_graph(road_agentA);
graphB <- ad_edge_graph(road_agentB);

Cheers,

Patrick


2013/8/1 Ancha <anechka.go...@gmail.com>

Ancha

unread,
Aug 2, 2013, 6:43:50 AM8/2/13
to gama-p...@googlegroups.com
Dear Patrick,


Thank you very much for explanation! If it is possible, could you spend some time for my clarifying questions (I would like to be sure that I understand all properly)?

Questions..

1. Is exterior_road_current the stripe between max and min lines (look at the attachment)?

2. You wrote in explanation that each agent has shape but in the beginning we define geometry shape <- envelope(shape_file_roads);
So these are different shapes?

3. Is it true that when we create the agents, all the actions are doing step by step for each agent (like loop for each for example 50 agents A)? I mean that first one agent 1 is created, then it gets some location in exterior_road_current, then exterior_road_current is refreshing and after that the same consequence of actions is repeating with second agent, then with 3th, with 4th etc. But in every next step the area of exterior_road_current is getting smaller and smaller for future potential agents?

After all agents A got locations in exterior_road_current, we start to define possible area for agents B, and when we applied procedure ASK for all agents A, we get area for agents B distribution? True?

Thank you!

BR,
Ancha






четверг, 1 августа 2013 г., 14:55:06 UTC+3 пользователь Patrick Taillandier написал:
pic3.png

Patrick Taillandier

unread,
Aug 2, 2013, 7:55:38 AM8/2/13
to gama-p...@googlegroups.com
Hi,


1. Is exterior_road_current the stripe between max and min lines (look at the attachment)?

Exactly


2. You wrote in explanation that each agent has shape but in the beginning we define geometry shape <- envelope(shape_file_roads); 
So these are different shapes? 

As I said, in GAMA all agents has a geometry. The global section define the characteristics of the world agent that has, like all other agents, a geometry (accessible through the shape variable like for the other agent). In this line, we define the geometry of the world agent (the global environment of the model) as the envelope of the road shapefile.


3. Is it true that when we create the agents, all the actions are doing step by step for each agent (like loop for each for example 50 agents A)? I mean that first one agent 1 is created, then it gets some location in exterior_road_current, then exterior_road_current is refreshing and after that the same consequence of actions is repeating with second agent, then with 3th, with 4th etc. But in every next step the area of exterior_road_current is getting smaller and smaller for future potential agents? 

After all agents A got locations in exterior_road_current, we start to define possible area for agents B, and when we applied procedure ASK for all agents A, we get area for agents B distribution? True?

You are totally right ;) .

Patrick


2013/8/2 Ancha <anechka.go...@gmail.com>

Ancha

unread,
Aug 8, 2013, 7:36:10 AM8/8/13
to gama-p...@googlegroups.com
Hi,


Thank you for reply! I also wanted to know if it is possible to use greedy approach in GAML? I mean that now the distribution of agents B (and if I want to add agents C, D etc) will depend on the distribution of previous types of agents. I would like this process is independent. I want to create all the agents of all types and then randomly pick up one agentfrom the container and check the best place on the road shapefile for it - for example it should be as close to the road as possible and keep the buffer of some distance with other agents of other types). Then I again randomly pick some other agent and check again to find the most optimal position. In such a way I want to optimize the global placement as much as possible.

Could you advice something?

Thank you!

BR,
Ancha






пятница, 2 августа 2013 г., 14:55:38 UTC+3 пользователь Patrick Taillandier написал:

Patrick Taillandier

unread,
Aug 9, 2013, 4:14:50 AM8/9/13
to gama-p...@googlegroups.com
Hi,

As GAMA provides all classic structures of a programming language (loop, test...), it is of course possible to implement a greedy approach.
Just to be sure: can you give a more details example of what you mean by the best place on the road shapefile (with a drawing if possible :) ).

However, you can just created all your agents, then make a loop on all of them. One solution : 
create agentA number: 100;
create agentB number: 100;
geometry possible_place <- .... //initial possible locations for the agents, can be the union of road geometries, or the same geometry as in the last example
geometry possible_place_agentA <- copy(possible_place);
geometry possible_place_agentB <- copy(possible_place);
ask shuffle(agentA + agentB) {
        if (species(self) = agentA) {
                  location <- .... //choose the best place in possible_place_agentA;
                   possible_place_agentA <- possible_place_agentA - (shape + distance_same_species);
                   possible_place_agentB <- possible_place_agentB - (shape + distance_different_species);
        else  {
                   location <- .... //choose the best place in possible_place_agentB;
                   possible_place_agentB <- possible_place_agentB - (shape + distance_same_species);
                   possible_place_agentA <- possible_place_agentA - (shape + distance_different_species);
        }
}

Cheers,

Patrick


2013/8/8 Ancha <anechka.go...@gmail.com>

Ancha

unread,
Aug 15, 2013, 3:26:16 AM8/15/13
to gama-p...@googlegroups.com
Hi,


Thank you for your answer!
You understood me properly,but if I want to pick one agent from the shuffle heap of agents, set its location and after that delete it from this heap? Does your code work like an infinite loop? In case that after you ask the agent about its species type and set to location, this agent can appear in a heap one more time? Or you mean that after placement the same agent can not appear any more?


Thank you!


BR,
Ancha

пятница, 9 августа 2013 г., 11:14:50 UTC+3 пользователь Patrick Taillandier написал:

Patrick Taillandier

unread,
Aug 16, 2013, 7:17:40 AM8/16/13
to gama-p...@googlegroups.com
Hi,
Hi,

The ask statement on a list of agents is a loop on this list: each agent of the list is activated only once (it is thus a finite loop). 

Cheers,

Patrick

Ancha

unread,
Aug 22, 2013, 8:03:16 AM8/22/13
to gama-p...@googlegroups.com
Hi,

Thank you!


BR,

Ancha

пятница, 16 августа 2013 г., 14:17:40 UTC+3 пользователь Patrick Taillandier написал:
Reply all
Reply to author
Forward
0 new messages