我有一个出租车的 NetLogo 模型,可以接载乘客并将他们带到目的地。我目前对出租车品种的定义如下:
taxis-own [
route ; List of destinations in order, each an x y pair
destin_x ; Coordinates of the taxis current destination
destin_y
trip_distance ; Distance of current trip in Netlogo cells = 100 meters
speed ; Travel speed in Netlogo cells = 100 meters per minute
time_left ; Time left in current trip until arrival
status ; Waiting ; Picking Up ; Psngr Boarding; En Route ; Psngr Alighting ; Dropping off
vmt ; Vehicle miles traveled
]
destin_x和destin_y分别是出租车当前目的地的x 和y 坐标。
我想在每辆出租车中存储一条路线,或每辆出租车的目的地列表。即[[x1 y1],[x2 y2][x3 y3]...]。
代理可以拥有这样的列表结构吗?我可以在代理的询问命令中使用列表命令,例如lput吗?有没有解决这个问题的替代方法?
到目前为止,我这样做的尝试没有奏效。见下文:
to hail-taxi ;
let available-taxis taxis with [status = "waiting"] ; Create a set of available taxis
let hailing-psngrs psngrs with [status = "hailing"] ; Create list of hailing passengers
foreach sort-by [ [wait_time] of ?1 > [wait_time] of ?2] hailing-psngrs [
ask ? [
let free-taxi min-one-of available-taxis [distance myself] ; Find the closest available taxi
let picked-taxi free-taxi
if ( picked-taxi != nobody )[
set status "waiting"
create-link-with picked-taxi
ask picked-taxi [
set status "picking up"
set available-taxis taxis with [status = "waiting"] ; Revise set of available taxis
; NEXT LINE DOES NOT WORK
lput list ( [xcor] of myself [ycor] of myself ) route
]
]
]
]
结尾