simpy-ds 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
simpy_ds/__init__.py ADDED
@@ -0,0 +1,10 @@
1
+ """Teaching helpers for distributed-system simulations on top of SimPy.
2
+
3
+ Use :mod:`simpy_ds.blocking` for mailbox-based processes or
4
+ :mod:`simpy_ds.events` for handler-based processes.
5
+ """
6
+
7
+ from .message import Message
8
+
9
+ __all__ = ["Message"]
10
+
simpy_ds/_network.py ADDED
@@ -0,0 +1,165 @@
1
+ """Internal shared mechanics for the two network programming models."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import random
6
+ from collections.abc import Callable, Iterable
7
+ from typing import Any
8
+
9
+ import simpy
10
+
11
+ from .message import Message
12
+
13
+ Delay = float | Callable[[Message], float]
14
+
15
+
16
+ class _NetworkBase:
17
+ """Shared asynchronous-link behaviour.
18
+
19
+ Subclasses choose how a delivered message reaches its destination by
20
+ implementing :meth:`_deliver_locally`.
21
+ """
22
+
23
+ def __init__(
24
+ self,
25
+ env: simpy.Environment,
26
+ *,
27
+ delay: Delay = 1.0,
28
+ drop_rate: float = 0.0,
29
+ seed: int | None = None,
30
+ ) -> None:
31
+ self.env = env
32
+ self.delay = delay
33
+ self.drop_rate = self._check_probability("drop_rate", drop_rate)
34
+ self.random = random.Random(seed)
35
+ self.trace: list[dict[str, Any]] = []
36
+ self._next_seq = 1
37
+
38
+ def send(
39
+ self,
40
+ src: str,
41
+ dst: str,
42
+ payload: Any = None,
43
+ *,
44
+ tag: str = "message",
45
+ ) -> simpy.Event:
46
+ """Schedule one message delivery."""
47
+ self._require_node(src)
48
+ self._require_node(dst)
49
+ message = Message(
50
+ src=src,
51
+ dst=dst,
52
+ payload=payload,
53
+ tag=tag,
54
+ sent_at=self.env.now,
55
+ seq=self._take_seq(),
56
+ )
57
+ self._record("send", message)
58
+ return self._schedule_delivery(message)
59
+
60
+ def broadcast(
61
+ self,
62
+ src: str,
63
+ dsts: Iterable[str] | None = None,
64
+ payload: Any = None,
65
+ *,
66
+ tag: str = "message",
67
+ include_self: bool = False,
68
+ ) -> simpy.AllOf:
69
+ """Send the same payload to several destinations."""
70
+ self._require_node(src)
71
+ destinations = self._broadcast_destinations(src, dsts, include_self)
72
+ sends = [self.send(src, dst, payload, tag=tag) for dst in destinations]
73
+ return self.env.all_of(sends)
74
+
75
+ def _schedule_delivery(self, message: Message) -> simpy.Event:
76
+ if self.random.random() < self.drop_rate:
77
+ self._record("drop", message)
78
+ return self.env.event().succeed()
79
+
80
+ delivery = self.env.timeout(self._delay_for(message))
81
+ delivery.callbacks.append(lambda _event: self._finish_delivery(message))
82
+ return delivery
83
+
84
+ def _finish_delivery(self, message: Message) -> None:
85
+ delivered = message.delivered_at(self.env.now)
86
+ self._record("deliver", delivered)
87
+ self._deliver_locally(delivered)
88
+ self._after_delivery(delivered)
89
+
90
+ def _deliver_locally(self, message: Message) -> None:
91
+ raise NotImplementedError
92
+
93
+ def _after_delivery(self, message: Message) -> None:
94
+ """Extension hook called once after normal local delivery."""
95
+ pass
96
+
97
+ def _broadcast_destinations(
98
+ self,
99
+ src: str,
100
+ dsts: Iterable[str] | None,
101
+ include_self: bool,
102
+ ) -> list[str]:
103
+ destinations = list(self.nodes if dsts is None else dsts)
104
+ for dst in destinations:
105
+ self._require_node(dst)
106
+ if include_self:
107
+ return destinations
108
+ return [dst for dst in destinations if dst != src]
109
+
110
+ def _delay_for(self, message: Message) -> float:
111
+ delay = self.delay(message) if callable(self.delay) else self.delay
112
+ if delay < 0:
113
+ raise ValueError("network delay must be non-negative")
114
+ return delay
115
+
116
+ def _take_seq(self) -> int:
117
+ seq = self._next_seq
118
+ self._next_seq += 1
119
+ return seq
120
+
121
+ def _record(self, event: str, message: Message) -> None:
122
+ self.trace.append(
123
+ {
124
+ "time": self.env.now,
125
+ "event": event,
126
+ "seq": message.seq,
127
+ "src": message.src,
128
+ "dst": message.dst,
129
+ "tag": message.tag,
130
+ "payload": message.payload,
131
+ }
132
+ )
133
+
134
+ @staticmethod
135
+ def _check_probability(name: str, value: float) -> float:
136
+ if not 0.0 <= value <= 1.0:
137
+ raise ValueError(f"{name} must be between 0 and 1")
138
+ return value
139
+
140
+
141
+ class DuplicatingMixin:
142
+ """Add an optional second local delivery after the original one."""
143
+
144
+ def __init__(self, *args, duplicate_rate: float = 0.0, **kwargs) -> None:
145
+ super().__init__(*args, **kwargs)
146
+ self.duplicate_rate = self._check_probability(
147
+ "duplicate_rate",
148
+ duplicate_rate,
149
+ )
150
+
151
+ def _after_delivery(self, message: Message) -> None:
152
+ super()._after_delivery(message)
153
+ if self.random.random() >= self.duplicate_rate:
154
+ return
155
+ duplicate = Message(
156
+ src=message.src,
157
+ dst=message.dst,
158
+ payload=message.payload,
159
+ tag=message.tag,
160
+ sent_at=message.sent_at,
161
+ deliver_at=self.env.now,
162
+ seq=self._take_seq(),
163
+ )
164
+ self._record("duplicate", duplicate)
165
+ self._deliver_locally(duplicate)
@@ -0,0 +1,6 @@
1
+ """Mailbox-based, blocking process helpers."""
2
+
3
+ from .network import Network
4
+ from .process import Process
5
+
6
+ __all__ = ["Network", "Process"]
@@ -0,0 +1,66 @@
1
+ from __future__ import annotations
2
+
3
+ from collections.abc import Callable, Iterable
4
+
5
+ import simpy
6
+
7
+ from .._network import Delay, _NetworkBase
8
+ from ..message import Message
9
+
10
+ Predicate = Callable[[Message], bool]
11
+
12
+
13
+ class Network(_NetworkBase):
14
+ """Message-passing network built from SimPy events and inboxes.
15
+
16
+ Each node has one inbox. Sending a message schedules a SimPy timeout for
17
+ the configured delay, then inserts the message in the destination inbox.
18
+ A message is either dropped or delivered exactly once.
19
+ """
20
+
21
+ def __init__(
22
+ self,
23
+ env: simpy.Environment,
24
+ nodes: Iterable[str] = (),
25
+ *,
26
+ delay: Delay = 1.0,
27
+ drop_rate: float = 0.0,
28
+ seed: int | None = None,
29
+ ) -> None:
30
+ super().__init__(env, delay=delay, drop_rate=drop_rate, seed=seed)
31
+ self._inboxes: dict[str, simpy.FilterStore] = {}
32
+ for node in nodes:
33
+ self.add_node(node)
34
+
35
+ @property
36
+ def nodes(self) -> tuple[str, ...]:
37
+ """Return the known node identifiers."""
38
+ return tuple(self._inboxes)
39
+
40
+ def add_node(self, node: str) -> None:
41
+ """Add a node and its inbox if it does not already exist."""
42
+ if node not in self._inboxes:
43
+ self._inboxes[node] = simpy.FilterStore(self.env)
44
+
45
+ def recv(
46
+ self,
47
+ node: str,
48
+ predicate: Predicate | None = None,
49
+ ) -> simpy.FilterStoreGet:
50
+ """Wait for the next message accepted by ``predicate``."""
51
+ self._require_node(node)
52
+ if predicate is None:
53
+ predicate = lambda _message: True
54
+ return self._inboxes[node].get(predicate)
55
+
56
+ def inbox_size(self, node: str) -> int:
57
+ """Return the number of queued messages in a node inbox."""
58
+ self._require_node(node)
59
+ return len(self._inboxes[node].items)
60
+
61
+ def _deliver_locally(self, message: Message) -> None:
62
+ self._inboxes[message.dst].put(message)
63
+
64
+ def _require_node(self, node: str) -> None:
65
+ if node not in self._inboxes:
66
+ raise KeyError(f"unknown node: {node!r}")
@@ -0,0 +1,65 @@
1
+ from __future__ import annotations
2
+
3
+ from collections.abc import Callable
4
+ from typing import Any
5
+
6
+ from ..message import Message
7
+ from .network import Network, Predicate
8
+
9
+
10
+ class Process:
11
+ """Convenience wrapper around one simulated distributed process."""
12
+
13
+ def __init__(self, pid: str, network: Network) -> None:
14
+ self.pid = pid
15
+ self.network = network
16
+ self.env = network.env
17
+ self.network.add_node(pid)
18
+
19
+ def send(
20
+ self,
21
+ dst: str,
22
+ payload: Any = None,
23
+ *,
24
+ tag: str = "message",
25
+ ):
26
+ """Send one message from this process."""
27
+ return self.network.send(self.pid, dst, payload, tag=tag)
28
+
29
+ def broadcast(
30
+ self,
31
+ payload: Any = None,
32
+ *,
33
+ tag: str = "message",
34
+ include_self: bool = False,
35
+ ):
36
+ """Broadcast from this process to the network's known nodes."""
37
+ return self.network.broadcast(
38
+ self.pid,
39
+ payload=payload,
40
+ tag=tag,
41
+ include_self=include_self,
42
+ )
43
+
44
+ def recv(self, predicate: Predicate | None = None):
45
+ """Receive the next matching message for this process."""
46
+ return self.network.recv(self.pid, predicate)
47
+
48
+ def recv_tag(self, tag: str):
49
+ """Receive the next message with the given tag."""
50
+ return self.recv(lambda message: message.tag == tag)
51
+
52
+ def timeout(self, delay: float):
53
+ """Wait for simulated time to pass."""
54
+ return self.env.timeout(delay)
55
+
56
+ def every(
57
+ self,
58
+ delay: float,
59
+ callback: Callable[["Process"], Any],
60
+ ):
61
+ """Run `callback` periodically as a SimPy process."""
62
+ while True:
63
+ yield self.timeout(delay)
64
+ callback(self)
65
+
@@ -0,0 +1,6 @@
1
+ """Handler-based, event-driven simulation helpers."""
2
+
3
+ from .network import EventNetwork
4
+ from .process import EventProcess
5
+
6
+ __all__ = ["EventNetwork", "EventProcess"]
@@ -0,0 +1,50 @@
1
+ """A handler-based asynchronous message-passing network."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from collections.abc import Callable
6
+
7
+ import simpy
8
+
9
+ from .._network import Delay, _NetworkBase
10
+ from ..message import Message
11
+
12
+ MessageHandler = Callable[[Message], None]
13
+
14
+
15
+ class EventNetwork(_NetworkBase):
16
+ """Lossy asynchronous links that deliver messages to node handlers.
17
+
18
+ Each node has exactly one registered message handler. A delivered message
19
+ calls that handler immediately at its delivery time; this network has no
20
+ inboxes and no blocking receive operation.
21
+ """
22
+
23
+ def __init__(
24
+ self,
25
+ env: simpy.Environment,
26
+ *,
27
+ delay: Delay = 1.0,
28
+ drop_rate: float = 0.0,
29
+ seed: int | None = None,
30
+ ) -> None:
31
+ super().__init__(env, delay=delay, drop_rate=drop_rate, seed=seed)
32
+ self._handlers: dict[str, MessageHandler] = {}
33
+
34
+ @property
35
+ def nodes(self) -> tuple[str, ...]:
36
+ """Return registered node identifiers."""
37
+ return tuple(self._handlers)
38
+
39
+ def register_handler(self, node: str, handler: MessageHandler) -> None:
40
+ """Register the one message handler for ``node``."""
41
+ if node in self._handlers:
42
+ raise ValueError(f"node already has a handler: {node!r}")
43
+ self._handlers[node] = handler
44
+
45
+ def _deliver_locally(self, message: Message) -> None:
46
+ self._handlers[message.dst](message)
47
+
48
+ def _require_node(self, node: str) -> None:
49
+ if node not in self._handlers:
50
+ raise KeyError(f"unknown node: {node!r}")
@@ -0,0 +1,69 @@
1
+ """Base class for handler-based distributed processes."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Any
6
+
7
+ import simpy
8
+
9
+ from ..message import Message
10
+ from .network import EventNetwork
11
+
12
+
13
+ class EventProcess:
14
+ """A distributed process driven by message and timer handlers.
15
+
16
+ Subclasses implement :meth:`handle_message`. Handler methods are ordinary
17
+ functions: they run to completion at one simulated time and must not yield.
18
+ """
19
+
20
+ def __init__(self, pid: str, network: EventNetwork) -> None:
21
+ self.pid = pid
22
+ self.network = network
23
+ self.env = network.env
24
+ self.network.register_handler(pid, self.handle_message)
25
+
26
+ def send(
27
+ self,
28
+ dst: str,
29
+ payload: Any = None,
30
+ *,
31
+ tag: str = "message",
32
+ ):
33
+ """Schedule one message delivery without waiting for it."""
34
+ return self.network.send(self.pid, dst, payload, tag=tag)
35
+
36
+ def broadcast(
37
+ self,
38
+ payload: Any = None,
39
+ *,
40
+ tag: str = "message",
41
+ include_self: bool = False,
42
+ ):
43
+ """Schedule one delivery to each destination without waiting."""
44
+ return self.network.broadcast(
45
+ self.pid,
46
+ payload=payload,
47
+ tag=tag,
48
+ include_self=include_self,
49
+ )
50
+
51
+ def call_later(self, delay: float, timer_id: Any) -> simpy.Event:
52
+ """Schedule :meth:`handle_timer` after ``delay`` simulated time."""
53
+ if delay < 0:
54
+ raise ValueError("timer delay must be non-negative")
55
+ timer = self.env.timeout(delay)
56
+ timer.callbacks.append(lambda _event: self.handle_timer(timer_id))
57
+ return timer
58
+
59
+ def handle_message(self, message: Message) -> None:
60
+ """Handle one delivered message.
61
+
62
+ Subclasses must override this ordinary, non-generator method.
63
+ """
64
+ raise NotImplementedError
65
+
66
+ def handle_timer(self, timer_id: Any) -> None:
67
+ """Handle a timer scheduled with :meth:`call_later`."""
68
+ raise NotImplementedError
69
+
simpy_ds/message.py ADDED
@@ -0,0 +1,30 @@
1
+ from __future__ import annotations
2
+
3
+ from dataclasses import dataclass, field
4
+ from typing import Any
5
+
6
+
7
+ @dataclass(frozen=True, slots=True)
8
+ class Message:
9
+ """A message delivered by the simulated network."""
10
+
11
+ src: str
12
+ dst: str
13
+ payload: Any = None
14
+ tag: str = "message"
15
+ sent_at: float = 0.0
16
+ deliver_at: float = 0.0
17
+ seq: int = field(default=0)
18
+
19
+ def delivered_at(self, time: float) -> "Message":
20
+ """Return a copy annotated with its simulated delivery time."""
21
+ return Message(
22
+ src=self.src,
23
+ dst=self.dst,
24
+ payload=self.payload,
25
+ tag=self.tag,
26
+ sent_at=self.sent_at,
27
+ deliver_at=time,
28
+ seq=self.seq,
29
+ )
30
+
@@ -0,0 +1,242 @@
1
+ Metadata-Version: 2.4
2
+ Name: simpy-ds
3
+ Version: 0.1.0
4
+ Summary: Small distributed-systems simulation helpers on top of SimPy.
5
+ Author-email: Davide Frey <davide.frey@inria.fr>
6
+ License-Expression: LGPL-3.0-or-later
7
+ Project-URL: Source, https://gitlab.inria.fr/dfrey/simpy-ds
8
+ Project-URL: Issues, https://gitlab.inria.fr/dfrey/simpy-ds/-/issues
9
+ Requires-Python: >=3.10
10
+ Description-Content-Type: text/markdown
11
+ License-File: LICENSE
12
+ License-File: NOTICE
13
+ Requires-Dist: simpy>=4.1.2
14
+ Dynamic: license-file
15
+
16
+ # SimPy DS
17
+
18
+ `simpy-ds` is a small teaching-oriented layer for writing distributed-system
19
+ simulations on top of SimPy's event-based core.
20
+
21
+ It is intentionally thin: SimPy still provides the scheduler, simulated time,
22
+ timeouts, events, and process execution. This package adds a small message
23
+ passing API that looks closer to distributed-algorithm pseudocode.
24
+
25
+ ```python
26
+ yield network.send("p0", "p1", {"round": 1}, tag="vote")
27
+ message = yield network.recv("p1")
28
+ ```
29
+ ## License
30
+
31
+ SimPy-DS is licensed under the GNU Lesser General Public License,
32
+ version 3.0 or later. See [LICENSE](LICENSE).
33
+
34
+ ## Why SimPy?
35
+
36
+ SimPy is a process-based discrete-event simulator. A distributed process can be
37
+ written as a Python generator, and `yield` marks points where it waits for an
38
+ event: a timeout, a message delivery, or a condition over several events.
39
+
40
+ This makes it a good substrate for algorithms with:
41
+
42
+ - asynchronous message delivery
43
+ - timers and timeouts
44
+ - controlled delays
45
+ - optional message loss
46
+ - simple crash-stop or omission faults
47
+ - deterministic replay with a random seed
48
+
49
+ ## Layout
50
+
51
+ ```text
52
+ simpy-ds/
53
+ README.md
54
+ requirements.txt
55
+ src/simpy_ds/
56
+ __init__.py
57
+ blocking/
58
+ network.py
59
+ process.py
60
+ events/
61
+ network.py
62
+ process.py
63
+ message.py
64
+ network.py
65
+ process.py
66
+ src/simpy_ds_extensions/
67
+ __init__.py
68
+ duplicating.py
69
+ examples/
70
+ adapters/
71
+ blocking_on_events.py
72
+ events_on_blocking.py
73
+ blocking/
74
+ bracha_double_echo.py
75
+ ping_pong.py
76
+ broadcast_delivery.py
77
+ broadcast_delivery_2.py
78
+ duplicating_channel.py
79
+ events/
80
+ bracha_double_echo.py
81
+ ping_pong.py
82
+ broadcast_delivery.py
83
+ duplicating_channel.py
84
+ ```
85
+
86
+ ## Install
87
+
88
+ From this folder:
89
+
90
+ ```bash
91
+ python -m pip install -r requirements.txt
92
+ ```
93
+
94
+ To run the examples from a local checkout, install the project in editable
95
+ mode:
96
+
97
+ ```bash
98
+ python -m pip install -e .
99
+ ```
100
+
101
+ ## Blocking-Style Examples
102
+
103
+ ```bash
104
+ python examples/blocking/ping_pong.py
105
+ python examples/blocking/broadcast_delivery.py
106
+ python examples/blocking/duplicating_channel.py
107
+ ```
108
+
109
+ If `yield` or `lambda` are unfamiliar, see
110
+ [`docs/python-yield-and-lambda.md`](docs/python-yield-and-lambda.md).
111
+
112
+ ## Two Programming Models
113
+
114
+ The library has two separate sub-libraries:
115
+
116
+ - `simpy_ds.blocking`: mailbox-based processes that wait with `yield recv()`.
117
+ - `simpy_ds.events`: handler-based processes. `EventNetwork` delivers each
118
+ message directly to the one registered `EventProcess` handler for its
119
+ destination. It has no inboxes and no `recv()` operation.
120
+
121
+ The corresponding examples for both styles are under `examples/blocking/` and
122
+ `examples/events/`.
123
+
124
+ ## Event-Driven Examples
125
+
126
+ ```bash
127
+ python examples/events/ping_pong.py
128
+ python examples/events/broadcast_delivery.py
129
+ python examples/events/duplicating_channel.py
130
+ python examples/events/bracha_double_echo.py
131
+
132
+ ## Layered Interface Samples
133
+
134
+ The modules in `examples/adapters/` show how one programming model can be
135
+ layered over the other:
136
+
137
+ - `blocking_on_events.py` provides a blocking `Network` and `Process` over the
138
+ handler-based implementation.
139
+ - `events_on_blocking.py` provides an `EventNetwork` and `EventProcess` over
140
+ the mailbox-based implementation.
141
+
142
+ Every ordinary example keeps its native import active and includes a commented
143
+ alternative import from the corresponding adapter. Uncomment that line and
144
+ comment the native import to run the same application over the layered API.
145
+ ```
146
+
147
+ ## Run Tests
148
+
149
+ The tests use Python's built-in `unittest` module:
150
+
151
+ ```bash
152
+ python -m unittest discover -s tests -v
153
+ ```
154
+
155
+ ## Blocking API
156
+
157
+ Create an environment and network:
158
+
159
+ ```python
160
+ import simpy
161
+ from simpy_ds.blocking import Network
162
+
163
+ env = simpy.Environment()
164
+ network = Network(env, nodes=["p0", "p1", "p2"], delay=1.0)
165
+ ```
166
+
167
+ Send a message:
168
+
169
+ ```python
170
+ yield network.send("p0", "p1", "hello", tag="greeting")
171
+ ```
172
+
173
+ Receive the next message:
174
+
175
+ ```python
176
+ message = yield network.recv("p1")
177
+ ```
178
+
179
+ Receive only messages matching a predicate:
180
+
181
+ ```python
182
+ message = yield network.recv("p1", lambda m: m.tag == "ack")
183
+ ```
184
+
185
+ Broadcast:
186
+
187
+ ```python
188
+ yield network.broadcast("p0", ["p1", "p2"], "value", tag="proposal")
189
+ ```
190
+
191
+ This is a network-level convenience method, not a reliable-broadcast protocol.
192
+ It schedules one send per destination. If the network is configured with
193
+ message loss, some destinations may never receive the payload. A real reliable
194
+ broadcast algorithm should be written as a process-level protocol on top of
195
+ `send`, `recv`, and `broadcast`, with explicit validity, agreement, and
196
+ integrity properties.
197
+
198
+ The base network can be configured as lossless by leaving `drop_rate=0.0`, or
199
+ as lossy by setting `drop_rate` above zero. It does not duplicate messages.
200
+
201
+ ## Optional Extensions
202
+
203
+ The optional network variants live in `simpy_ds_extensions`. The current
204
+ duplicating variants support both network APIs.
205
+
206
+ For example, `DuplicatingNetwork` extends the blocking network with possible
207
+ duplicate delivery. `DuplicatingEventNetwork` provides the matching
208
+ handler-based variant.
209
+
210
+ ```python
211
+ from simpy_ds_extensions import DuplicatingNetwork
212
+
213
+ network = DuplicatingNetwork(
214
+ env,
215
+ nodes=["p0", "p1"],
216
+ delay=1.0,
217
+ duplicate_rate=0.1,
218
+ )
219
+ ```
220
+
221
+ Use this only when you explicitly want to model a channel that may deliver a
222
+ second copy of an already delivered message.
223
+
224
+ Add a timeout:
225
+
226
+ ```python
227
+ received = network.recv("p1")
228
+ timeout = env.timeout(5)
229
+ result = yield received | timeout
230
+
231
+ if received in result:
232
+ message = result[received]
233
+ else:
234
+ print("timed out")
235
+ ```
236
+
237
+ ## Scope
238
+
239
+ This is a starting point, not a full distributed-systems framework. The current
240
+ library models processes and message passing. Natural next additions are FIFO
241
+ links, partitions, crash-stop nodes, Byzantine nodes, vector clocks, and trace
242
+ export for visualization.
@@ -0,0 +1,18 @@
1
+ simpy_ds/__init__.py,sha256=WwcOGwTIUynCTc1cI5Ifg-cNZ9wMXOOPVBj2HVUSKoA,243
2
+ simpy_ds/_network.py,sha256=5nQJiY0O-ebsP-Y9jZbReUBy-1Ppo2sYcQwQ6xWqa8k,5009
3
+ simpy_ds/message.py,sha256=5gejWb7dL3eI3yiY_jFvlFWZUtJJhiUPJp4BKV8yGQo,733
4
+ simpy_ds/blocking/__init__.py,sha256=Fau8C_BynWm-ANaJfTIKMp2v7AFrUffkBBAG3UrEdCA,140
5
+ simpy_ds/blocking/network.py,sha256=MmwiAXWu82jmLm5MQiDATjxmp9P6pT7eZa0gVS83pS0,2083
6
+ simpy_ds/blocking/process.py,sha256=6K3JKa8vo-OvPRjIJox1zaDQPU8YFln3OmC-CIMxC9Y,1765
7
+ simpy_ds/events/__init__.py,sha256=UbQNUeHwjMtc_ahdIuKNg3hj8L4ZVO14rq2yyJRGtnc,167
8
+ simpy_ds/events/network.py,sha256=Pt5Y5gYClZlPoWc-cMGMZ-yhz0GNXgK__siqxLWU4mc,1569
9
+ simpy_ds/events/process.py,sha256=7znVf7XBQh30zFMKbrjTXforOqFosa77V0McNgatDxE,2042
10
+ simpy_ds-0.1.0.dist-info/licenses/LICENSE,sha256=46mU2C5kSwOnkqkw9XQAJlhBL2JAf1_uCD8lVcXyMRg,7652
11
+ simpy_ds-0.1.0.dist-info/licenses/NOTICE,sha256=CIWd6Dmr4IPjby7vgLyxwyXEk0t_tUiejGnVYJQ7TsI,302
12
+ simpy_ds_extensions/__init__.py,sha256=XaXkie0kAYcM2oS9d1xyeHH6fj4_gTWwXnIpwzZO7Ow,219
13
+ simpy_ds_extensions/duplicating.py,sha256=5h-1nb3dSpfd7WqaasJoCcPJ1n8n1lASlv-BKiO_8bM,380
14
+ simpy_ds_extensions/duplicating_events.py,sha256=ImvgtB33f-1gUm2NBl6ldPwL0P7n8bJYYifwaHFyCQY,390
15
+ simpy_ds-0.1.0.dist-info/METADATA,sha256=1Too8PT4U_DCZOtDqGg0hTxH2hEVRmujy7CbEPLHYk8,6311
16
+ simpy_ds-0.1.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
17
+ simpy_ds-0.1.0.dist-info/top_level.txt,sha256=Ivoct-MS6gCNdp1Dx6AMknzsK66ZZwBZpoJfaP9RCnk,29
18
+ simpy_ds-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.2.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,165 @@
1
+ GNU LESSER GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+
9
+ This version of the GNU Lesser General Public License incorporates
10
+ the terms and conditions of version 3 of the GNU General Public
11
+ License, supplemented by the additional permissions listed below.
12
+
13
+ 0. Additional Definitions.
14
+
15
+ As used herein, "this License" refers to version 3 of the GNU Lesser
16
+ General Public License, and the "GNU GPL" refers to version 3 of the GNU
17
+ General Public License.
18
+
19
+ "The Library" refers to a covered work governed by this License,
20
+ other than an Application or a Combined Work as defined below.
21
+
22
+ An "Application" is any work that makes use of an interface provided
23
+ by the Library, but which is not otherwise based on the Library.
24
+ Defining a subclass of a class defined by the Library is deemed a mode
25
+ of using an interface provided by the Library.
26
+
27
+ A "Combined Work" is a work produced by combining or linking an
28
+ Application with the Library. The particular version of the Library
29
+ with which the Combined Work was made is also called the "Linked
30
+ Version".
31
+
32
+ The "Minimal Corresponding Source" for a Combined Work means the
33
+ Corresponding Source for the Combined Work, excluding any source code
34
+ for portions of the Combined Work that, considered in isolation, are
35
+ based on the Application, and not on the Linked Version.
36
+
37
+ The "Corresponding Application Code" for a Combined Work means the
38
+ object code and/or source code for the Application, including any data
39
+ and utility programs needed for reproducing the Combined Work from the
40
+ Application, but excluding the System Libraries of the Combined Work.
41
+
42
+ 1. Exception to Section 3 of the GNU GPL.
43
+
44
+ You may convey a covered work under sections 3 and 4 of this License
45
+ without being bound by section 3 of the GNU GPL.
46
+
47
+ 2. Conveying Modified Versions.
48
+
49
+ If you modify a copy of the Library, and, in your modifications, a
50
+ facility refers to a function or data to be supplied by an Application
51
+ that uses the facility (other than as an argument passed when the
52
+ facility is invoked), then you may convey a copy of the modified
53
+ version:
54
+
55
+ a) under this License, provided that you make a good faith effort to
56
+ ensure that, in the event an Application does not supply the
57
+ function or data, the facility still operates, and performs
58
+ whatever part of its purpose remains meaningful, or
59
+
60
+ b) under the GNU GPL, with none of the additional permissions of
61
+ this License applicable to that copy.
62
+
63
+ 3. Object Code Incorporating Material from Library Header Files.
64
+
65
+ The object code form of an Application may incorporate material from
66
+ a header file that is part of the Library. You may convey such object
67
+ code under terms of your choice, provided that, if the incorporated
68
+ material is not limited to numerical parameters, data structure
69
+ layouts and accessors, or small macros, inline functions and templates
70
+ (ten or fewer lines in length), you do both of the following:
71
+
72
+ a) Give prominent notice with each copy of the object code that the
73
+ Library is used in it and that the Library and its use are
74
+ covered by this License.
75
+
76
+ b) Accompany the object code with a copy of the GNU GPL and this license
77
+ document.
78
+
79
+ 4. Combined Works.
80
+
81
+ You may convey a Combined Work under terms of your choice that,
82
+ taken together, effectively do not restrict modification of the
83
+ portions of the Library contained in the Combined Work and reverse
84
+ engineering for debugging such modifications, if you also do each of
85
+ the following:
86
+
87
+ a) Give prominent notice with each copy of the Combined Work that
88
+ the Library is used in it and that the Library and its use are
89
+ covered by this License.
90
+
91
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
92
+ document.
93
+
94
+ c) For a Combined Work that displays copyright notices during
95
+ execution, include the copyright notice for the Library among
96
+ these notices, as well as a reference directing the user to the
97
+ copies of the GNU GPL and this license document.
98
+
99
+ d) Do one of the following:
100
+
101
+ 0) Convey the Minimal Corresponding Source under the terms of this
102
+ License, and the Corresponding Application Code in a form
103
+ suitable for, and under terms that permit, the user to
104
+ recombine or relink the Application with a modified version of
105
+ the Linked Version to produce a modified Combined Work, in the
106
+ manner specified by section 6 of the GNU GPL for conveying
107
+ Corresponding Source.
108
+
109
+ 1) Use a suitable shared library mechanism for linking with the
110
+ Library. A suitable mechanism is one that (a) uses at run time
111
+ a copy of the Library already present on the user's computer
112
+ system, and (b) will operate properly with a modified version
113
+ of the Library that is interface-compatible with the Linked
114
+ Version.
115
+
116
+ e) Provide Installation Information, but only if you would otherwise
117
+ be required to provide such information under section 6 of the
118
+ GNU GPL, and only to the extent that such information is
119
+ necessary to install and execute a modified version of the
120
+ Combined Work produced by recombining or relinking the
121
+ Application with a modified version of the Linked Version. (If
122
+ you use option 4d0, the Installation Information must accompany
123
+ the Minimal Corresponding Source and Corresponding Application
124
+ Code. If you use option 4d1, you must provide the Installation
125
+ Information in the manner specified by section 6 of the GNU GPL
126
+ for conveying Corresponding Source.)
127
+
128
+ 5. Combined Libraries.
129
+
130
+ You may place library facilities that are a work based on the
131
+ Library side by side in a single library together with other library
132
+ facilities that are not Applications and are not covered by this
133
+ License, and convey such a combined library under terms of your
134
+ choice, if you do both of the following:
135
+
136
+ a) Accompany the combined library with a copy of the same work based
137
+ on the Library, uncombined with any other library facilities,
138
+ conveyed under the terms of this License.
139
+
140
+ b) Give prominent notice with the combined library that part of it
141
+ is a work based on the Library, and explaining where to find the
142
+ accompanying uncombined form of the same work.
143
+
144
+ 6. Revised Versions of the GNU Lesser General Public License.
145
+
146
+ The Free Software Foundation may publish revised and/or new versions
147
+ of the GNU Lesser General Public License from time to time. Such new
148
+ versions will be similar in spirit to the present version, but may
149
+ differ in detail to address new problems or concerns.
150
+
151
+ Each version is given a distinguishing version number. If the
152
+ Library as you received it specifies that a certain numbered version
153
+ of the GNU Lesser General Public License "or any later version"
154
+ applies to it, you have the option of following the terms and
155
+ conditions either of that published version or of any later version
156
+ published by the Free Software Foundation. If the Library as you
157
+ received it does not specify a version number of the GNU Lesser
158
+ General Public License, you may choose any version of the GNU Lesser
159
+ General Public License ever published by the Free Software Foundation.
160
+
161
+ If the Library as you received it specifies that a proxy can decide
162
+ whether future versions of the GNU Lesser General Public License shall
163
+ apply, that proxy's public statement of acceptance of any version is
164
+ permanent authorization for you to choose that version for the
165
+ Library.
@@ -0,0 +1,9 @@
1
+ SimPy-DS
2
+
3
+ Copyright © 2026 Inria
4
+ Author: Davide Frey
5
+
6
+ This library is free software: you can redistribute it and/or modify it
7
+ under the terms of the GNU Lesser General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
@@ -0,0 +1,2 @@
1
+ simpy_ds
2
+ simpy_ds_extensions
@@ -0,0 +1,7 @@
1
+ """Optional network models built on top of simpy_ds."""
2
+
3
+ from .duplicating import DuplicatingNetwork
4
+ from .duplicating_events import DuplicatingEventNetwork
5
+
6
+ __all__ = ["DuplicatingEventNetwork", "DuplicatingNetwork"]
7
+
@@ -0,0 +1,12 @@
1
+ """Optional duplicating channels for mailbox-based processes."""
2
+
3
+ from simpy_ds._network import DuplicatingMixin
4
+ from simpy_ds.blocking import Network
5
+
6
+
7
+ class DuplicatingNetwork(DuplicatingMixin, Network):
8
+ """A blocking network that may deliver a second copy of a message.
9
+
10
+ The duplicate is inserted immediately after the original, at the same
11
+ simulated time.
12
+ """
@@ -0,0 +1,12 @@
1
+ """Optional duplicating channels for handler-based processes."""
2
+
3
+ from simpy_ds._network import DuplicatingMixin
4
+ from simpy_ds.events import EventNetwork
5
+
6
+
7
+ class DuplicatingEventNetwork(DuplicatingMixin, EventNetwork):
8
+ """An event network that may call a destination handler twice.
9
+
10
+ The duplicate is delivered immediately after the original, at the same
11
+ simulated time.
12
+ """