受值限制的列表的 Netlogo 随机值

Netlogo random values for list bounded by values

在我的毕业设计中,我正在调查办公楼中居住者的用电量。乘员到达办公室后,可以离开办公桌进行其他活动(例如午餐、会议、洗手间)。每个居住者都有自己的上下班时间。 我想要的是居住者决定他们何时离开办公桌,随机分布在去办公室和回家之间。

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 ticks 之间)

去洗手间的频率将是 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

既然你现在说你只想要两个端点之间的 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。 (根据口味进行调整。)值被限制为唯一。