Hi everyone!
I have tried all the solutions that you gave me in these days.
I have written this code...but the cars don't move from their position.
I report all the code below:
extensions [ gis nw csv]
;; *** GLOBALS ***
globals [
gridDataset
node-data
link-data
area
city2
prf
max-speed
refused
charge-error
num-unloaded
tot-journey
service-journey
empty-journey
mean-poll
]
;; *** BREEDS ***
breed [ employees employee ]
breed [ shuttles shuttle ]
breed [ buses bus ]
breed [ destinations a-destination ]
breed [ resident-drivers resident-driver ]
breed [ recorder record ]
breed [ el-vehicles el-vehicle ]
breed [ el-stations el-station ]
breed [customers customer ]
breed [parking-lots parking-lot ]
breed [ nodes node ]
breed [ nlabels nlabel ]
;; *** ATTRIBUTES ***
nodes-own [
isStop
isType
speedlimit
car-to-public
]
links-own [
linkLength
traffic
tramline
velmax
pollution
]
employees-own [
transport-type
destination
sec-destination
place
travel-time
waiting-time
actual-time
late
status
activity-time
nodeList
onlyNodes
onlyNodes-sec
ride-from-home
satisfaction
disposed
mode
initial-destination
start-timestamp
end-timestamp
]
shuttles-own [
tratta
direction
destination
nodeList
onlyNodes
place
waiting
]
buses-own [
tratta
direction
destination
nodeList
onlyNodes
place
waiting
]
resident-drivers-own [
destination
place
status
road-type
nodeList
onlyNodes
late
fueltype
emissions
emissions-gasoline
emissions-diesel
emissions-GPL
]
el-vehicles-own [
tratta
onlyNodes
nodeList
place
depot
destination
charge
discharged
charge-time
parking-search
parked
MC ML MI MP MS
CM CI CL CZ CS
IC IP IM IS IL
PH PS PM PC PL
SP SL SM SC SI
LM LS LC LI LP
]
recorder-own [
which-agent
time-taken
transport-type
waiting-spent
travel-spent
satisfaction
disposed
]
;; *** SETUP ***
to setup
ca
reset-ticks
ask patches [ set pcolor 66 ]
let grid true
if nameOfGrid = "" [ set grid false ]
load-gisdata grid
map-gisdata grid
ask nodes [
set speedLimit 0
if IsStop = 1 [
set color 52
set size 8
]
]
ask links [
ifelse tramline = 1 or tramline = 3 [
set color yellow
set thickness 3
]
[
set thickness 1
set color black
]
ask one-of links [
let placeholder velmax
let a end1
let b end2
ask a [
if speedLimit = 0 [
set speedLimit placeholder
]
]
ask b [
if speedLimit = 0 [
set speedLimit placeholder
]
]
]
]
ifelse station-airport?
[ let linkPath []
let nodePath []
ask node 219 [
nw:set-context nodes links
set linkPath nw:weighted-path-to node 98 linklength
nw:set-context nodes links
set nodePath nw:turtles-on-weighted-path-to node 98 linklength
]
foreach linkPath [ x -> ask x [ set color violet set tramline 4 set thickness 3 set traffic 2 ] ]
foreach nodePath [ x -> ask x [ set isType 4 ] ]
ask first nodePath [
set color orange
set size 6
set isStop 1
]
ask last nodePath [
set color orange
set size 6
set isStop 1
]
]
[ ]
create-recorder 1
ask recorder [
setxy -300 -240
set size 20
set shape "box"
set color brown
set which-agent []
set time-taken []
set transport-type []
set waiting-spent []
set travel-spent []
set satisfaction []
set disposed []
]
reset-ticks
add-el-stations
add-parking-lots
add-el-vehicles
end
;; *** GISDATA ***
to load-gisdata [ readGrid ]
;set variables for datasets
set node-data gis:load-dataset ("Punti26aprile.shp" )
set link-data gis:load-dataset ("Linee26aprile.shp" )
set area gis:load-dataset ("acqua.shp")
set city2 gis:load-dataset ("city2.shp")
set prf gis:load-dataset ("prf.shp")
;_____________________________________________________________________________________________________________________________________________________
;##################################################### IMPORTANT: DEFINE PATH ########################################################################
if readGrid [ set gridDataset gis:load-dataset word "your_path" ( word nameOfGrid ".asc") ]
;again, a grid file can be specified here
;#####################################################################################################################################################
;set extent
ifelse readGrid [
gis:set-world-envelope (gis:envelope-union-of (gis:envelope-of gridDataset)
(gis:envelope-of node-data)
(gis:envelope-of link-data))
][
;bugfixing envelope. to small -> nodes could be created out of world extent
let envNodes [] foreach gis:envelope-of node-data [ ?1 -> set envNodes lput ( ?1 + 0.00001 ) envNodes ]
gis:set-world-envelope (gis:envelope-union-of (envNodes)
(gis:envelope-of link-data))
]
end
;; ***MAP GISDATA ***
to map-gisdata [ displayGrid ]
;draw grid
if displayGrid [ gis:paint gridDataset 0 ]
;draw nodes
let nodescount 0
foreach gis:feature-list-of node-data [ ?1 -> ;iterate over all features
let loc gis:location-of (first(first(gis:vertex-lists-of ?1))) ;get location of feature...
let stopTram gis:property-value ?1 nameofStop ;get length of feature
let stopType gis:property-value ?1 nameType ;get type of feature
let feat ?1
create-nodes 1[
set xcor item 0 loc ;..and put the node at the same location
set ycor item 1 loc
set shape "circle"
set color red
set size 0.5
set isStop stopTram
set isType stopType
]
]
;generate and draw links for routing
foreach gis:feature-list-of link-data[ ?1 -> ;iterate over all features
let agent1 gis:property-value ?1 nameOfStartNode
let agent2 gis:property-value ?1 nameOfEndNode
let shapeLength gis:property-value ?1 nameoflengthfield ;get length of feature
let traffictype gis:property-value ?1 nameTrafficType ;get traffic type of feature (either cars only or tram and cars)
let tramNumber gis:property-value ?1 nameTramLine ;get tram line of feature (either line 1, line 3 or no line)
let speed gis:property-value ?1 nameSpeed ;get the maximum allowed speed of feature
ask nodes with [who = agent1] [
create-link-with node agent2 [
set linkLength shapeLength
set traffic traffictype
set tramline tramNumber
set velmax speed
]
]
;create the links
]
end
to add-el-stations
set-default-shape el-stations "house"
create-el-stations 6 [
set color blue
set size 10
set label who ;; give me informations indicating the number of el-station
]
(foreach (list (el-station 262) (el-station 263) (el-station 264) (el-station 265) (el-station 266) (el-station 267))
(list (node 98) (node 75) (node 51) (node 189) (node 210) (node 218))
[[the-el-station the-node] -> ask the-el-station [move-to the-node]])
end
to add-parking-lots
ask el-stations [
hatch-parking-lots num-parking-lots
[set hidden? true]
]
end
to el-vehicles-defaults
set color orange
set shape "car"
set size 20
set parked 1
set charge (el-vehicle-range)
end
to add-el-vehicles
ask el-station 262 [hatch-el-vehicles num-el-vehicles[
set depot 1
el-vehicles-defaults]
]
ask el-station 263 [hatch-el-vehicles num-el-vehicles[
set depot 2
el-vehicles-defaults]
]
ask el-station 264 [hatch-el-vehicles num-el-vehicles[
set depot 3
el-vehicles-defaults]
]
ask el-station 265 [hatch-el-vehicles num-el-vehicles[
set depot 4
el-vehicles-defaults]
]
ask el-station 266 [hatch-el-vehicles num-el-vehicles[
set depot 5
el-vehicles-defaults]
]
ask el-station 267 [hatch-el-vehicles num-el-vehicles[
set depot 6
el-vehicles-defaults]
]
end
to go
el-vehicle-charge
create-trip
parking-trip
;;design-trip
tick
end
to el-vehicle-charge
ask el-vehicles with [discharged = 1][
set color red
set charge-time charge-time + 1
if charge-time >= ((maximum-charge-time * 42)*(el-vehicle-range - charge)/(el-vehicle-range) )
[
set discharged 0
set charge-time 0
set color green
set charge (el-vehicle-range)]]
end
to create-trip
set-default-shape customers "person"
if random (42 / demand-probability) = 0 [
create-customers 1 [set size 4]
ask customers [
move-to one-of el-stations
ifelse count el-vehicles-here with [(discharged = 0) and (parking-search = 0) and (parked = 1)] != 0
[ask one-of el-vehicles-here with [(discharged = 0) and (parking-search = 0) and (parked = 1)][
if depot = 1 [set destination one-of [2 3 4 5 6]]
if depot = 2 [set destination one-of [1 3 4 5 6]]
if depot = 3 [set destination one-of [1 2 4 5 6]]
if depot = 4 [set destination one-of [1 2 3 5 6]]
if depot = 5 [set destination one-of [1 2 3 4 6]]
if depot = 6 [set destination one-of [1 2 3 4 5]]
set parked 0
start]
die]
[set refused refused + 1
die]
]]
end
to start
(ifelse
depot = 1 and destination = 2 [Mi-Ce]
depot = 1 and destination = 3 [Mi-In]
depot = 1 and destination = 4 [Mi-Pe]
depot = 1 and destination = 5 [Mi-Sa]
depot = 1 and destination = 6 [Mi-Li]
depot = 2 and destination = 1 [Ce-Mi]
depot = 2 and destination = 3 [Ce-In]
depot = 2 and destination = 4 [Ce-Pe]
depot = 2 and destination = 5 [Ce-Sa]
depot = 2 and destination = 6 [Ce-Li]
depot = 3 and destination = 1 [In-Mi]
depot = 3 and destination = 2 [In-Ce]
depot = 3 and destination = 4 [In-Pe]
depot = 3 and destination = 5 [In-Sa]
depot = 3 and destination = 6 [In-Li]
depot = 4 and destination = 1 [Pe-Mi]
depot = 4 and destination = 2 [Pe-Ce]
depot = 4 and destination = 3 [Pe-In]
depot = 4 and destination = 5 [Pe-Sa]
depot = 4 and destination = 6 [Pe-Li]
depot = 5 and destination = 1 [Sa-Mi]
depot = 5 and destination = 2 [Sa-Ce]
depot = 5 and destination = 3 [Sa-In]
depot = 5 and destination = 4 [Sa-Pe]
depot = 5 and destination = 6 [Sa-Li]
depot = 6 and destination = 1 [Li-Mi]
depot = 6 and destination = 2 [Li-Ce]
depot = 6 and destination = 3 [Li-In]
depot = 6 and destination = 4 [Li-Pe]
[Li-Sa])
end
to design-trip
ask el-vehicles[
if MC > 0 [Mi-Ce]
if ML > 0 [Mi-Li]
if MI > 0 [Mi-In]
if MP > 0 [Mi-Pe]
if MS > 0 [Mi-Sa]
if CM > 0 [Ce-Mi]
if CI > 0 [Ce-In]
if CZ > 0 [Ce-Pe]
if CS > 0 [Ce-Sa]
if CL > 0 [Ce-Li]
if IC > 0 [In-Ce]
if IP > 0 [In-Pe]
if IM > 0 [In-Mi]
if IS > 0 [In-Sa]
if IL > 0 [In-Li]
if PH > 0 [Pe-In]
if PS > 0 [Pe-Sa]
if PM > 0 [Pe-Mi]
if PC > 0 [Pe-Ce]
if PL > 0 [Pe-Li]
if SP > 0 [Sa-Pe]
if SL > 0 [Sa-Li]
if SM > 0 [Sa-Mi]
if SC > 0 [Sa-Ce]
if SI > 0 [Sa-In]
if LS > 0 [Li-Sa]
if LM > 0 [Li-Mi]
if LI > 0 [Li-In]
if LP > 0 [Li-Pe]
if LC > 0 [Li-Ce]]
end
to parking-trip
ask el-vehicles with [parking-search = 1][
set color white
set parking-search 0
if depot = 1 [
(ifelse
count el-vehicles-on el-station 263 < count parking-lots-on el-station 263 [
set destination 2
Mi-Ce]
count el-vehicles-on el-station 264 < count parking-lots-on el-station 264 and
count el-vehicles-on el-station 263 >= count parking-lots-on el-station 263 [
set destination 3
Mi-In]
count el-vehicles-on el-station 265 < count parking-lots-on el-station 265 and
count el-vehicles-on el-station 264 >= count parking-lots-on el-station 264 and
count el-vehicles-on el-station 263 >= count parking-lots-on el-station 263 [
set destination 4
Mi-Pe]
count el-vehicles-on el-station 266 < count parking-lots-on el-station 266 and
count el-vehicles-on el-station 265 >= count parking-lots-on el-station 265 and
count el-vehicles-on el-station 264 >= count parking-lots-on el-station 264 and
count el-vehicles-on el-station 263 >= count parking-lots-on el-station 263 [
set destination 4
Mi-Sa]
[set destination 6
Mi-Li])
]
if depot = 2 [
(ifelse
count el-vehicles-on el-station 264 < count parking-lots-on el-station 264 [
set destination 3
Ce-In]
count el-vehicles-on el-station 265 < count parking-lots-on el-station 265 and
count el-vehicles-on el-station 264 >= count parking-lots-on el-station 264 [
set destination 4
Ce-Pe]
count el-vehicles-on el-station 266 < count parking-lots-on el-station 266 and
count el-vehicles-on el-station 265 >= count parking-lots-on el-station 265 and
count el-vehicles-on el-station 264 >= count parking-lots-on el-station 264 [
set destination 5
Ce-Sa]
count el-vehicles-on el-station 267 < count parking-lots-on el-station 267 and
count el-vehicles-on el-station 266 >= count parking-lots-on el-station 266 and
count el-vehicles-on el-station 265 >= count parking-lots-on el-station 265 and
count el-vehicles-on el-station 264 >= count parking-lots-on el-station 264 [
set destination 6
Ce-Li]
[set destination 1
Ce-Mi])
]
if depot = 3 [
(ifelse
count el-vehicles-on el-station 265 < count parking-lots-on el-station 265 [
set destination 4
In-Pe]
count el-vehicles-on el-station 266 < count parking-lots-on el-station 266 and
count el-vehicles-on el-station 265 >= count parking-lots-on el-station 265 [
set destination 5
In-Sa]
count el-vehicles-on el-station 267 < count parking-lots-on el-station 267 and
count el-vehicles-on el-station 266 >= count parking-lots-on el-station 266 and
count el-vehicles-on el-station 265 >= count parking-lots-on el-station 265 [
set destination 6
In-Li]
count el-vehicles-on el-station 262 < count parking-lots-on el-station 262 and
count el-vehicles-on el-station 267 >= count parking-lots-on el-station 267 and
count el-vehicles-on el-station 266 >= count parking-lots-on el-station 266 and
count el-vehicles-on el-station 265 >= count parking-lots-on el-station 265 [
set destination 1
In-Mi]
[set destination 2
In-Ce])
]
if depot = 4 [
(ifelse
count el-vehicles-on el-station 266 < count parking-lots-on el-station 266 [
set destination 5
Pe-Sa]
count el-vehicles-on el-station 267 < count parking-lots-on el-station 267 and
count el-vehicles-on el-station 266 >= count parking-lots-on el-station 266 [
set destination 6
Pe-Li]
count el-vehicles-on el-station 262 < count parking-lots-on el-station 262 and
count el-vehicles-on el-station 267 >= count parking-lots-on el-station 267 and
count el-vehicles-on el-station 266 >= count parking-lots-on el-station 266 [
set destination 1
Pe-Mi]
count el-vehicles-on el-station 263 < count parking-lots-on el-station 263 and
count el-vehicles-on el-station 262 >= count parking-lots-on el-station 262 and
count el-vehicles-on el-station 267 >= count parking-lots-on el-station 267 and
count el-vehicles-on el-station 266 >= count parking-lots-on el-station 266 [
set destination 2
Pe-Ce]
[set destination 3
Pe-In])
]
if depot = 5 [
(ifelse
count el-vehicles-on el-station 267 < count parking-lots-on el-station 267 [
set destination 6
Sa-Li]
count el-vehicles-on el-station 262 < count parking-lots-on el-station 262 and
count el-vehicles-on el-station 267 >= count parking-lots-on el-station 267 [
set destination 1
Sa-Mi]
count el-vehicles-on el-station 263 < count parking-lots-on el-station 263 and
count el-vehicles-on el-station 262 >= count parking-lots-on el-station 262 and
count el-vehicles-on el-station 267 >= count parking-lots-on el-station 267 [
set destination 2
Sa-Ce]
count el-vehicles-on el-station 264 < count parking-lots-on el-station 264 and
count el-vehicles-on el-station 263 >= count parking-lots-on el-station 263 and
count el-vehicles-on el-station 262 >= count parking-lots-on el-station 262 and
count el-vehicles-on el-station 267 >= count parking-lots-on el-station 267 [
set destination 3
Sa-In]
[set destination 4
Sa-Pe])
]
if depot = 6 [
(ifelse
count el-vehicles-on el-station 262 < count parking-lots-on el-station 262 [
set destination 1
Li-Mi]
count el-vehicles-on el-station 263 < count parking-lots-on el-station 263 and
count el-vehicles-on el-station 262 >= count parking-lots-on el-station 262 [
set destination 2
Li-Ce]
count el-vehicles-on el-station 264 < count parking-lots-on el-station 264 and
count el-vehicles-on el-station 263 >= count parking-lots-on el-station 263 and
count el-vehicles-on el-station 262 >= count parking-lots-on el-station 262 [
set destination 3
Li-In]
count el-vehicles-on el-station 265 < count parking-lots-on el-station 265 and
count el-vehicles-on el-station 264 >= count parking-lots-on el-station 264 and
count el-vehicles-on el-station 263 >= count parking-lots-on el-station 263 and
count el-vehicles-on el-station 262 >= count parking-lots-on el-station 262 [
set destination 4
Li-Pe]
[set destination 5
Li-Sa])
]]
end
to end-process
set tot-journey tot-journey + 1
if color = white [set empty-journey empty-journey + 1]
if color = green [set service-journey service-journey + 1]
if charge <= 0 [set charge-error charge-error + 1]
set color green
ifelse count el-vehicles-here > count parking-lots-here
[set parking-search 1]
[set parked 1]
if (charge < critical-threshold) and (parked = 1)[
set discharged 1
set num-unloaded num-unloaded + 1]
end
to Mi-Ce
ask el-vehicles with [depot = 1]
[
if distance el-station 263 = 0
[ set MC 0
set depot 2
set charge charge - 1.97
end-process
stop
]
pen-down
face node-MC
ifelse distance node-MC < 1
[ move-to node-MC set MC MC + 1] ;gv is updated only once the current target vertex is reached
[ fd 1 ]
]
end
to-report node-MC
(ifelse
MC < 5 [ report node 83 ]
MC < 10 [ report node 82 ]
MC < 15 [ report node 81 ]
MC < 20 [ report node 79 ]
MC < 25 [ report node 78 ]
MC < 30 [ report node 77 ][report el-station 263] )
end
to Mi-In
ask el-vehicles with [depot = 1]
[
if distance el-station 264 = 0
[ set MI 0
set depot 3
set charge charge - 1.97
end-process
stop
]
pen-down
face node-MI
ifelse distance node-MI < 1
[ move-to node-MI set MI MI + 1] ;gv is updated only once the current target vertex is reached
[ fd 1 ]
]
end
to-report node-MI
(ifelse
MI < 5 [ report node 83 ]
MI < 10 [ report node 82 ]
MI < 15 [ report node 81 ]
MI < 20 [ report node 79 ]
MI < 25 [ report node 78 ]
MI < 30 [ report node 77 ][report el-station 264] )
end
to Mi-Pe
ask el-vehicles with [depot = 1]
[
if distance el-station 265 = 0
[ set MP 0
set depot 4
set charge charge - 1.97
end-process
stop
]
pen-down
face node-MP
ifelse distance node-MP < 1
[ move-to node-MP set MP MP + 1] ;gv is updated only once the current target vertex is reached
[ fd 1 ]
]
end
to-report node-MP
(ifelse
MP < 5 [ report node 83 ]
MP < 10 [ report node 82 ]
MP < 15 [ report node 81 ]
MP < 20 [ report node 79 ]
MP < 25 [ report node 78 ]
MP < 30 [ report node 77 ][report el-station 265] )
end
to Mi-Sa
ask el-vehicles with [depot = 1]
[
if distance el-station 266 = 0
[ set MS 0
set depot 5
set charge charge - 1.97
end-process
stop
]
pen-down
face node-MS
ifelse distance node-MS < 1
[ move-to node-MS set MS MS + 1] ;gv is updated only once the current target vertex is reached
[ fd 1 ]
]
end
to-report node-MS
(ifelse
MS < 5 [ report node 83 ]
MS < 10 [ report node 82 ]
MS < 15 [ report node 81 ]
MS < 20 [ report node 79 ]
MS < 25 [ report node 78 ]
MS < 30 [ report node 77 ][report el-station 266] )
end
to Mi-Li
ask el-vehicles with [depot = 1]
[
if distance el-station 267 = 0
[ set ML 0
set depot 6
set charge charge - 1.97
end-process
stop
]
pen-down
face node-ML
ifelse distance node-ML < 1
[ move-to node-ML set ML ML + 1] ;gv is updated only once the current target vertex is reached
[ fd 1 ]
]
end
to-report node-ML
(ifelse
ML < 5 [ report node 83 ]
ML < 10 [ report node 82 ]
ML < 15 [ report node 81 ]
ML < 20 [ report node 79 ]
ML < 25 [ report node 78 ]
ML < 30 [ report node 77 ][report el-station 267] )
end
to Ce-Mi
ask el-vehicles with [depot = 2]
[
if distance el-station 262 = 0
[ set CM 0
set depot 1
set charge charge - 1.97
end-process
stop
]
pen-down
face node-CM
ifelse distance node-CM < 1
[ move-to node-CM set CM CM + 1] ;gv is updated only once the current target vertex is reached
[ fd 1 ]
]
end
to-report node-CM
(ifelse
CM < 5 [ report node 77 ]
CM < 10 [ report node 78 ]
CM < 15 [ report node 79 ]
CM < 20 [ report node 81 ]
CM < 25 [ report node 82 ]
CM < 30 [ report node 83 ][report el-station 262] )
end
to Ce-In
ask el-vehicles with [depot = 2]
[
if distance el-station 264 = 0
[ set CI 0
set depot 3
set charge charge - 1.97
end-process
stop
]
pen-down
face node-CI
ifelse distance node-CI < 1
[ move-to node-CI set CI CI + 1]
[ fd 1 ]
]
end
to-report node-CI
(ifelse
CI < 5 [ report node 74 ]
CI < 10 [ report node 73 ]
CI < 15 [ report node 72 ]
CI < 20 [ report node 69 ]
CI < 25 [ report node 67 ]
CI < 30 [ report node 66 ]
CI < 35 [ report node 65 ]
CI < 40 [ report node 63 ]
CI < 30 [ report node 62 ][report el-station 264] )
end
to Ce-Pe
ask el-vehicles with [depot = 2]
[
if distance el-station 265 = 0
[ set CZ 0
set depot 4
set charge charge - 1.97
end-process
stop
]
pen-down
face node-CZ
ifelse distance node-CZ < 1
[ move-to node-CZ set CZ CZ + 1]
[ fd 1 ]
]
end
to-report node-CZ
(ifelse
CZ < 5 [ report node 74 ]
CZ < 10 [ report node 73 ]
CZ < 15 [ report node 72 ]
CZ < 20 [ report node 69 ]
CZ < 25 [ report node 67 ]
CZ < 30 [ report node 66 ]
CZ < 35 [ report node 65 ]
CZ < 40 [ report node 63 ]
CZ < 30 [ report node 62 ][report el-station 265] )
end
to Ce-Sa
ask el-vehicles with [depot = 2]
[
if distance el-station 266 = 0
[ set CS 0
set depot 5
set charge charge - 1.97
end-process
stop
]
pen-down
face node-CS
ifelse distance node-CS < 1
[ move-to node-CS set CS CS + 1]
[ fd 1 ]
]
end
to-report node-CS
(ifelse
CS < 5 [ report node 74 ]
CS < 10 [ report node 73 ]
CS < 15 [ report node 72 ]
CS < 20 [ report node 69 ]
CS < 25 [ report node 67 ]
CS < 30 [ report node 66 ]
CS < 35 [ report node 65 ]
CS < 40 [ report node 63 ]
CS < 30 [ report node 62 ][report el-station 266] )
end
to Ce-Li
ask el-vehicles with [depot = 2]
[
if distance el-station 267 = 0
[ set CL 0
set depot 6
set charge charge - 1.97
end-process
stop
]
pen-down
face node-CL
ifelse distance node-CL < 1
[ move-to node-CL set CL CL + 1]
[ fd 1 ]
]
end
to-report node-CL
(ifelse
CL < 5 [ report node 74 ]
CL < 10 [ report node 73 ]
CL < 15 [ report node 72 ]
CL < 20 [ report node 69 ]
CL < 25 [ report node 67 ]
CL < 30 [ report node 66 ]
CL < 35 [ report node 65 ]
CL < 40 [ report node 63 ]
CL < 30 [ report node 62 ][report el-station 267] )
end
to In-Ce
ask el-vehicles with [depot = 3]
[
if distance el-station 263 = 0
[ set IC 0
set depot 2
set charge charge - 1.97
end-process
stop
]
pen-down
face node-IC
ifelse distance node-IC < 1
[ move-to node-IC set IC IC + 1]
[ fd 1 ]
]
end
to-report node-IC
(ifelse
IC < 5 [ report node 62 ]
IC < 10 [ report node 63 ]
IC < 15 [ report node 64 ]
IC < 20 [ report node 65 ]
IC < 25 [ report node 66 ]
IC < 30 [ report node 67 ]
IC < 35 [ report node 69 ]
IC < 40 [ report node 71 ]
IC < 45 [ report node 72 ]
IC < 50 [ report node 73 ]
IC < 55 [ report node 74 ][report el-station 263] )
end
to In-Mi
ask el-vehicles with [depot = 3]
[
if distance el-station 262 = 0
[ set IM 0
set depot 1
set charge charge - 1.97
end-process
stop
]
pen-down
face node-IM
ifelse distance node-IM < 1
[ move-to node-IM set IM IM + 1]
[ fd 1 ]
]
end
to-report node-IM
(ifelse
IC < 5 [ report node 62 ]
IC < 10 [ report node 63 ]
IC < 15 [ report node 64 ]
IC < 20 [ report node 65 ]
IC < 25 [ report node 66 ]
IC < 30 [ report node 67 ]
IC < 35 [ report node 69 ]
IC < 40 [ report node 71 ]
IC < 45 [ report node 72 ]
IC < 50 [ report node 73 ]
IC < 55 [ report node 74 ][report el-station 262] )
end
to In-Pe
ask el-vehicles with [depot = 3]
[
if distance el-station 265 = 0
[ set IP 0
set depot 4
set charge charge - 1.97
end-process
stop
]
pen-down
face node-IP
ifelse distance node-IP < 1
[ move-to node-IP set IP IP + 1]
[ fd 1 ]
]
end
to-report node-IP
(ifelse
IP < 5 [ report node 48 ]
IP < 10 [ report node 47 ][report el-station 265] )
end
to In-Sa
ask el-vehicles with [depot = 3]
[
if distance el-station 266 = 0
[ set IS 0
set depot 5
set charge charge - 1.97
end-process
stop
]
pen-down
face node-IS
ifelse distance node-IS < 1
[ move-to node-IS set IS IS + 1]
[ fd 1 ]
]
end
to-report node-IS
(ifelse
IP < 5 [ report node 48 ]
IP < 10 [ report node 47 ][report el-station 266] )
end
to In-Li
ask el-vehicles with [depot = 3]
[
if distance el-station 267 = 0
[ set IL 0
set depot 6
set charge charge - 1.97
end-process
stop
]
pen-down
face node-IL
ifelse distance node-IL < 1
[ move-to node-IL set IL IL + 1]
[ fd 1 ]
]
end
to-report node-IL
(ifelse
IL < 5 [ report node 48 ]
IL < 10 [ report node 47 ][report el-station 267] )
end
to Pe-In
ask el-vehicles with [depot = 4]
[
if distance el-station 264 = 0
[ set PH 0
set depot 3
set charge charge - 1.97
end-process
stop
]
pen-down
face node-PH
ifelse distance node-PH < 1
[ move-to node-PH set PH PH + 1]
[ fd 1 ]
]
end
to-report node-PH
(ifelse
PH < 5 [ report node 46 ]
PH < 10 [ report node 47 ]
PH < 15 [ report node 48 ]
PH < 20 [ report node 50 ][report el-station 264] )
end
to Pe-Ce
ask el-vehicles with [depot = 4]
[
if distance el-station 263 = 0
[ set PC 0
set depot 2
set charge charge - 1.97
end-process
stop
]
pen-down
face node-PC
ifelse distance node-PC < 1
[ move-to node-PC set PC PC + 1]
[ fd 1 ]
]
end
to-report node-PC
(ifelse
PC < 5 [ report node 46 ]
PC < 10 [ report node 47 ]
PC < 15 [ report node 48 ]
PC < 20 [ report node 50 ][report el-station 263] )
end
to Pe-Mi
ask el-vehicles with [depot = 4]
[
if distance el-station 262 = 0
[ set PM 0
set depot 1
set charge charge - 1.97
end-process
stop
]
pen-down
face node-PM
ifelse distance node-PM < 1
[ move-to node-PM set PM PM + 1]
[ fd 1 ]
]
end
to-report node-PM
(ifelse
PM < 5 [ report node 46 ]
PM < 10 [ report node 47 ]
PM < 15 [ report node 48 ]
PM < 20 [ report node 50 ][report el-station 262] )
end
to Pe-Sa
ask el-vehicles with [depot = 4]
[
if distance el-station 266 = 0
[ set PS 0
set depot 5
set charge charge - 1.97
end-process
stop
]
pen-down
face node-PS
ifelse distance node-PS < 1
[ move-to node-PS set PS PS + 1]
[ fd 1 ]
]
end
to-report node-PS
(ifelse
PS < 5 [ report node 260 ]
PS < 10 [ report node 183 ]
PS < 15 [ report node 194 ]
PS < 20 [ report node 195 ]
PS < 25 [ report node 178 ]
PS < 25 [ report node 198 ]
PS < 30 [ report node 199 ]
PS < 35 [ report node 200 ]
PS < 40 [ report node 202 ]
PS < 45 [ report node 204 ]
PS < 50 [ report node 205 ]
PS < 45 [ report node 206 ]
PS < 50 [ report node 208 ][report el-station 266] )
end
to Pe-Li
ask el-vehicles with [depot = 4]
[
if distance el-station 267 = 0
[ set PL 0
set depot 6
set charge charge - 1.97
end-process
stop
]
pen-down
face node-PL
ifelse distance node-PL < 1
[ move-to node-PL set PL PL + 1]
[ fd 1 ]
]
end
to-report node-PL
(ifelse
PL < 5 [ report node 260 ]
PL < 10 [ report node 183 ]
PL < 15 [ report node 194 ]
PL < 20 [ report node 195 ]
PL < 25 [ report node 178 ]
PL < 25 [ report node 198 ]
PL < 30 [ report node 199 ]
PL < 35 [ report node 200 ]
PL < 40 [ report node 202 ]
PL < 45 [ report node 204 ]
PL < 50 [ report node 205 ]
PL < 45 [ report node 206 ]
PL < 50 [ report node 208 ][report el-station 267] )
end
to Sa-Li
ask el-vehicles with [depot = 5]
[
if distance el-station 267 = 0
[ set SL 0
set depot 6
set charge charge - 1.97
end-process
stop
]
pen-down
face node-SL
ifelse distance node-SL < 1
[ move-to node-SL set SL SL + 1]
[ fd 1 ]
]
end
to-report node-SL
(ifelse
SL < 5 [ report node 211 ]
SL < 10 [ report node 212 ]
SL < 15 [ report node 213 ]
SL < 20 [ report node 214 ]
SL < 25 [ report node 215 ]
SL < 30 [ report node 216 ]
SL < 35 [ report node 217 ][report el-station 267] )
end
to Sa-Pe
ask el-vehicles with [depot = 5]
[
if distance el-station 265 = 0
[ set SP 0
set depot 4
set charge charge - 1.97
end-process
stop
]
pen-down
face node-SP
ifelse distance node-SP < 1
[ move-to node-SP set SP SP + 1]
[ fd 1 ]
]
end
to-report node-SP
(ifelse
SP < 5 [ report node 209 ]
SP < 10 [ report node 208 ]
SP < 15 [ report node 207 ]
SP < 35 [ report node 206 ]
SP < 40 [ report node 205 ]
SP < 45 [ report node 204 ]
SP < 50 [ report node 202 ]
SP < 55 [ report node 200 ]
SP < 60 [ report node 199 ]
SP < 65 [ report node 195 ][report el-station 265] )
end
to Sa-In
ask el-vehicles with [depot = 5]
[
if distance el-station 264 = 0
[ set SI 0
set depot 3
set charge charge - 1.97
end-process
stop
]
pen-down
face node-SI
ifelse distance node-SI < 1
[ move-to node-SI set SI SI + 1]
[ fd 1 ]
]
end
to-report node-SI
(ifelse
SI < 5 [ report node 209 ]
SI < 10 [ report node 208 ]
SI < 15 [ report node 207 ]
SI < 35 [ report node 206 ]
SI < 40 [ report node 205 ]
SI < 45 [ report node 204 ]
SI < 50 [ report node 202 ]
SI < 55 [ report node 200 ]
SI < 60 [ report node 199 ]
SI < 65 [ report node 195 ][report el-station 264] )
end
to Sa-Ce
ask el-vehicles with [depot = 5]
[
if distance el-station 263 = 0
[ set SC 0
set depot 2
set charge charge - 1.97
end-process
stop
]
pen-down
face node-SC
ifelse distance node-SC < 1
[ move-to node-SC set SC SC + 1]
[ fd 1 ]
]
end
to-report node-SC
(ifelse
SC < 5 [ report node 209 ]
SC < 10 [ report node 208 ]
SC < 15 [ report node 207 ]
SC < 35 [ report node 206 ]
SC < 40 [ report node 205 ]
SC < 45 [ report node 204 ]
SC < 50 [ report node 202 ]
SC < 55 [ report node 200 ]
SC < 60 [ report node 199 ]
SC < 65 [ report node 195 ][report el-station 263] )
end
to Sa-Mi
ask el-vehicles with [depot = 5]
[
if distance el-station 262 = 0
[ set SM 0
set depot 1
set charge charge - 1.97
end-process
stop
]
pen-down
face node-SM
ifelse distance node-SM < 1
[ move-to node-SM set SM SM + 1]
[ fd 1 ]
]
end
to-report node-SM
(ifelse
SM < 5 [ report node 209 ]
SM < 10 [ report node 208 ]
SM < 15 [ report node 207 ]
SM < 35 [ report node 206 ]
SM < 40 [ report node 205 ]
SM < 45 [ report node 204 ]
SM < 50 [ report node 202 ]
SM < 55 [ report node 200 ]
SM < 60 [ report node 199 ]
SM < 65 [ report node 195 ][report el-station 262] )
end
to Li-Mi
ask el-vehicles with [depot = 6]
[
if distance el-station 262 = 0
[ set LM 0
set depot 1
set charge charge - 1.97
end-process
stop
]
pen-down
face node-LM
ifelse distance node-LM < 1
[ move-to node-LM set LM LM + 1]
[ fd 1 ]
]
end
to-report node-LM
(ifelse
LM < 5 [ report node 246 ]
LM < 10 [ report node 245 ]
LM < 15 [ report node 244 ]
LM < 35 [ report node 243 ]
LM < 40 [ report node 231 ]
LM < 45 [ report node 130 ]
LM < 50 [ report node 129 ]
LM < 55 [ report node 128 ]
LM < 60 [ report node 105 ]
LM < 65 [ report node 86 ]
LM < 70 [ report node 85 ]
LM < 75 [ report node 84 ][report el-station 262] )
end
to Li-Sa
ask el-vehicles with [depot = 6]
[
if distance el-station 266 = 0
[ set LS 0
set depot 5
set charge charge - 1.97
end-process
stop
]
pen-down
face node-LS
ifelse distance node-LS < 1
[ move-to node-LS set LS LS + 1]
[ fd 1 ]
]
end
to-report node-LS
(ifelse
LS < 5 [ report node 217 ]
LS < 10 [ report node 216 ]
LS < 15 [ report node 215 ]
LS < 35 [ report node 214 ]
LS < 40 [ report node 213 ]
LS < 45 [ report node 212 ]
LS < 50 [ report node 211 ][report el-station 266] )
end
to Li-Pe
ask el-vehicles with [depot = 6]
[
if distance el-station 265 = 0
[ set LP 0
set depot 4
set charge charge - 1.97
end-process
stop
]
pen-down
face node-LP
ifelse distance node-LP < 1
[ move-to node-LP set LP LP + 1]
[ fd 1 ]
]
end
to-report node-LP
(ifelse
LP < 5 [ report node 217 ]
LP < 10 [ report node 216 ]
LP < 15 [ report node 215 ]
LP < 35 [ report node 214 ]
LP < 40 [ report node 213 ]
LP < 45 [ report node 212 ]
LP < 50 [ report node 211 ][report el-station 265] )
end
to Li-In
ask el-vehicles with [depot = 6]
[
if distance el-station 264 = 0
[ set LI 0
set depot 3
set charge charge - 1.97
end-process
stop
]
pen-down
face node-LI
ifelse distance node-LI < 1
[ move-to node-LI set LI LI + 1]
[ fd 1 ]
]
end
to-report node-LI
(ifelse
LI < 5 [ report node 217 ]
LI < 10 [ report node 216 ]
LI < 15 [ report node 215 ]
LI < 35 [ report node 214 ]
LI < 40 [ report node 213 ]
LI < 45 [ report node 212 ]
LI < 50 [ report node 211 ][report el-station 264] )
end
to Li-Ce
ask el-vehicles with [depot = 6]
[
if distance el-station 263 = 0
[ set LC 0
set depot 2
set charge charge - 1.97
end-process
stop
]
pen-down
face node-LC
ifelse distance node-LC < 1
[ move-to node-LC set LC LC + 1]
[ fd 1 ]
]
end
to-report node-LC
(ifelse
LC < 5 [ report node 217 ]
LC < 10 [ report node 216 ]
LC < 15 [ report node 215 ]
LC < 35 [ report node 214 ]
LC < 40 [ report node 213 ]
LC < 45 [ report node 212 ]
LC < 50 [ report node 211 ][report el-station 263] )
end
It could be more simple with my gis map.
I attach to this email also a figure of my map, tu understand what I need to do.
I hope someone can help me.