-
Notifications
You must be signed in to change notification settings - Fork 99
RoadTrafficModel_step4
The present model will introduce how to design a road system, or graph, based on the road GIS data and provide each edge a weight
representing the destruction level of the road.
- Add a
destruction_coeff
variable to theroad
agent. The value of this variable is higher or equal to 1 or lower or equal to 2. At initialization, the value of this variable is randomly defined between 1 and 2. - In the road network graph, more a road is worn out (
destruction_coeff
high), more apeople
agent takes time to go all over it. Then the value of the arc representing the road in the graph is equal to "length of the road*
destruction_coeff". - The color of the road depends on the
destruction_coeff
. If "destruction_coeff = 1", the road is green, if "destruction_coeff = 2", the road is red.
We add a destruction_coeff
variable which initial value is randomly defined between 1 and 2 and which have a max of 2. The color of the agent will depend on this variable. In order to simplify the GAML code, we define a new variable colorValue
that represents the value of red color and that will be defined between 0 and 255.
species road {
float destruction_coeff <- rnd(1.0,2.0) max: 2.0;
int colorValue <- int(255*(destruction_coeff - 1)) update: int(255*(destruction_coeff - 1));
rgb color <- rgb(min([255, colorValue]),max ([0, 255 - colorValue]),0) update: rgb(min([255, colorValue]),max ([0, 255 - colorValue]),0) ;
...
}
In GAMA, adding a weight for a graph is very simple, we use the with_weights
operator with the graph for left-operand and a weight map for the right-operand. The weight map contains the weight of each edge: [edge1::weight1, edge2:: weight2,...]. In this model, the weight will be equal to the length of the road (perimeter of the polyline) its destruction coefficient.
init {
...
create road from: shape_file_roads ;
map<road,float> weights_map <- road as_map (each:: (each.destruction_coeff * each.shape.perimeter));
the_graph <- as_edge_graph(road) with_weights weights_map;
...
}
https://github.com/gama-platform/gama/blob/GAMA_1.9.2/msi.gama.models/models/Tutorials/Road%20Traffic/models/Model%2004.gaml
- Installation and Launching
- Workspace, Projects and Models
- Editing Models
- Running Experiments
- Running Headless
- Preferences
- Troubleshooting
- Introduction
- Manipulate basic Species
- Global Species
- Defining Advanced Species
- Defining GUI Experiment
- Exploring Models
- Optimizing Model Section
- Multi-Paradigm Modeling
- Manipulate OSM Data
- Diffusion
- Using Database
- Using FIPA ACL
- Using BDI with BEN
- Using Driving Skill
- Manipulate dates
- Manipulate lights
- Using comodel
- Save and restore Simulations
- Using network
- Headless mode
- Using Headless
- Writing Unit Tests
- Ensure model's reproducibility
- Going further with extensions
- Built-in Species
- Built-in Skills
- Built-in Architecture
- Statements
- Data Type
- File Type
- Expressions
- Exhaustive list of GAMA Keywords
- Installing the GIT version
- Developing Extensions
- Introduction to GAMA Java API
- Using GAMA flags
- Creating a release of GAMA
- Documentation generation