Integrate a building map in a Repast model - Evacuation Simulation

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

Integrate a building map in a Repast model - Evacuation Simulation

Gerardo Leo
Greetings, 

In my model I have to simulate an evacuation from a building (an airport).
At the moment my problem is how to create the building map and how to integrate it in my Repast model. I did't find any tutorial about this and I don't know how to start.

My idea is to use a GIS file, draw the map using the CAD and then covert it in a shape file (I am open to any kind of advice, since I am a real novice with repast).

I found the Nick Malleson's “repastcity”. It is very useful but pretty complex at the same time, I am going to study it. At the moment seems to be the best (probably the only) GIS tutorial for Repast.

Moreover a doubt assails me: I don’t want that my agents can move only along a predetermined footpaths, like the road network in the “repastcity”, rather I want that they move in a random way in the whole building.
Is it possible ? How can I do it ? 

Thank you very much in advance, best. 
Gerardo 

------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are
consuming the most bandwidth. Provides multi-vendor support for NetFlow,
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports.http://sdm.link/zohodev2dev
_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest
Reply | Threaded
Open this post in threaded view
|

Re: Integrate a building map in a Repast model - Evacuation Simulation

Grant, Tyler J [NREM]

The most useful “tutorial” for GIS models is the “Geography” example model distributed with Repast Simphony.  But I’m not sure you want a GIS type of model, you might be better off using a continuous space model like is implemented in the JZombies tutorial. 

 

Dr. Tyler J. Grant

Postdoctoral Associate

Department of Natural Resource Ecology and Management

Iowa State University

339 Science II

Ames, IA 50011

 

From: Gerardo Leo [mailto:[hidden email]]
Sent: Thursday, July 21, 2016 7:55 PM
To: [hidden email]
Subject: [Repast-interest] Integrate a building map in a Repast model - Evacuation Simulation

 

Greetings, 

 

In my model I have to simulate an evacuation from a building (an airport).

At the moment my problem is how to create the building map and how to integrate it in my Repast model. I did't find any tutorial about this and I don't know how to start.

 

My idea is to use a GIS file, draw the map using the CAD and then covert it in a shape file (I am open to any kind of advice, since I am a real novice with repast).

 

I found the Nick Malleson's “repastcity”. It is very useful but pretty complex at the same time, I am going to study it. At the moment seems to be the best (probably the only) GIS tutorial for Repast.

 

Moreover a doubt assails me: I don’t want that my agents can move only along a predetermined footpaths, like the road network in the “repastcity”, rather I want that they move in a random way in the whole building.

Is it possible ? How can I do it ? 

 

Thank you very much in advance, best. 

Gerardo 


------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are
consuming the most bandwidth. Provides multi-vendor support for NetFlow,
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports.http://sdm.link/zohodev2dev
_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest
Reply | Threaded
Open this post in threaded view
|

Re: Integrate a building map in a Repast model - Evacuation Simulation

Tatara, Eric R.
In reply to this post by Gerardo Leo
Andrew Crooks has a really great blog about pedestrian modeling and evacuation models:  http://www.gisagents.org/

I'd look there to get some ideas.  Most of the models highlighted on his site are implemented with NetLogo or Mason, but the modeling concepts would translate similarly into Repast.  My suggestion if you aren't starting with GIS data, then it might be easier to start with a 2D space.  You can implement the walls of a building using a 2D value layer in Repast such that certain values represent walls or restricted areas the agents cannot move into.  Agents will need to see the walls and other agents by querying the space with some defined radius or cone that represents how far the agents can see in some direction.  The movement rules will use the information about the agent's local neighborhood to perform actions like avoiding a wall or following a crowd of other agents.

eric

Eric Tatara, PhD, PE
Software Engineer
Global Security Sciences Division
Argonne National Laboratory

From: Gerardo Leo [[hidden email]]
Sent: Thursday, July 21, 2016 7:54 PM
To: [hidden email]
Subject: [Repast-interest] Integrate a building map in a Repast model - Evacuation Simulation

Greetings, 

In my model I have to simulate an evacuation from a building (an airport).
At the moment my problem is how to create the building map and how to integrate it in my Repast model. I did't find any tutorial about this and I don't know how to start.

My idea is to use a GIS file, draw the map using the CAD and then covert it in a shape file (I am open to any kind of advice, since I am a real novice with repast).

I found the Nick Malleson's “repastcity”. It is very useful but pretty complex at the same time, I am going to study it. At the moment seems to be the best (probably the only) GIS tutorial for Repast.

Moreover a doubt assails me: I don’t want that my agents can move only along a predetermined footpaths, like the road network in the “repastcity”, rather I want that they move in a random way in the whole building.
Is it possible ? How can I do it ? 

Thank you very much in advance, best. 
Gerardo 

------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are
consuming the most bandwidth. Provides multi-vendor support for NetFlow,
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports.http://sdm.link/zohodev2dev
_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest
Reply | Threaded
Open this post in threaded view
|

Re: Integrate a building map in a Repast model - Evacuation Simulation

Fabian Cid
In reply to this post by Gerardo Leo

Hi Gerardo
You're right, the best option would be to use a (or many) geography projection (gis libraries ) for your model.  Maybe one layer for each level of the building . The movement doesn't have to be constrained to a path,  rather areas can be defined as polygons with barriers and connecting sections (entrance-exits) .

Good luck

Fabián Cid Yañez


On Jul 22, 2016 5:27 AM, "Gerardo Leo" <[hidden email]> wrote:
Greetings, 

In my model I have to simulate an evacuation from a building (an airport).
At the moment my problem is how to create the building map and how to integrate it in my Repast model. I did't find any tutorial about this and I don't know how to start.

My idea is to use a GIS file, draw the map using the CAD and then covert it in a shape file (I am open to any kind of advice, since I am a real novice with repast).

I found the Nick Malleson's “repastcity”. It is very useful but pretty complex at the same time, I am going to study it. At the moment seems to be the best (probably the only) GIS tutorial for Repast.

Moreover a doubt assails me: I don’t want that my agents can move only along a predetermined footpaths, like the road network in the “repastcity”, rather I want that they move in a random way in the whole building.
Is it possible ? How can I do it ? 

Thank you very much in advance, best. 
Gerardo 

------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are
consuming the most bandwidth. Provides multi-vendor support for NetFlow,
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports.http://sdm.link/zohodev2dev
_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest


------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are
consuming the most bandwidth. Provides multi-vendor support for NetFlow,
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports.http://sdm.link/zohodev2dev
_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest
Reply | Threaded
Open this post in threaded view
|

Re: Integrate a building map in a Repast model - Evacuation Simulation

Gerardo Leo
In reply to this post by Tatara, Eric R.
Hello Eric, thank you very much for your help!

I have already found the Andrew Crooks blog, it is really interesting and useful.
Anyway my problem is more a practical than "conceptual".

I have different ideas on how implement my model and about what I want from it.
The real problem is that, since I am not a software engineer and I am also a novice with java and repast, I don't how to code it..

Actually my first idea was your own, but I don't know how to do it. At the beginning I though to create a map from and image (.pgm, .ppm ...) file or from a text file. My problem is (again) the code. I didn't find any examples or "tutorial" about this topic.

I switched to the GIS idea, at a later stage, thinking that would be easier and faster to draw an airport map using the CAD and then convert it in a shape file.

Best,
Gerardo



Tatara, Eric R. wrote
Andrew Crooks has a really great blog about pedestrian modeling and evacuation models:  http://www.gisagents.org/

I'd look there to get some ideas.  Most of the models highlighted on his site are implemented with NetLogo or Mason, but the modeling concepts would translate similarly into Repast.  My suggestion if you aren't starting with GIS data, then it might be easier to start with a 2D space.  You can implement the walls of a building using a 2D value layer in Repast such that certain values represent walls or restricted areas the agents cannot move into.  Agents will need to see the walls and other agents by querying the space with some defined radius or cone that represents how far the agents can see in some direction.  The movement rules will use the information about the agent's local neighborhood to perform actions like avoiding a wall or following a crowd of other agents.

