MCPcopy Index your code
hub / github.com/PyVRP/PyVRP / Model

Class Model

pyvrp/Model.py:100–563  ·  view source on GitHub ↗

A simple interface for modelling vehicle routing problems with PyVRP.

Source from the content-addressed store, hash-verified

98
99
100class Model:
101 """
102 A simple interface for modelling vehicle routing problems with PyVRP.
103 """
104
105 def __init__(self) -> None:
106 self._clients: list[Client] = []
107 self._depots: list[Depot] = []
108 self._edges: list[Edge] = []
109 self._groups: list[ClientGroup] = []
110 self._profiles: list[Profile] = []
111 self._vehicle_types: list[VehicleType] = []
112
113 @property
114 def clients(self) -> list[Client]:
115 """
116 Returns all clients currently in the model.
117 """
118 return self._clients
119
120 @property
121 def depots(self) -> list[Depot]:
122 """
123 Returns all depots currently in the model.
124 """
125 return self._depots
126
127 @property
128 def locations(self) -> list[Client | Depot]:
129 """
130 Returns all locations (depots and clients) in the current model. The
131 clients in the routes of the solution returned by :meth:`~solve` can be
132 used to index these locations.
133 """
134 return self._depots + self._clients
135
136 @property
137 def groups(self) -> list[ClientGroup]:
138 """
139 Returns all client groups currently in the model.
140 """
141 return self._groups
142
143 @property
144 def profiles(self) -> list[Profile]:
145 """
146 Returns all routing profiles currently in the model.
147 """
148 return self._profiles
149
150 @property
151 def vehicle_types(self) -> list[VehicleType]:
152 """
153 Returns the vehicle types in the current model. The routes of the
154 solution returned by :meth:`~solve` have a property
155 :meth:`~pyvrp._pyvrp.Route.vehicle_type()` that can be used to index
156 these vehicle types.
157 """

Calls

no outgoing calls