Stores a routing profile. A routing profile is a collection of edges with distance and duration attributes that together define a complete distance and duration matrix. These can be used to model, for example, the road uses of different types of vehicles, like trucks, cars, or
| 62 | |
| 63 | |
| 64 | class Profile: |
| 65 | """ |
| 66 | Stores a routing profile. |
| 67 | |
| 68 | A routing profile is a collection of edges with distance and duration |
| 69 | attributes that together define a complete distance and duration matrix. |
| 70 | These can be used to model, for example, the road uses of different types |
| 71 | of vehicles, like trucks, cars, or bicyclists. Each |
| 72 | :class:`~pyvrp._pyvrp.VehicleType` is associated with a routing profile. |
| 73 | """ |
| 74 | |
| 75 | edges: list[Edge] |
| 76 | name: str |
| 77 | |
| 78 | def __init__(self, *, name: str = ""): |
| 79 | self.edges = [] |
| 80 | self.name = name |
| 81 | |
| 82 | def add_edge( |
| 83 | self, |
| 84 | frm: Client | Depot, |
| 85 | to: Client | Depot, |
| 86 | distance: int, |
| 87 | duration: int = 0, |
| 88 | ) -> Edge: |
| 89 | """ |
| 90 | Adds a new edge to this routing profile. |
| 91 | """ |
| 92 | edge = Edge(frm, to, distance, duration) |
| 93 | self.edges.append(edge) |
| 94 | return edge |
| 95 | |
| 96 | def __str__(self) -> str: |
| 97 | return self.name |
| 98 | |
| 99 | |
| 100 | class Model: |
no outgoing calls