From 258423625b2b841d2ffe807e84daae7c9414df35 Mon Sep 17 00:00:00 2001 From: SPS Date: Fri, 5 Dec 2025 00:28:30 +0330 Subject: [PATCH] Revert "Update getting started example to use SimPM API" --- docs/source/getting-started.rst | 39 ++++++++++++--------------------- 1 file changed, 14 insertions(+), 25 deletions(-) diff --git a/docs/source/getting-started.rst b/docs/source/getting-started.rst index 25a65e2..203c756 100644 --- a/docs/source/getting-started.rst +++ b/docs/source/getting-started.rst @@ -16,55 +16,44 @@ Install SimPM from PyPI: A minimal example ----------------- -This minimal model represents a single project activity that requires one crew. -The activity waits until the crew is available, performs the work, and then releases -the resource. The SimPM engine models activities with ``do`` (time spent working) -and ``get`` / ``put`` (queueing for and releasing resources), rather than raw -``timeout`` calls. - +This minimal model represents a single project activity that requires one crew. +The activity waits until the crew is available, works for a random duration, and then finishes. This example shows how to: - Create a :class:`simpm.des.Environment` - Define a simple :class:`simpm.des.Resource` -- Model work with :class:`simpm.des.Entity` using ``do`` and ``get`` -- Run the simulation and inspect basic outputs +- Run the simulation +- Inspect basic outputs (duration and finish time) .. code-block:: python - import simpm from simpm.des import Environment, Resource from simpm.dist import norm # 1) Create the simulation environment - env = Environment("Single activity") + env = Environment() # 2) Define resources (e.g., one crew) - crew = Resource(env, name="Crew 1", capacity=1) - - # 3) Create an entity to perform the activity - (activity_entity,) = env.create_entities("Activity", 1, print_actions=False, log=True) + crew = Resource(env, capacity=1, name="Crew 1") - # 4) Define the activity process - def activity(entity, resource): + # 3) Define an activity process + def activity(env, resource, name): # Request one unit of the crew resource and wait until it is available - yield entity.get(resource, 1) + yield resource.request() # Perform the work duration = norm(10, 2).sample() - yield entity.do("work", duration) - - # Release the crew - yield entity.put(resource, 1) + yield env.timeout(duration) - print(f"{entity.env.now:.2f}: {entity} finished (duration={duration:.2f})") + print(f"{env.now:.2f}: {name} finished (duration={duration:.2f})") - env.process(activity(activity_entity, crew)) + # 4) Create entities / activities + env.process(activity(env, crew, "Activity A")) # 5) Run the simulation - simpm.run(env) + env.run() print(f"Project finished at t={env.now:.2f}") - print(activity_entity.schedule()) Next steps ----------