-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest2.py
More file actions
37 lines (25 loc) · 968 Bytes
/
Copy pathtest2.py
File metadata and controls
37 lines (25 loc) · 968 Bytes
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
33
34
35
36
37
from typing import List
import simpy
from pulpy.interfaces import DefaultContextUser
from pulpy.machines import Machine
from pulpy.system import Context, Monitor, ProbabilityMap, RequestSource, build_catalog, Catalog
# *** SET UP THE CONTEXT ***
# create the usual simpy env
env = simpy.Environment()
# generate a Catalog of Items to query
catalog : Catalog = build_catalog(10)
# create a monitor for logging purposes
monitor : Monitor = Monitor(env)
# put them together
context = Context(env,monitor,catalog)
DefaultContextUser.set_default_context(context)
# *** CREATE THE ACTUATORS OF THE SCENARIO ***
# create clients
clients : List[RequestSource] = [ RequestSource(prob_map=ProbabilityMap(catalog=catalog,autogenerate_weights=True)) ] * 20
# create a server
server : Machine = Machine('SERVER',context=context)
# *** TELL THE ACTUATORS WHAT TO DO
for c in clients:
env.process(c.send_requests(server))
# *** START THE SIMULATION ***
env.run(1000)