Minimal Hybrid System¶
This example constructs a thermostat from locations, continuous dynamics, event surfaces, and transitions, then simulates it.
Run it from the repository root:
The build_thermostat() function assembles a HybridSystem from these objects:
Locationrepresents an automaton node, hereheatingandcooling.Flowstores the derivative function asfn; each location selects one throughLocation.flow.EventSurfacedefines a function whose zero crossing can trigger a transition.CrossingDirectionrestricts an event to rising or falling crossings.Transitionconnects a source location to a target location.
Temperature rises at a constant rate while heating and falls at a constant rate while cooling. Crossing the upper or lower temperature boundary selects the other location without resetting the temperature. The HybridSystem constructor also sets the initial state and location.
The script passes this model to simulate and displays the returned trajectory with plot_trajectory. It prints the number of recorded events and opens a Matplotlib plot.