在我的毕业设计项目中,我正在调查办公楼的住户用电量。当到达办公室时,他们可以离开办公桌做其他活动(例如午餐,会议,洗手间)。每个人在上班和回家时都有自己的时间。 我想要的是,占用者确定他们何时离开工作台,在上班和回家之间随机分配。
to go
if time = 0 [start-day]
ask occupants [
let $currenttime hour-of-day
ifelse (go-to-office-today AND (workDays = "M-F" AND (Day >= 0) AND (Day
<= 4) AND ($currenttime * 100 >= workStartHour ) AND ($currenttime * 100
<= workEndHour - 100 )))
[if (not atWork?) [GoWork] ]
[if (atWork?) [GoHome] ]
if go-to-office-today and workschedule-next < length workschedule [
let workschedule-item item workschedule-next workschedule
]]
tick
to start-day
ask occupants [ set schedule-next 0
set go-to-office-today false
]
let $Occupancy-Percentage (50 + random 0)
ask n-of( int ($Occupancy-Percentage / 100 * count occupants)) occupants [
set go-to-office-today true
set workschedule [ ]
]
DetermineWorkSchedule
setMeetingSchedule
end
现在我只有一个固定值列表。但我想要几个正常分布在workstarthour和workendhour之间(例如10到90个刻度)
去洗手间频率将是4次然后我希望列表是工作日程[15 28 51 73]
to DetermineWorkSchedule
ask occupants [
let lunchtime [ ]
set lunchtime lput precision (random-normal 12 1 ) 0 lunchtime
set workschedule lput one-of lunchtime workschedule
let toilettime []
set toilettime lput precision (random-normal 15 2) 0 toilettime
set workschedule lput one-of toilettime workschedule
end
答案 0 :(得分:1)
由于您现在声称只需要两个端点之间的n
随机值而没有任何分布式约束,您可以这样做:
to-report transition-times [#n #start #end]
let _possible n-values (#end - #start + 1) [#start + ?]
report sort n-of #n _possible
end
这将为您提供[#start,#end]中的值 - 即包括#start和#end。 (根据品味调整。)值被限制为唯一。