-
Notifications
You must be signed in to change notification settings - Fork 0
/
Arcs.py
86 lines (69 loc) · 1.76 KB
/
Arcs.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
from Itinerary import Itinerary
from Arc import Arc
from Nodes import SinkNode, EndNode, StartNode
class ConnectionArc(Arc): #Intermediate Waiting Arc (Connection)
count = 0
def __init__(self,endNode,startNode):
assert endNode.__class__ == EndNode
assert startNode.__class__ == StartNode
self.i = endNode
self.j = startNode
ConnectionArc.count += 1
def cost(self):
return self.j.t - self.i.t + 30
def available(self,num):
return num
def reduce(self,num):
pass
class TripStartArc(Arc): #Itinerary Arrival Arc
count = 0
def __init__(self,itinNode, startNode):
assert itinNode.__class__ == Itinerary
assert startNode.__class__ == StartNode
self.i = itinNode
self.j = startNode
TripStartArc.count += 1
def cost(self):
return self.j.t - self.i.t
def available(self, num):
return num
def reduce(self,num):
pass
class TripEndArc(Arc): #Itinerary End Arc
count = 0
def __init__(self,endNode, sinkNode):
assert sinkNode.__class__ == SinkNode
assert endNode.__class__ == EndNode
self.i = endNode
self.j = sinkNode
TripEndArc.count += 1
def cost(self):
return 0
def available(self, num):
return num
def reduce(self,num):
pass
class NextDayArc(Arc): #Next-Day Flight Arc
count = 0
used = 0
def __init__(self,itinNode,sinkNode):
assert itinNode.__class__ == Itinerary
assert sinkNode.__class__ == SinkNode
self.i = itinNode
self.j = sinkNode
NextDayArc.count += 1
def cost(self):
waitCost = 24*60
return waitCost + self.i.schedCost()
def costBreakdown(self):
tc = self.i.ff.cost()
wc = 24*60
cc = 0
if self.i.sf != None:
tc += self.i.sf.cost()
cc += self.i.sf.i.t - self.i.ff.j.t + 30
return tc, wc, cc
def available(self,num):
return num
def reduce(self, num):
NextDayArc.used += num