Spaces:
Sleeping
Sleeping
File size: 2,170 Bytes
5f38e95 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | """Hybrid physics + data-driven learning layer.
Three workflows live here, intentionally kept compositional rather than
unified:
* **Reinforcement learning.** A Gymnasium-compatible :class:`CDPREnv` wraps
the Phase-1 simulator and exposes the standard reset / step / reward
contract; :mod:`cdpr.learn.rl` provides thin Stable-Baselines3 adapters
for PPO / SAC / TD3 that share a logging callback recording
per-step physics diagnostics (condition number, infeasibility) alongside
the usual reward / loss curves.
* **Supervised learning.** :class:`cdpr.learn.datasets.TrajectoryDataset`
turns a :class:`SimulationResult` or :class:`IngestedExperiment` into a
PyTorch ``Dataset`` of state-target pairs, and :mod:`cdpr.learn.models`
ships an MLP inverse-dynamics regressor as the canonical baseline.
* **Physics-informed neural networks.** :class:`cdpr.learn.models.pinn.InverseDynamicsPINN`
layers a Newton-Euler residual on top of the supervised loss; the
framework's structure matrix evaluates the physics term so the network
is *always* anchored to the geometric model it is learning to amend.
Interpretability is a hard requirement. Every model exposes
``predict_with_components`` that returns the prediction *plus* its data /
physics residuals, and the training loop logs each loss component
separately. The :mod:`cdpr.learn.benchmark` harness then runs analytic,
PD, computed-torque, and learned controllers on the same task and emits
a side-by-side comparison.
Optional dependencies:
* ``pip install 'cdpr[learn]'`` -- PyTorch + Gymnasium for supervised / PINN /
env construction.
* ``pip install 'cdpr[rl]'`` -- adds Stable-Baselines3 on top.
"""
from cdpr.learn._lazy import (
require_gymnasium,
require_stable_baselines3,
require_torch,
)
from cdpr.learn.rewards import (
ActionSmoothness,
InfeasibilityPenalty,
PoseTracking,
RewardSum,
TensionCost,
VelocityTracking,
)
__all__ = [
"require_torch",
"require_gymnasium",
"require_stable_baselines3",
"PoseTracking",
"VelocityTracking",
"ActionSmoothness",
"TensionCost",
"InfeasibilityPenalty",
"RewardSum",
]
|