Skip to content

Commit

Permalink
last update
Browse files Browse the repository at this point in the history
  • Loading branch information
griffy committed Dec 15, 2011
1 parent fdb7e1e commit af30fad
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 12 deletions.
5 changes: 5 additions & 0 deletions elevator.py
Expand Up @@ -165,6 +165,7 @@
class Elevator(object):
def __init__(self, type_):
self.type = type_
self.num_passengers = 0
if self.type = TYPE_F:
self.capacity = 11
elif self.type = TYPE_L:
Expand All @@ -190,6 +191,10 @@ def pick_floor(self, time):
elif afternoon_end < time <= evening_end:
return distrs[self.type]['evening']()

# TODO
def service_time(self, time):
return self.idle_time(time) + self.busy_time(time) + ...

def idle_time(self, time):
if self.type == TYPE_F:
morning_end = 6*60*60 # 11am
Expand Down
9 changes: 8 additions & 1 deletion elevator_group.py
Expand Up @@ -5,4 +5,11 @@ def __init__(self, type_, count):
self.type = type_
self.count = count
self.elevators = [Elevator(type_) for i in range(count)]
self.in_period = True
self.in_period = False
self.already_created = False
self.pool = 0

def create_passengers(self):
if not self.already_created:
# TODO
pass
20 changes: 9 additions & 11 deletions elevatorsim.py
Expand Up @@ -14,10 +14,10 @@ def __init__(self, time, group, index):

class ElevatorSystem(System):
def initialize(self):
self.elevator_groups = [ElevatorGroup(elevator.TYPE_F, 3),
self.elevator_groups = [ElevatorGroup(elevator.TYPE_F, 2),
ElevatorGroup(elevator.TYPE_L, 3),
ElevatorGroup(elevator.TYPE_I, 3),
ElevatorGroup(elevator.TYPE_E, 3)]
ElevatorGroup(elevator.TYPE_I, 1),
ElevatorGroup(elevator.TYPE_E, 2)]
time = 0
for elevator_group in self.elevator_groups:
# schedule arrival of all elevators at time 0
Expand All @@ -43,17 +43,15 @@ def handle(self, event):
elevator.num_passengers = group.pool
group.pool = 0
# schedule next arrival

cur_time = self.clock.time()
service_time = elevator.service_time(cur_time)
time = cur_time + service_time
self.schedule_event(ElevatorArriveEvent(time, group, index))
else:
# TODO
# schedule next arrival
# schedule next arrival at beginning of next 5 min period
pass

self.stats.num_passengers = rand.poisson(5, 1)
self.stats.floor_selected = self.elevators[0].pick_floor(self.clock.time())
self.schedule_event(PassengerDepartEvent(event.time+1))
elif isinstance(event, PassengerDepartEvent):
self.schedule_event(PassengerArriveEvent(event.time+5))




Expand Down

0 comments on commit af30fad

Please sign in to comment.