asim — Neural Network Simulation & Optimal Control for Physical Systems
asim is a Python library for modeling, simulating, and optimizing physical systems using neural networks. It is designed for industrial process control — such as boilers, cooling systems, and heat exchangers — where data-driven state-space models replace first-principles equations.
Installation
pip install asim
What is asim
Train a neural network on historical sensor data, export it to ONNX, then run closed-loop simulation or gradient-based optimal control — all within a unified API.
- Data-driven state-space modeling — learns system dynamics from tabular time-series data with explicit separation of controllable inputs (
Vu), state variables (Vx), and time-varying parameters (Vc) - Automatic normalization — columns sharing a physical unit (
union=) are scaled together; scalers are baked into the ONNX export - ONNX simulation — autoregressive rollout via
onnxruntime; supports multi-group systems with cross-group wiring - Optimal control —
OffPolicyOptimizertranslates the ONNX graph into CasADi symbolic math and solves step-by-step MPC problems with IPOPT - Monotonicity checking —
Explainerverifies gradient sign constraints to catch physically implausible model behavior
Using asim
import matplotlib.pyplot as plt
import pandas as pd
from asim import Vt, Vu, Vx
from asim.dataset import PhysicalDataManage
from asim.explainer import Explainer
from asim.model import PhysicalFieldModel
from asim.optimizer import OffPolicyOptimizer
from asim.simulator import PhysicalSimulator
from asim.tool import DummyDatasets
# 1. Define data and structure
df = DummyDatasets.boiler_minimum(size=10000) # pd.read_csv("demo.csv")
cols = [
Vt(label="ts"),
Vu(group="boiler", label="heat_power1", minmax=(1.0, None), union="kw"),
Vu(group="boiler", label="heat_power2", minmax=(None, 90), union="kw"),
Vx(group="boiler", label="heat_temp", union="kj"),
]
dm = PhysicalDataManage(df, columns=cols, batch_size=64, seq_size=5)
# 2A. Select the model, define the parameters, train and save
fm = PhysicalFieldModel(dm, lr=0.002)
fm.fit(epochs=50)
fm.export("demo.sim.onnx")
# 2B. Check model
explainer = Explainer(dm, fm)
explainer.checkGrad()
# 2C. Use a simulator to simulate the operation
sim = PhysicalSimulator("demo.sim.onnx", dm=dm)
sim_df = df[0:1440].copy()
sim_df.index = pd.to_datetime(sim_df["ts"], unit="s", utc=True).dt.tz_convert("Etc/GMT-8")
sim_df = sim.steps(sim_df, x0={"heat_temp": sim_df["heat_temp"].iloc[0]})
sim.plots(sim_df)
plt.show()
# 3A. Build the optimizer
lTerm = lambda x, u, p: (x - p) ** 2 + 0.5 * (u[0] ** 2 + u[1] ** 2)
mTerm = lambda x, u, p: (x - p) ** 2
opt = OffPolicyOptimizer("demo.sim.onnx", dm=dm, lTerm=lTerm, mTerm=mTerm)
opt.fit(epochs=100)
opt.export("demo.opt.onnx")
# 3B. Use the optimizer
opt_df = opt.steps(df[0:360].copy(), interval=1)
opt.plots(opt_df)
plt.show()
Metadata
Release files for asim 26.6.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
Total release size: 16.4 MB
Release files / asim-26.6.1-cp314-cp314-win_amd64.whl
| Download URL | asim-26.6.1-cp314-cp314-win_amd64.whl |
|---|---|
| Size | 477.6 kB |
| Tags | CPython 3.14 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
271b0b87cdf16b4e387586f5ed5ccf41fb9a78c689486324137c731284a12455
|
|
BLAKE2b-256 checksum How to use checksums |
2e52a52e527c674d6c70ad2260d94f63da9310659d679f1fea656b84c2842672
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Release files / asim-26.6.1-cp314-cp314-win32.whl
| Download URL | asim-26.6.1-cp314-cp314-win32.whl |
|---|---|
| Size | 413.5 kB |
| Tags | CPython 3.14 Windows x86-32 |
|
SHA-256 checksum How to use checksums |
a2c5336531b7ff342823b55cc05c3115b9f5125e46b5915bc5e600f8a6eee7bc
|
|
BLAKE2b-256 checksum How to use checksums |
a85bdf9ee47357647f46244793ba83937c50e4dfad017ef8d830c7a1ce94e08f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Release files / asim-26.6.1-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
| Download URL | asim-26.6.1-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 4.0 MB |
| Tags | CPython 3.14 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
109e4747d32427526a2e5d804c8695cbcc435e0587c62fe60bac24c804da7f83
|
|
BLAKE2b-256 checksum How to use checksums |
869ca8d130fa0b10edc1a2a32ef3dc9ed6bf93a323857fd2f9a7a257a2b4359f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Release files / asim-26.6.1-cp314-cp314-macosx_11_0_arm64.whl
| Download URL | asim-26.6.1-cp314-cp314-macosx_11_0_arm64.whl |
|---|---|
| Size | 548.4 kB |
| Tags | CPython 3.14 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
e9c630d7a2b4d4cb0ef288542959670cf120b3aa86f1537b845bd031c4b1c92d
|
|
BLAKE2b-256 checksum How to use checksums |
43c10d7aab827d2b815ce69ce5e53eefe069dc58f2569024cc1796e2b47d02ed
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Release files / asim-26.6.1-cp313-cp313-win_amd64.whl
| Download URL | asim-26.6.1-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 466.4 kB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
31203823bd15feadba22af4dc609d750a9d288ff9b485b02b4aed72944f1c7a2
|
|
BLAKE2b-256 checksum How to use checksums |
3505d59049ec4ba550014ba3f80eae7e258c396b40b7f871ce2e3dc318dcf271
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Release files / asim-26.6.1-cp313-cp313-win32.whl
| Download URL | asim-26.6.1-cp313-cp313-win32.whl |
|---|---|
| Size | 403.5 kB |
| Tags | CPython 3.13 Windows x86-32 |
|
SHA-256 checksum How to use checksums |
88e261474ce007ff54f7ccab36f2b88dc94dd92e24509ad83d0289dd0fdb2568
|
|
BLAKE2b-256 checksum How to use checksums |
c30f32024a7ede04d58dd27886753d54e0707d4323d1333649436229c47a6dff
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Release files / asim-26.6.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
| Download URL | asim-26.6.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 4.0 MB |
| Tags | CPython 3.13 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
64c325467ac2b1c83391afbde99d208040225586c341213d20230d43b32fde31
|
|
BLAKE2b-256 checksum How to use checksums |
55e4a9899227417181e1dcab97c991d4a2327bd038690b4c4d804f2954d69ad0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Release files / asim-26.6.1-cp313-cp313-macosx_11_0_arm64.whl
| Download URL | asim-26.6.1-cp313-cp313-macosx_11_0_arm64.whl |
|---|---|
| Size | 543.1 kB |
| Tags | CPython 3.13 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
23e719eff89b9261a9f7e59ede600fc48c6da6717c321344a1673a3a7f0a701f
|
|
BLAKE2b-256 checksum How to use checksums |
5d55a07c1191db75a2912b7cf355460fc66b253f76ede873c406a11bb9e44b0d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Release files / asim-26.6.1-cp312-cp312-win_amd64.whl
| Download URL | asim-26.6.1-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 468.5 kB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
6586e65fc2be492a013e2c8e5e88a6ead0dbfc301f8037759ab949d068f3a81a
|
|
BLAKE2b-256 checksum How to use checksums |
4b3690d2d2418d4d211c10e25229e98d54e232ca065e07a989423ecdf2c1e714
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Release files / asim-26.6.1-cp312-cp312-win32.whl
| Download URL | asim-26.6.1-cp312-cp312-win32.whl |
|---|---|
| Size | 405.8 kB |
| Tags | CPython 3.12 Windows x86-32 |
|
SHA-256 checksum How to use checksums |
3614558e6c49b7f54194df734fd548c1121603cbac4ed0a11e8ab9c0af63cbe0
|
|
BLAKE2b-256 checksum How to use checksums |
c6f760d12e90c9bdeaf1a1ff1a7766c8ad4f6745e02968f8561865aabbdaf32c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Release files / asim-26.6.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
| Download URL | asim-26.6.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 4.1 MB |
| Tags | CPython 3.12 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
417dbe54f8adc012f2a5cc0899184c599fd816c367d05fda3ea1bb6ff8ef5dca
|
|
BLAKE2b-256 checksum How to use checksums |
276f3bc871189d395271862a3180a4ad9b4e6f01fa470c4d4c9c0af1e469af1e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Release files / asim-26.6.1-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | asim-26.6.1-cp312-cp312-macosx_11_0_arm64.whl |
|---|---|
| Size | 547.2 kB |
| Tags | CPython 3.12 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
add48159ee8ea63e4118f52823ca867e10656c350580a85bb8bfbef8ec8ebd67
|
|
BLAKE2b-256 checksum How to use checksums |
beb94d8af257952583c2b1025a9cf1f4a72b96fcdc967dd0b788c635ebd0c869
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Security for asim 26.6.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.