Skip to main content

Multiphase Adaptive Trajectory Optimizer

Project description

MAPTOR

MAPTOR: Multiphase Adaptive Trajectory Optimizer

PyPI version Python 3.10+ License: LGPL v3

Author: David Timothy

Contact: chendavidtimothy@gmail.com

A Python framework for trajectory optimization using optimal control. MAPTOR solves problems involving the motion of vehicles, robots, spacecraft, and other dynamic systems through space and time using the Legendre-Gauss-Radau pseudospectral method and phs-adaptive mesh refinement.

What is Trajectory Optimization?

Trajectory optimization finds the best path for a dynamic system to follow, considering:

  • Physics: System dynamics and constraints
  • Objectives: Minimize time, fuel, energy, or tracking error
  • Constraints: Safety limits, obstacle avoidance, boundary conditions

Mathematical Foundation: MAPTOR applies optimal control theory to transform continuous trajectory optimization problems into solvable nonlinear programming problems through spectral collocation methods.

Core Methodology

MAPTOR implements the Legendre-Gauss-Radau pseudospectral method with:

  • Spectral accuracy: Exponential convergence for smooth solutions
  • Adaptive mesh refinement: Automatic error control through phs-adaptive mesh refinement method
  • Multiphase capability: Complex missions with automatic phase linking
  • Symbolic computation: Built on CasADi for exact differentiation and optimization

Quick Start

import maptor as mtor

# Minimum-time trajectory: reach target with bounded control
problem = mtor.Problem("Minimum Time to Target")
phase = problem.set_phase(1)

# Variables
t = phase.time(initial=0.0)  # Free final time
position = phase.state("position", initial=0.0, final=1.0)
velocity = phase.state("velocity", initial=0.0, final=0.0)
force = phase.control("force", boundary=(-2.0, 2.0))

# Dynamics and objective
phase.dynamics({position: velocity, velocity: force})
problem.minimize(t.final)

# Solve
phase.mesh([8], [-1.0, 1.0])
solution = mtor.solve_adaptive(problem)

if solution.status["success"]:
    print(f"Optimal time: {solution.status['objective']:.3f}")
    solution.plot()

Problem Classes

Beyond Spatial Trajectories: MAPTOR also handles abstract optimal control problems where "trajectory" refers to the evolution of any system state over time (chemical processes, financial optimization, resource allocation).

Installation

pip install maptor

Requirements: Python 3.10+, NumPy, SciPy, CasADi, Matplotlib

Development Installation:

git clone https://github.com/maptor/maptor.git
cd maptor
pip install -e .

Documentation

Resource Description
Installation Guide Setup and dependencies
Quick Start Basic workflow and first example
Problem Definition Tutorial Comprehensive problem construction guide
Solution Analysis Tutorial Working with optimization results
Examples Gallery Complete problems with mathematical formulations
API Reference Detailed function documentation

Example Trajectories

The examples gallery demonstrates trajectory optimization across multiple domains:

Advanced Aerospace Applications

Advanced Robotics and Control

Atmospheric and Environmental Systems

Interdisciplinary Applications

Benchmark and Classical Problems

Architecture

MAPTOR provides a layered architecture separating trajectory design from numerical implementation:

User API (Problem, solve_adaptive, solve_fixed_mesh)
         ↓
Trajectory Definition (States, controls, dynamics, constraints)
         ↓
Mathematical Framework (Radau pseudospectral method)
         ↓
Symbolic Computation (CasADi expressions and differentiation)
         ↓
Optimization (IPOPT nonlinear programming solver)

Key Design Principles:

  • Intuitive API: Define trajectories naturally without numerical details
  • Automatic differentiation: CasADi handles complex derivative computations
  • Adaptive precision: Mesh refinement ensures solution accuracy
  • Multiphase support: Complex missions with automatic phase transitions

Contributing

We currently do not accept code submissions, but we welcome issues and feedback reports from the trajectory optimization and optimal control community. Please use GitHub Issues to:

  • Report bugs or unexpected behavior
  • Request new features or enhancements
  • Ask questions about usage or implementation
  • Suggest improvements to documentation or examples
  • Share feedback on your experience with MAPTOR

Your input helps improve MAPTOR for the entire community.

License

MAPTOR is licensed under the GNU Lesser General Public License v3.0. This allows use in both open source and proprietary applications while ensuring improvements to the core library remain open.

Citation

If you use MAPTOR in academic research, please cite:

@software{maptor2025,
  title={MAPTOR: Multiphase Adaptive Trajectory Optimizer},
  author={Timothy, David},
  year={2025},
  url={https://github.com/maptor/maptor},
  version={0.2.0}
}

References

MAPTOR builds upon established methods in computational optimal control:

Optimal Control Theory and Methods:

Pseudospectral Methods:

  • Agamawi, Y. M., & Rao, A. V. (2020). CGPOPS: A C++ Software for Solving Multiple-Phase Optimal Control Problems Using Adaptive Gaussian Quadrature Collocation and Sparse Nonlinear Programming. ACM Transactions on Mathematical Software, 46(3), Article 25. https://doi.org/10.1145/3390463

Adaptive Mesh Refinement:

  • Haman III, G. V., & Rao, A. V. (2024). Adaptive Mesh Refinement and Error Estimation Method for Optimal Control Using Direct Collocation. arXiv preprint arXiv:2410.07488. https://arxiv.org/abs/2410.07488

Symbolic Computation Framework:

  • Andersson, J. A. E., Gillis, J., Horn, G., Rawlings, J. B., & Diehl, M. (2019). CasADi -- A software framework for nonlinear optimization and optimal control. Mathematical Programming Computation, 11(1), 1-36. https://doi.org/10.1007/s12532-018-0139-4

Support

Acknowledgments

MAPTOR implements methods from the computational optimal control literature, particularly pseudospectral collocation techniques and adaptive mesh refinement strategies. The framework leverages CasADi for symbolic computation and automatic differentiation.


Next Steps: Begin with the Quick Start Guide or explore the Examples Gallery to see MAPTOR applied to trajectory optimization problems in your domain.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

maptor-0.2.0.tar.gz (103.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

maptor-0.2.0-py3-none-any.whl (95.4 kB view details)

Uploaded Python 3

File details

Details for the file maptor-0.2.0.tar.gz.

File metadata

  • Download URL: maptor-0.2.0.tar.gz
  • Upload date:
  • Size: 103.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for maptor-0.2.0.tar.gz
Algorithm Hash digest
SHA256 f6569cd19e78a7cda019641c14f8a7212f8304c9d0f5bc5ee132e0229f4ff621
MD5 a00e2a8d17a7dac22a3e63765039df58
BLAKE2b-256 b2f9308d2fc6b5b3d3a1afde4fb84dab34ab6c8d03a97a51020697b2a8bd479d

See more details on using hashes here.

Provenance

The following attestation bundles were made for maptor-0.2.0.tar.gz:

Publisher: release.yml on maptor/maptor

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file maptor-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: maptor-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 95.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for maptor-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 871f81a26adc91fd652041ef8f954d7ef64f5ce7ce2bea028e9c88b66d11f72a
MD5 f7a03664d7061a89a35b4e028e37ca17
BLAKE2b-256 ba981fcfed31d8b9d5fe3aa98b8f89c64bd7b5c24beb4d4a52cee4bcdc8bb7cf

See more details on using hashes here.

Provenance

The following attestation bundles were made for maptor-0.2.0-py3-none-any.whl:

Publisher: release.yml on maptor/maptor

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page