Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
manifest-path: pixi.toml
pixi-version: v0.41.0
cache: true
- run: pixi run -e py312 build_html_docs
- run: pixi run -e py312 myst build --html
- name: Build the JupyterLite site
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
run: pixi run -e py312 build_jl
Expand All @@ -25,5 +25,5 @@ jobs:
with:
publish_branch: gh-pages
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: build/docs/
publish_dir: ./_build/html
force_orphan: true
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
environment: [py312]
environment: [py312, py313, py314]
steps:
- uses: actions/checkout@v6
- uses: prefix-dev/setup-pixi@v0.9.5
Expand All @@ -31,7 +31,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
environment: [py311, py312, py313]
environment: [py312, py313, py314]
steps:
- uses: actions/checkout@v6
- uses: prefix-dev/setup-pixi@v0.9.5
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,6 @@ docs/source/auto
# Jupyterlite
*.doit.db
_output

# MyST build outputs
_build
68 changes: 2 additions & 66 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,67 +1,3 @@
# UPSTAGE
# upstage_des

UPSTAGE is a **U**niversal **P**latform for **S**imulating
**T**asks and **A**ctors with **G**raphs and **E**vents built atop
[__`SimPy 4`__][simpy-repo].

## ✨ Try it in your browser ✨

➡️ **https://gtri.github.io/upstage/demo**

## What is UPSTAGE for?

__UPSTAGE__ is a Python framework for creating robust, behavior-driven Discrete Event Simulations (DES). The primary goal of UPSTAGE is to enable the quick creation of simulations at any desired level of abstraction with built-in data recording, simulation integrity and runtime checks, and assistance for the usual pitfalls in custom discrete-event simulation: interrupts and cancellations. It is designed is to simplify the development process for simulation models of *complex systems of systems*.

__UPSTAGE__ leverages the extensible [__`SimPy`__][simpy-docs] library and adds two concepts to accelerate the generation of complex discrete-event simulations.

1. `Actor` - i.e., an entity that has `State`
2. `Task` - i.e., actions actors can perform and that can be organized into a `TaskNetwork`.

Actors can have multiple networks running on them, their states can be shared, and there are features for interactions between task networks running on the same actor. Those tasks modify the states on their actor, with features for real-time states that update on request without requiring time-stepping or modifying the existing events.

![image](docs/source/_static/upstage-flow.png)

Additional features include:

1. Context-aware `EnvironmentContext`, accessed via `UpstageBase`, enabling thread-safe simulation globals for the _Stage_ and _Named Entities_ (see below).
1. __Active States__ (e.g.,`LinearChangingState`) represent continuous-time attributes of actors that can be queried at discrete points in time, or trigger events when they reach a certain level.
1. Spatial-aware data types (e.g., `CartesianLocation`) and states like the waypoint-following `GeodeticLocationChangingState`.
1. Geodetic and cartesian positions, distances, and motion - with ranged sensing.
1. `NamedEntity` in a thread-safe global context, enabling easier "director" logic creation with less argument passing in your code
1. The `Stage`: a global context variable for simulation properties and attributes. This enables under-the-hood coordination of motion, geography, and other features.
1. __Rehearsal__: Write planning and simulation code in one place only, and "rehearse" an actor through a task network using planning factors to discover task feasibility before the actor attempts to complete the task.
1. All States are recordable, and some record dataclass and dictionary values
1. A `Routine` class for building reusable event behaviors to simplify `Task` coding.
1. Point-To-Point and Routing Table communications handlers.
1. Numerous runtime checks and error handling for typical DES pitfalls: based on more than a decade of custom DES-building experience.
1. And more!

See the [documentation][upstage-docs] for tutorials and details.

## Requirements

UPSTAGE only requires Python 3.11+ and Simpy 4+.

## Installation

In an environment (Python 3.11+) of your choice:

```console
pip install upstage-des
```

## Documentation

See the [documentation][upstage-docs] for tutorials and additional details.

## How do I contribute or set up a develpment environment?

See [CONTRIBUTING][contributing] for instructions on setting up an environment and contributing.

For information on how to style your code, see the [Style Guide][style-guide].

[contributing]: ./CONTRIBUTING.md
[style-guide]: ./STYLE_GUIDE.md
[simpy-docs]: https://simpy.readthedocs.io/en/latest/
[simpy-repo]: https://gitlab.com/team-simpy/simpy/
[upstage-docs]: https://gtri.github.io/upstage
This is a software library for doing discrete event simulation.
Binary file added docs/source/_static/cashier_actor_hinting.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 0 additions & 18 deletions docs/source/class_refs.txt

This file was deleted.

86 changes: 0 additions & 86 deletions docs/source/conf.py

This file was deleted.

18 changes: 0 additions & 18 deletions docs/source/demo.md

This file was deleted.

1 change: 1 addition & 0 deletions docs/source/features-active-states.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Active States
1 change: 1 addition & 0 deletions docs/source/features-actor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Actor
1 change: 1 addition & 0 deletions docs/source/features-knowledge.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Knowledge
42 changes: 42 additions & 0 deletions docs/source/features-logging.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Logging

UPSTAGE exposes a :mod:`logging` hierarchy rooted at ``upstage_des``. The
library is silent by default — a ``NullHandler`` is attached on import and
the package logger defaults to ``WARNING``. Opt in at your application
entry point

```{code-block} python
import logging

logging.basicConfig(level=logging.INFO, format="%(name)s: %(message)s")
logging.getLogger("upstage_des").setLevel(logging.INFO)
```

Actor events go to ``upstage_des.actor.<actor.name>``.

```{code-block} python
logging.getLogger("upstage_des.actor").setLevel(logging.INFO)
# Filter only for actors with certain values in the name
logging.getLogger("upstage_des.actor").addFilter(
lambda rec: "Plane" not in rec.name
)
```

Inside a custom :class:`Task`, call ``actor.write_to_log`` with printf-style
arguments. Formatting is deferred — when the log level is disabled and
``debug_logging=False`` on the actor, the interpolation never runs, so
``repr``/``str`` cost on your arguments is avoided in hot loops.

```{code-block} python
def task(self, *, actor):
actor.write_to_log("picked up %s (qty=%d)", item, qty) # INFO
actor.write_to_log("low fuel: %.1f%%", remaining, level=logging.WARNING)
```

Two independent sinks are driven by every ``write_to_log`` call:

* The per-actor in-memory list (``actor.write_to_log()`` /
``actor.get_log()``) — controlled by the ``debug_logging`` flag set at
actor construction. Use this for post-run analysis in notebooks.
* Python's ``logging`` — controlled by the standard level hierarchy.
Use this for structured sinks (files, JSON, stdout during dev).
1 change: 1 addition & 0 deletions docs/source/features-stage.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Environment Context and Stage
1 change: 1 addition & 0 deletions docs/source/features-states.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# States
1 change: 1 addition & 0 deletions docs/source/features-task-networks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Task Networks
1 change: 1 addition & 0 deletions docs/source/features-tasks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Tasks
7 changes: 7 additions & 0 deletions docs/source/features.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# UPSTAGE Features

These are the features.

:::{toctree}
:context: children
:::
Loading