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

Class Edge

pyvrp/Model.py:25–61  ·  view source on GitHub ↗

Stores an edge connecting two locations. Raises ------ ValueError When either distance or duration is a negative value, or when self loops have nonzero distance or duration values.

Source from the content-addressed store, hash-verified

23
24
25class Edge:
26 """
27 Stores an edge connecting two locations.
28
29 Raises
30 ------
31 ValueError
32 When either distance or duration is a negative value, or when self
33 loops have nonzero distance or duration values.
34 """
35
36 __slots__ = ["distance", "duration", "frm", "to"]
37
38 def __init__(
39 self,
40 frm: Client | Depot,
41 to: Client | Depot,
42 distance: int,
43 duration: int,
44 ):
45 if distance < 0 or duration < 0:
46 raise ValueError("Cannot have negative edge distance or duration.")
47
48 if id(frm) == id(to) and (distance != 0 or duration != 0):
49 raise ValueError("A self loop must have 0 distance and duration.")
50
51 if max(distance, duration) > MAX_VALUE:
52 msg = """
53 The given distance or duration value is very large. This may impact
54 numerical stability. Consider rescaling your input data.
55 """
56 warn(msg, ScalingWarning)
57
58 self.frm = frm
59 self.to = to
60 self.distance = distance
61 self.duration = duration
62
63
64class Profile:

Callers 3

add_edgeMethod · 0.85
from_dataMethod · 0.85
add_edgeMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected