到目前为止,这是一个非常简单的模型。我希望助行器能够移动到补丁,但不是随机移动到现在但是有可能。在这种情况下,列表“优先级”描述了每个补丁(二手车)的概率。
所以我的问题是:如何实现移动声明的计算优先级?
以下是代码:
breed [nodes node]
breed [walkers walker]
globals [
cost
time
wellbeing
efficiency
vec1
vec2
vec3
nodelist
; rain
]
walkers-own [
Temp_best ;aim temp
capital ; capital for each timestep to invest in transportation
adaptation
location
priority
delta-priority
] ;; holds a node
patches-own [
]
to setup
clear-all
set-default-shape nodes "circle"
;; create a random network
create-nodes 1 [ set color white ]
create-nodes 1 [ set color blue ] ;car
create-nodes 1 [ set color yellow ] ;bike
create-nodes 1 [ set color green ] ;public transportation
ask node 0 [ create-link-with node 1 ]
ask node 0 [ create-link-with node 2 ]
ask node 0 [ create-link-with node 3 ]
;; lay it out so links are not overlapping
repeat 500 [ layout ]
;; leave space around the edges
ask nodes [ setxy 0.95 * xcor 0.95 * ycor ]
;; put some "walker" turtles on the network
create-walkers 1 [
set color red
set location node 0
move-to location
]
reset-ticks
ask walkers [
set capital 5
set adaptation 0.1
set wellbeing n-values 3 [0]
set priority n-values 3 [0] ;sum of all must be 1
set delta-priority n-values 3 [0] ;sum of all must be 0
set efficiency n-values 3 [0]
]
set cost [3.5 1 0.1]
set time [0.3 0.6 0.7]
set vec1 [0.7 0.7 0.7] ;if change one, than also the other --> sum must be 1
set vec2 [0.3 0.3 0.3] ;
set vec3 [1 1 1]
ask walkers[
output-print wellbeing
]
set cost (map * cost vec1)
set time (map * time vec2)
ask walkers[
output-print cost
output-print time
]
ask walkers [
set wellbeing (map + cost time)
set wellbeing (map / vec3 wellbeing) ;devided by 1 to have a high number for wellbeing
set priority [0 0.1 0.9]
; set priority (map + priority delta-priority)
if rain? [
set priority replace-item 2 priority 0
set priority replace-item 1 priority (1 - item 0 priority + item 2 priority)
]
]
ask walkers[
output-print wellbeing
output-print priority
]
;set efficiency replace-item 1 efficiency (wellbeing 1 / )
set efficiency (map / wellbeing cost)
output-print efficiency
;end
;to calculate
;ask walker[
;set delta-priority replace-item 0 delta-priority ( adaptation * item 0 priority * ((item 0 wellbeing) - ) - ((item 1 priority * item 1 wellbeing)+(item 2 priority * item 2 wellbeing)))
; set priority replace-item 0 priority (priority 0 + delta-priority 0)
;set priority replace-item 1 priority (priority 1 + delta-priority 1)
;set priority replace-item 2 priority (priority 2 + delta-priority 2)
; set priority (map + priority delta-priority)
;ifelse wellbeing 2 > wellbeing 1
; output-print delta-priority
; ]
end
to layout
layout-spring nodes links 0.5 2 1
end
to go
ask links [ set thickness 0 ]
ask walkers [
let new-location one-of nodes ;i want to introduce the priority for each node
;one-of [link-neighbors] of location
;; change the thickness of the link I just crossed over
;ask [link-with new-location] of location [ set thickness 0.5 ]
face new-location ;; not strictly necessary, but improves the visuals a bit
move-to new-location
set location new-location
]
tick
ask nodes
[show count walkers-here]
end