This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
TRUST is a Python Flask web application for data-driven controller synthesis of dynamical systems with unknown mathematical models. It synthesizes Control Lyapunov Functions (CLF) or Control Barrier Certificates (CBC) using sum-of-squares (SOS) optimization based solely on input-state trajectory data.
Supports four system classes:
- Continuous-time nonlinear polynomial systems (ct-NPS)
- Continuous-time linear systems (ct-LS)
- Discrete-time nonlinear polynomial systems (dt-NPS)
- Discrete-time linear systems (dt-LS)
cp .env.example .env
docker compose up --build -d
# Access at http://127.0.0.1:8000# Ensure Python 3.12.10 via pyenv
pyenv install 3.12.10
pyenv local 3.12.10
# Install dependencies
poetry install
# Copy environment file
cp .env.example .env
# Build frontend
cd vite && npm ci && npm run build && cd ..
# Run application
poetry run python main.py # Runs on port 5000 with SSLpoetry run pytestpoetry run pip-audit # Python vulnerabilities
cd vite && npm audit # npm vulnerabilitiesmain.py- Application entry point, creates Flask appapp/__init__.py- Flask app factory with Inertia.js and Vite integrationapp/http/controllers/dashboard_controller.py- Main route handler, processes form submissions and file uploads
barrier.py- Base Barrier class with shared properties (state space, monomials, data parsing)safety_barrier.py- SafetyBarrier class implementing CBC synthesis for all 4 system typesstability.py- Stability class implementing CLF synthesis for all 4 system types
Key computation flow:
- Parse input data (X0, X1, U0 matrices) from form or CSV files
- Check rank conditions for persistent excitation
- Solve SOS optimization using MOSEK solver via PICOS/SumOfSquares
- Return Lyapunov/barrier function and controller expressions
vite/- Vue 3 SPA with Tailwind CSSvite/main.js- Inertia.js app setupvite/js/Components/Pages/Dashboard.vue- Main interface- Uses Atomic Design: Atoms → Molecules → Organisms → Pages
storage/cases/- Example benchmark datasets with CSV files (X0T, X1T, U0T matrices)storage/uploads/- Temporary file uploads (auto-cleaned)
- MOSEK: Commercial SOS solver (requires license file uploaded via GUI)
- PICOS/SumOfSquares: Python SOS optimization interfaces
- SymPy: Symbolic mathematics for polynomial manipulation
- NumPy: Matrix operations and linear algebra
- Flask-Inertia: Server-side rendering bridge to Vue.js frontend
Key variables in .env:
FLASK_DEBUG/FLASK_ENV- Development mode settingsFLASK_KEY- Secret key for sessionsSENTRY_DSN- Error monitoring (optional)GUNICORN_PORT- Docker container port (default: 8000)