Christus
Christus

Reputation: 3

Netlogo random values for list bounded by values

For my graduation project I am investigating the electricity consumption of occupants in officebuildings. Occupants when arriving at office they can leave their work desk doing other activities (e.g. lunch, meetings, restroom). Each occupant has his own time when going to office and when going home. What I want is that occupants determine when they leave workdesk randomly distributed between going to office and going home.

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

now i have only one fixed value for the list. But i want several normally distributed between workstarthour and workendhour (e.g between 10 and 90 ticks)

to go to restroom frequencie will be 4 times then i want the list to be workschedule [ 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

Upvotes: 0

Views: 119

Answers (1)

Alan
Alan

Reputation: 9620

Since you now say you just want a n stochastic values between two endpoints without any distributional constraint, you could do this:

to-report transition-times [#n #start #end]
  let _possible n-values (#end - #start + 1) [#start + ?]
  report sort n-of #n _possible
end

This will give you values in [#start,#end] -- that is, including #start and #end. (Adjust to taste.) Values are constrained to be unique.

Upvotes: 1

Related Questions