diff --git a/simtools.gaml.extensions.traffic/models/Driving Skill/models/Drive Random.gaml b/simtools.gaml.extensions.traffic/models/Driving Skill/models/Advanced models/Drive Random.gaml similarity index 95% rename from simtools.gaml.extensions.traffic/models/Driving Skill/models/Drive Random.gaml rename to simtools.gaml.extensions.traffic/models/Driving Skill/models/Advanced models/Drive Random.gaml index 41a86a0f99..cec456240f 100644 --- a/simtools.gaml.extensions.traffic/models/Driving Skill/models/Drive Random.gaml +++ b/simtools.gaml.extensions.traffic/models/Driving Skill/models/Advanced models/Drive Random.gaml @@ -15,8 +15,8 @@ global { float step <- 0.2#s; string map_name; - file shp_roads <- file("../includes/" + map_name + "/roads.shp"); - file shp_nodes <- file("../includes/" + map_name + "/nodes.shp"); + file shp_roads <- file("../../includes/" + map_name + "/roads.shp"); + file shp_nodes <- file("../../includes/" + map_name + "/nodes.shp"); geometry shape <- envelope(shp_roads) + 50; diff --git a/simtools.gaml.extensions.traffic/models/Driving Skill/models/Following Paths.gaml b/simtools.gaml.extensions.traffic/models/Driving Skill/models/Advanced models/Following Paths.gaml similarity index 93% rename from simtools.gaml.extensions.traffic/models/Driving Skill/models/Following Paths.gaml rename to simtools.gaml.extensions.traffic/models/Driving Skill/models/Advanced models/Following Paths.gaml index 554f535716..c686357ad1 100644 --- a/simtools.gaml.extensions.traffic/models/Driving Skill/models/Following Paths.gaml +++ b/simtools.gaml.extensions.traffic/models/Driving Skill/models/Advanced models/Following Paths.gaml @@ -15,8 +15,8 @@ global { float step <- 0.1 #s; string map_name <- "rouen"; - file shp_roads <- file("../includes/" + map_name + "/roads.shp"); - file shp_nodes <- file("../includes/" + map_name + "/nodes.shp"); + file shp_roads <- file("../../includes/" + map_name + "/roads.shp"); + file shp_nodes <- file("../../includes/" + map_name + "/nodes.shp"); geometry shape <- envelope(shp_roads) + 50; diff --git a/simtools.gaml.extensions.traffic/models/Driving Skill/models/Simple Intersection.gaml b/simtools.gaml.extensions.traffic/models/Driving Skill/models/Advanced models/Simple Intersection.gaml similarity index 100% rename from simtools.gaml.extensions.traffic/models/Driving Skill/models/Simple Intersection.gaml rename to simtools.gaml.extensions.traffic/models/Driving Skill/models/Advanced models/Simple Intersection.gaml diff --git a/simtools.gaml.extensions.traffic/models/Driving Skill/models/Traffic.gaml b/simtools.gaml.extensions.traffic/models/Driving Skill/models/Advanced models/Traffic.gaml similarity index 100% rename from simtools.gaml.extensions.traffic/models/Driving Skill/models/Traffic.gaml rename to simtools.gaml.extensions.traffic/models/Driving Skill/models/Advanced models/Traffic.gaml diff --git a/simtools.gaml.extensions.traffic/models/Driving Skill/models/Simple model/Simple Traffic Model.gaml b/simtools.gaml.extensions.traffic/models/Driving Skill/models/Simple model/Simple Traffic Model.gaml new file mode 100644 index 0000000000..dba1dc6fe3 --- /dev/null +++ b/simtools.gaml.extensions.traffic/models/Driving Skill/models/Simple model/Simple Traffic Model.gaml @@ -0,0 +1,75 @@ +/** +* Name: Traffic +* Description: define species for traffic simulation +* Author: Patrick Taillandier & Duc Pham +* Tags: driving skill, graph, agent_movement, skill, transport +*/ + +model simple_traffic_model + +global { + shape_file nodes_shape_file <- shape_file("../../includes/rouen/nodes.shp"); + shape_file roads_shape_file <- shape_file("../../includes/rouen/roads.shp"); + + geometry shape <- envelope(roads_shape_file); + graph road_network; + init { + create intersection from: nodes_shape_file; + + create road from: roads_shape_file { + // Create another road in the opposite direction + create road { + num_lanes <- myself.num_lanes; + shape <- polyline(reverse(myself.shape.points)); + maxspeed <- myself.maxspeed; + linked_road <- myself; + myself.linked_road <- self; + } + } + + + road_network <- as_driving_graph(road, intersection); + + create vehicle number: 1000 with: (location: one_of(intersection).location); + } + +} + +species road skills: [skill_road] { + rgb color <- #white; + + aspect base { + draw shape color: color end_arrow: 1; + } +} + +species intersection skills: [skill_road_node] ; + +species vehicle skills: [advanced_driving] { + rgb color <- rnd_color(255); + init { + vehicle_length <- 1.9 #m; + max_speed <- 100 #km / #h; + max_acceleration <- 3.5; + } + + reflex select_next_path when: current_path = nil { + // A path that forms a cycle + do compute_path graph: road_network target: one_of(intersection); + } + + reflex commute when: current_path != nil { + do drive; + } + aspect base { + draw triangle(5.0) color: color rotate: heading + 90 border: #black; + } +} + +experiment city type: gui { + output { + display map type: opengl background: #gray synchronized: true { + species road aspect: base; + species vehicle aspect: base; } + } +} \ No newline at end of file diff --git a/simtools.gaml.extensions.traffic/models/Driving Skill/models/OSM Loading Driving.gaml b/simtools.gaml.extensions.traffic/models/Driving Skill/models/Utilities/OSM Loading Driving.gaml similarity index 97% rename from simtools.gaml.extensions.traffic/models/Driving Skill/models/OSM Loading Driving.gaml rename to simtools.gaml.extensions.traffic/models/Driving Skill/models/Utilities/OSM Loading Driving.gaml index c7ffe82afb..508f31f982 100644 --- a/simtools.gaml.extensions.traffic/models/Driving Skill/models/OSM Loading Driving.gaml +++ b/simtools.gaml.extensions.traffic/models/Driving Skill/models/Utilities/OSM Loading Driving.gaml @@ -14,7 +14,7 @@ global{ map filtering <- map(["highway"::["primary", "secondary", "tertiary", "motorway", "living_street","residential", "unclassified"]]); //OSM file to load - file osmfile <- file(osm_file("../includes/rouen.gz", filtering)) ; + file osmfile <- file(osm_file("../../includes/rouen.gz", filtering)) ; geometry shape <- envelope(osmfile); graph the_graph;