eric

Eric Tatara, PhD, PE
Software Engineer
Global Security Sciences Division
Argonne National Laboratory
Reply | Threaded
Open this post in threaded view
|

Re: Integrate a building map in a Repast model - Evacuation Simulation

Gerardo Leo
In reply to this post by Grant, Tyler J [NREM]
Hello Tyler, thank you for your reply !

When I started to use repast, after I finished the "jzombies" tutorial, my first idea was to implement a map for that model, in order to allow the agents to move in a building map rather than in a blank space. But I wasn't able to code it.

The consideration about this are almost the same I expressed above.

Best,
Gerardo


Grant, Tyler J [NREM] wrote
The most useful “tutorial” for GIS models is the “Geography” example model distributed with Repast Simphony.  But I’m not sure you want a GIS type of model, you might be better off using a continuous space model like is implemented in the JZombies tutorial.

Dr. Tyler J. Grant
Postdoctoral Associate
Department of Natural Resource Ecology and Management
Iowa State University
339 Science II
Ames, IA 50011
Reply | Threaded
Open this post in threaded view
|

Re: Integrate a building map in a Repast model - Evacuation Simulation

Gerardo Leo
In reply to this post by Fabian Cid
Hi Fabián, thanks a lot for your advice!

My idea is right the one you suggested. Do you have any advice about this ? Can you suggest me some guidance or helpful examples ?

Best,
Gerardo


Fabian Cid wrote
Hi Gerardo
You're right, the best option would be to use a (or many) geography
projection (gis libraries ) for your model.  Maybe one layer for each level
of the building . The movement doesn't have to be constrained to a path,
rather areas can be defined as polygons with barriers and connecting
sections (entrance-exits) .

Good luck

Fabián Cid Yañez
Reply | Threaded
Open this post in threaded view
|

Re: Integrate a building map in a Repast model - Evacuation Simulation

Tatara, Eric R.
In reply to this post by Gerardo Leo
The Repast Sugarscape demo has an example PGM reader that loads a PGM file into a value layer.

eric

Eric Tatara, PhD, PE
Software Engineer
Global Security Sciences Division
Argonne National Laboratory


________________________________________
From: Gerardo Leo [[hidden email]]
Sent: Friday, July 22, 2016 5:19 PM
To: [hidden email]
Subject: Re: [Repast-interest] Integrate a building map in a Repast model -     Evacuation Simulation

Hello Eric, thank you very much for your help!

I have already found the Andrew Crooks blog, it is really interesting and
useful.
Anyway my problem is more a practical than "conceptual".

I have different ideas on how implement my model and about what I want from
it.
The real problem is that, since I am not a software engineer and I am also a
novice with java and repast, I don't how to code it..

Actually my first idea was your own, but I don't know how to do it. At the
beginning I though to create a map from and image (.pgm, .ppm ...) file or
from a text file. My problem is (again) the code. I didn't find any examples
or "tutorial" about this topic.

I switched to the GIS idea, at a later stage, thinking that would be easier
and faster to draw an airport map using the CAD and then convert it in a
shape file.

Best,
Gerardo




Tatara, Eric R. wrote

> Andrew Crooks has a really great blog about pedestrian modeling and
> evacuation models:  http://www.gisagents.org/
>
> I'd look there to get some ideas.  Most of the models highlighted on his
> site are implemented with NetLogo or Mason, but the modeling concepts
> would translate similarly into Repast.  My suggestion if you aren't
> starting with GIS data, then it might be easier to start with a 2D space.
> You can implement the walls of a building using a 2D value layer in Repast
> such that certain values represent walls or restricted areas the agents
> cannot move into.  Agents will need to see the walls and other agents by
> querying the space with some defined radius or cone that represents how
> far the agents can see in some direction.  The movement rules will use the
> information about the agent's local neighborhood to perform actions like
> avoiding a wall or following a crowd of other agents.
>
> eric
>
> Eric Tatara, PhD, PE
> Software Engineer
> Global Security Sciences Division
> Argonne National Laboratory





