| 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 |
import java.io.*; |
|---|
| 33 |
import java.awt.geom.*; |
|---|
| 34 |
|
|---|
| 35 |
public class BusNode extends Node implements Serializable |
|---|
| 36 |
{ |
|---|
| 37 |
|
|---|
| 38 |
int[] mappingIds; |
|---|
| 39 |
|
|---|
| 40 |
|
|---|
| 41 |
DummyBusSchedule busSchedules; |
|---|
| 42 |
|
|---|
| 43 |
public BusNode(int pId) { |
|---|
| 44 |
super(pId); |
|---|
| 45 |
|
|---|
| 46 |
} |
|---|
| 47 |
|
|---|
| 48 |
public BusNode(int pId, DummyBusSchedule pSched, String pRouteIdentifier, int length) |
|---|
| 49 |
{ |
|---|
| 50 |
super(pId); |
|---|
| 51 |
busSchedules = pSched; |
|---|
| 52 |
super.setDescription(pRouteIdentifier); |
|---|
| 53 |
mappingIds = new int[length]; |
|---|
| 54 |
} |
|---|
| 55 |
|
|---|
| 56 |
public BusNode(String pRouteIdentifier, int pId) |
|---|
| 57 |
{ |
|---|
| 58 |
super(pId); |
|---|
| 59 |
super.setDescription(pRouteIdentifier); |
|---|
| 60 |
} |
|---|
| 61 |
|
|---|
| 62 |
public int GetNodeIndex(int nodeId) |
|---|
| 63 |
{ |
|---|
| 64 |
for(int i = 0; i < mappingIds.length; i++) |
|---|
| 65 |
{ |
|---|
| 66 |
if(mappingIds[i] == nodeId) |
|---|
| 67 |
{ |
|---|
| 68 |
return i; |
|---|
| 69 |
} |
|---|
| 70 |
} |
|---|
| 71 |
return -1; |
|---|
| 72 |
} |
|---|
| 73 |
|
|---|
| 74 |
|
|---|
| 75 |
public void BindPhyisicalNodeToIndex(int nodeId, int index) |
|---|
| 76 |
{ |
|---|
| 77 |
mappingIds[index] = nodeId; |
|---|
| 78 |
} |
|---|
| 79 |
|
|---|
| 80 |
public int RouteLength() |
|---|
| 81 |
{ |
|---|
| 82 |
return mappingIds.length; |
|---|
| 83 |
} |
|---|
| 84 |
|
|---|
| 85 |
public String RouteIdentifier(int index) |
|---|
| 86 |
{ |
|---|
| 87 |
|
|---|
| 88 |
return ""; |
|---|
| 89 |
} |
|---|
| 90 |
|
|---|
| 91 |
public Cost ComputeWaitTime(Node busRideOrigination, Cost gCostOrigination, Search s) |
|---|
| 92 |
{ |
|---|
| 93 |
|
|---|
| 94 |
|
|---|
| 95 |
|
|---|
| 96 |
|
|---|
| 97 |
int originationIndex = this.GetNodeIndex(busRideOrigination.id); |
|---|
| 98 |
Cost gCostBusNode = busSchedules.eWaitTimeForRoute(this.id, originationIndex, gCostOrigination); |
|---|
| 99 |
gCostBusNode.physicalNodeGotOntoBus = busRideOrigination; |
|---|
| 100 |
return gCostBusNode; |
|---|
| 101 |
} |
|---|
| 102 |
|
|---|
| 103 |
public Cost ComputeTransitTime(Node busRideDestination, Cost gCostBusNode, Search s) |
|---|
| 104 |
{ |
|---|
| 105 |
|
|---|
| 106 |
|
|---|
| 107 |
|
|---|
| 108 |
int fromIndex = this.GetNodeIndex(gCostBusNode.physicalNodeGotOntoBus.id); |
|---|
| 109 |
int toIndex = this.GetNodeIndex(busRideDestination.id); |
|---|
| 110 |
return busSchedules.eTransTimeFor(this.id, fromIndex, toIndex, gCostBusNode); |
|---|
| 111 |
} |
|---|
| 112 |
|
|---|
| 113 |
public Cost computeHCost(Search S, Node previousNode) |
|---|
| 114 |
{ |
|---|
| 115 |
|
|---|
| 116 |
|
|---|
| 117 |
|
|---|
| 118 |
|
|---|
| 119 |
|
|---|
| 120 |
return previousNode.computeHCost(S, this); |
|---|
| 121 |
} |
|---|
| 122 |
} |
|---|