forked from Pouria-Nazemi/Elevator-Scheduling
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplanning.py
48 lines (48 loc) · 1.83 KB
/
planning.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# from Graphic_Interface import elevators
# # elevators = []
# #
# # elevator1 = elevator(name=1,head= 0)# staticList=[2, 5, 6, 1, 12])
# # elevator2 = elevator(name=2, head=8)
# # elevator3 = elevator(name=3, head=12,)# staticList=[3, 4])
# #
# # elevators.append(elevator1)
# # elevators.append(elevator2)
# # elevators.append(elevator3)
#
#
# def inputElePlan(floor):
# minDistance = 100
# for eachElevator in elevators:
# distance = 0
# if (floor - eachElevator.head) < 0:
#
# if eachElevator.direction == "DOWN" or eachElevator.direction == "both":
# distance = abs(floor - eachElevator.head)
# elif eachElevator.direction == "UP":
# distance = (eachElevator.up[-1] - eachElevator.head) * 2 + abs(floor - eachElevator.head)
#
# elif (floor - eachElevator.head) > 0:
# if eachElevator.direction == "UP" or eachElevator.direction == "both":
# distance = floor - eachElevator.head
# elif eachElevator.direction == "DOWN":
# print(eachElevator.name + " check")
# distance = (eachElevator.head - eachElevator.down[-1]) * 2 + floor - eachElevator.head
#
# if (minDistance > distance):
# minDistance = distance
# choosenElevator = eachElevator
#
# print(choosenElevator.name)
# choosenElevator.addInput(floor)
# for eachElevator in elevators:
# print("head of " + str(eachElevator.name) + " head: " + str(
# eachElevator.head) + " direction " + eachElevator.direction)
# print(str(choosenElevator.name) + str(" floor:* ") + str(floor) + "\n")
#
#
# def getStatus(elevators):
# for elevator in elevators:
# print("head of " + str(elevator.name) + " head: " + str(elevator.head) + " direction " + elevator.direction)
#
#
# # inputElePlan(15)