--
View this message in context: http://repast.10935.n7.nabble.com/Integrate-a-building-map-in-a-Repast-model-Evacuation-Simulation-tp11570p11575.html
Sent from the repast-interest mailing list archive at Nabble.com.

------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are
consuming the most bandwidth. Provides multi-vendor support for NetFlow,
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports.http://sdm.link/zohodev2dev
_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest

------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are
consuming the most bandwidth. Provides multi-vendor support for NetFlow,
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports.http://sdm.link/zohodev2dev
_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest
Reply | Threaded
Open this post in threaded view
|

Re: Integrate a building map in a Repast model - Evacuation Simulation

Gerardo Leo
Thank you !!
And if i would like load a PPM image (in order to load directly a colored picture), what's the difference ?

Thanks,
Gerardo


Tatara, Eric R. wrote
The Repast Sugarscape demo has an example PGM reader that loads a PGM file into a value layer.

eric

Eric Tatara, PhD, PE
Software Engineer
Global Security Sciences Division
Argonne National Laboratory
Reply | Threaded
Open this post in threaded view
|

Re: Integrate a building map in a Repast model - Evacuation Simulation

Tatara, Eric R.
It's very similar.  PGM has a single number for each pixel and PPM has RGB triplet for each pixel (https://en.wikipedia.org/wiki/Netpbm_format).  If you search google for "java ppm reader" there appears to be several examples.


-----Original Message-----
From: Gerardo Leo [mailto:[hidden email]]
Sent: Tuesday, July 26, 2016 8:05 PM
To: [hidden email]
Subject: Re: [Repast-interest] Integrate a building map in a Repast model - Evacuation Simulation

Thank you !!
And if i would like load a PPM image (in order to load directly a colored picture), what's the difference ?

Thanks,
Gerardo



Tatara, Eric R. wrote
> The Repast Sugarscape demo has an example PGM reader that loads a PGM file
> into a value layer.
>
> eric
>
> Eric Tatara, PhD, PE
> Software Engineer
> Global Security Sciences Division
> Argonne National Laboratory





--
View this message in context: http://repast.10935.n7.nabble.com/Integrate-a-building-map-in-a-Repast-model-Evacuation-Simulation-tp11570p11580.html
Sent from the repast-interest mailing list archive at Nabble.com.

------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are
consuming the most bandwidth. Provides multi-vendor support for NetFlow,
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports.http://sdm.link/zohodev2dev
_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest

------------------------------------------------------------------------------
_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest
Reply | Threaded
Open this post in threaded view
|

Re: Integrate a building map in a Repast model - Evacuation Simulation

Gerardo Leo
I am trying to implement a map in the jZombies model.
What do I need to change ?
The PGMReader is the same I guess, then I need to create a new space class (like the SugarSpace class) and  "link" it with the human and zombies classes and with the context builder. Right ?

Which part of the code do I need to change in these classes ?

Once again, thank you.
Gerardo

Tatara, Eric R. wrote
It's very similar.  PGM has a single number for each pixel and PPM has RGB triplet for each pixel (https://en.wikipedia.org/wiki/Netpbm_format).  If you search google for "java ppm reader" there appears to be several examples.
Reply | Threaded
Open this post in threaded view
|

Re: Integrate a building map in a Repast model - Evacuation Simulation

Tatara, Eric R.
I don't recommend following the SugarScape model directly because it is more complex than needs to be (it was a conversion of an earlier version model).  However, you will need to create a GridValueLayer in your ContextBuilder similar to how it's done in the SugarSpace class and assign the values from the file.

You can put the following in your ContextBuilder class:

GridValueLayer mySpace = new GridValueLayer("MySpace",true, new WrapAroundBorders(), xdim, ydim);

context.addValueLayer(mySpace)

PGMReader reader = new PGMReader(myFile);
int matrix[][] = reader.getMatrix();

for (int x = 0; x < xdim; x++) {
        for (int y = 0; y < ydim; y++) {    
                mySpace.set(matrix[x][y], x,y);
        }
}

And also be sure to update the context.xml file accordingly:

<projection id="MySpace" type="value layer" />


Eric Tatara, PhD, PE
Software Engineer
Global Security Sciences Division
Argonne National Laboratory


________________________________________
From: Gerardo Leo [[hidden email]]
Sent: Friday, July 29, 2016 2:40 AM
To: [hidden email]
Subject: Re: [Repast-interest] Integrate a building map in a Repast model -     Evacuation Simulation

I am trying to implement a map in the jZombies model.
What do I need to change ?
The PGMReader is the same I guess, then I need to create a new space class
(like the SugarSpace class) and  "link" it with the human and zombies
classes and with the context builder. Right ?

Which part of the code do I need to change in these classes ?

Once again, thank you.
Gerardo


Tatara, Eric R. wrote
> It's very similar.  PGM has a single number for each pixel and PPM has RGB
> triplet for each pixel (https://en.wikipedia.org/wiki/Netpbm_format).  If
> you search google for "java ppm reader" there appears to be several
> examples.





--
View this message in context: http://repast.10935.n7.nabble.com/Integrate-a-building-map-in-a-Repast-model-Evacuation-Simulation-tp11570p11587.html
Sent from the repast-interest mailing list archive at Nabble.com.

------------------------------------------------------------------------------
_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest

------------------------------------------------------------------------------
_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest
Reply | Threaded
Open this post in threaded view
|

Re: Integrate a building map in a Repast model - Evacuation Simulation

Gerardo Leo
I have already extrapolated that part of the code from the SugarScape model and I tried to insert it in the jzombie model as you suggested, but doesn't work. The model runs, but it still shows the toroidal space and doesn't charge the map.
I also tried adding a new display using the grid projection (like the SugarScape model), it's the same.

I guess I need to update the human and zombie code, right ? How ?

Thank you very much.
Gerardo

Tatara, Eric R. wrote
I don't recommend following the SugarScape model directly because it is more complex than needs to be (it was a conversion of an earlier version model).  However, you will need to create a GridValueLayer in your ContextBuilder similar to how it's done in the SugarSpace class and assign the values from the file.

You can put the following in your ContextBuilder class:

GridValueLayer mySpace = new GridValueLayer("MySpace",true, new WrapAroundBorders(), xdim, ydim);

context.addValueLayer(mySpace)

PGMReader reader = new PGMReader(myFile);
int matrix[][] = reader.getMatrix();

for (int x = 0; x < xdim; x++) {
        for (int y = 0; y < ydim; y++) {    
                mySpace.set(matrix[x][y], x,y);
        }
}

And also be sure to update the context.xml file accordingly:

<projection id="MySpace" type="value layer" />


Eric Tatara, PhD, PE
Software Engineer
Global Security Sciences Division
Argonne National Laboratory
Reply | Threaded
Open this post in threaded view
|

Re: Integrate a building map in a Repast model - Evacuation Simulation

Tatara, Eric R.
Have you added the value layer to the display also?  It won't appear otherwise.

Eric Tatara, PhD, PE
Software Engineer
Global Security Sciences Division
Argonne National Laboratory


________________________________________
From: Gerardo Leo [[hidden email]]
Sent: Tuesday, August 02, 2016 11:30 PM
To: [hidden email]
Subject: Re: [Repast-interest] Integrate a building map in a Repast model -     Evacuation Simulation

I have already extrapolated that part of the code from the SugarScape model
and I tried to insert it in the jzombie model as you suggested, but doesn't
work. The model runs, but it still shows the toroidal space and doesn't
charge the map.
I also tried adding a new display using the grid projection (like the
SugarScape model), it's the same.

I guess I need to update the human and zombie code, right ? How ?

Thank you very much.
Gerardo


Tatara, Eric R. wrote

> I don't recommend following the SugarScape model directly because it is
> more complex than needs to be (it was a conversion of an earlier version
> model).  However, you will need to create a GridValueLayer in your
> ContextBuilder similar to how it's done in the SugarSpace class and assign
> the values from the file.
>
> You can put the following in your ContextBuilder class:
>
> GridValueLayer mySpace = new GridValueLayer("MySpace",true, new
> WrapAroundBorders(), xdim, ydim);
>
> context.addValueLayer(mySpace)
>
> PGMReader reader = new PGMReader(myFile);
> int matrix[][] = reader.getMatrix();
>
> for (int x = 0; x < xdim; x++) {
>       for (int y = 0; y < ydim; y++) {
>               mySpace.set(matrix[x][y], x,y);
>       }
> }
>
> And also be sure to update the context.xml file accordingly:
> <projection id="MySpace" type="value layer" />
>
> Eric Tatara, PhD, PE
> Software Engineer
> Global Security Sciences Division
> Argonne National Laboratory





--
View this message in context: http://repast.10935.n7.nabble.com/Integrate-a-building-map-in-a-Repast-model-Evacuation-Simulation-tp11570p11604.html
Sent from the repast-interest mailing list archive at Nabble.com.

------------------------------------------------------------------------------
_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest

------------------------------------------------------------------------------
_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest
Reply | Threaded
Open this post in threaded view
|

Re: Integrate a building map in a Repast model - Evacuation Simulation

Gerardo Leo
In reply to this post by Tatara, Eric R.
Yes I did it, but doesn't work. The model runs but the map is not charged.

Thank you.
Gerardo


Tatara, Eric R. wrote
I don't recommend following the SugarScape model directly because it is more complex than needs to be (it was a conversion of an earlier version model).  However, you will need to create a GridValueLayer in your ContextBuilder similar to how it's done in the SugarSpace class and assign the values from the file.

You can put the following in your ContextBuilder class:

GridValueLayer mySpace = new GridValueLayer("MySpace",true, new WrapAroundBorders(), xdim, ydim);

context.addValueLayer(mySpace)

PGMReader reader = new PGMReader(myFile);
int matrix[][] = reader.getMatrix();

for (int x = 0; x < xdim; x++) {
        for (int y = 0; y < ydim; y++) {    
                mySpace.set(matrix[x][y], x,y);
        }
}

And also be sure to update the context.xml file accordingly:

<projection id="MySpace" type="value layer" />
Reply | Threaded
Open this post in threaded view
|

Re: Integrate a building map in a Repast model - Evacuation Simulation

Tatara, Eric R.
OK I'd recommend the following:

1.  Verify the value layer is available to agents and has data.  You can for example just have an agent access a value layer position and read the value and compare it to the known value at that position.  This will indicate if the value layer is setup and populated correctly.

2.  Are you using a 2D display?  Try a 2D display with only a value layer.  The value layer styling can be done either by using the style editor in the display wizard like in the Autocatalysis demo, or by using a style class like in the Sugarscape demo (SurfaceStyle2D.java).  I recommend trying to use a style class first rather than the style editor since it's more intuitive in terms of matching the display colors to the values in the value layer.  The Sugarscape SurfaceStyle2D returns various shades of yellow-orange in a color map based on expected integer values in the range [0,4].    If you have a discrete number of values in your value layer, your could try this approach, or try rounding the double value returned from the value layer and picking the color from a map.  

An alternative is to directly convert the value layer double value to an RGB info and return a color based on some predetermined min and max values for values in the layer.  This is essentially what the value layer style editor does if you take that approach, but again I find it easier to define a map of colors against a range of values rather than trying to directly map the value to RGB values in a color.

Eric Tatara, PhD, PE
Software Engineer
Global Security Sciences Division
Argonne National Laboratory


________________________________________
From: Gerardo Leo [[hidden email]]
Sent: Thursday, August 04, 2016 4:07 PM
To: [hidden email]
Subject: Re: [Repast-interest] Integrate a building map in a Repast model -     Evacuation Simulation

Yes I did it, but doesn't work. The model runs but the map is not charged.

Thank you.
Gerardo



Tatara, Eric R. wrote

> I don't recommend following the SugarScape model directly because it is
> more complex than needs to be (it was a conversion of an earlier version
> model).  However, you will need to create a GridValueLayer in your
> ContextBuilder similar to how it's done in the SugarSpace class and assign
> the values from the file.
>
> You can put the following in your ContextBuilder class:
>
> GridValueLayer mySpace = new GridValueLayer("MySpace",true, new
> WrapAroundBorders(), xdim, ydim);
>
> context.addValueLayer(mySpace)
>
> PGMReader reader = new PGMReader(myFile);
> int matrix[][] = reader.getMatrix();
>
> for (int x = 0; x < xdim; x++) {
>       for (int y = 0; y < ydim; y++) {
>               mySpace.set(matrix[x][y], x,y);
>       }
> }
>
> And also be sure to update the context.xml file accordingly:
> <projection id="MySpace" type="value layer" />





--
View this message in context: http://repast.10935.n7.nabble.com/Integrate-a-building-map-in-a-Repast-model-Evacuation-Simulation-tp11570p11612.html
Sent from the repast-interest mailing list archive at Nabble.com.

------------------------------------------------------------------------------
_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest

------------------------------------------------------------------------------
_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest
Reply | Threaded
Open this post in threaded view
|

Re: Integrate a building map in a Repast model - Evacuation Simulation

Gerardo Leo
This post was updated on .
Hello Eric,

sorry for the late reply, but I took some days off.

I had already used the style class (like the one in the sugarscape model), you are right it is much more intuitive, anyway the problem was still present.
Checking the code I found out that there were some errors in the parameters .xml file and in the display .xml file, I fixed them and now the map has been charged properly and the model runs.

Now, I want that the agent could not cross the the walls but just the doors.
I guess the easiest way is to use an "if-else" statement.

For example, in the .pgm file 1 is the wall (not crossable) and 0 the empty space (crossable), and moveTowards() the agents movement method:

  if ( cell[i] == 1 )
 {moveTowards() = false;
 }
  else if ( cell[i] == 0 )
 {moveTowards() = true;
 }

Of course cell[i] and moveTowards() in the code above are wrong, how do I fix it ?
                   
Where do I need to insert this code ? In the context builder or in the agent classes ?

Thank you very much.
Gerardo Leo



Tatara, Eric R. wrote
OK I'd recommend the following:

1.  Verify the value layer is available to agents and has data.  You can for example just have an agent access a value layer position and read the value and compare it to the known value at that position.  This will indicate if the value layer is setup and populated correctly.

2.  Are you using a 2D display?  Try a 2D display with only a value layer.  The value layer styling can be done either by using the style editor in the display wizard like in the Autocatalysis demo, or by using a style class like in the Sugarscape demo (SurfaceStyle2D.java).  I recommend trying to use a style class first rather than the style editor since it's more intuitive in terms of matching the display colors to the values in the value layer.  The Sugarscape SurfaceStyle2D returns various shades of yellow-orange in a color map based on expected integer values in the range [0,4].    If you have a discrete number of values in your value layer, your could try this approach, or try rounding the double value returned from the value layer and picking the color from a map.  

An alternative is to directly convert the value layer double value to an RGB info and return a color based on some predetermined min and max values for values in the layer.  This is essentially what the value layer style editor does if you take that approach, but again I find it easier to define a map of colors against a range of values rather than trying to directly map the value to RGB values in a color.

Eric Tatara, PhD, PE
Software Engineer
Global Security Sciences Division
Argonne National Laboratory