fixed car example #4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| pull_request: | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| lint: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: astral-sh/setup-uv@v6 | |
| with: | |
| enable-cache: true | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| - run: uv sync --locked | |
| - run: uv run ruff check tbm tests examples | |
| test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: astral-sh/setup-uv@v6 | |
| with: | |
| enable-cache: true | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| - run: uv sync --locked | |
| - run: uv run pytest | |
| package: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: astral-sh/setup-uv@v6 | |
| with: | |
| enable-cache: true | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| - run: uv build | |
| - run: python -m venv /tmp/tbm-wheel-test | |
| - run: /tmp/tbm-wheel-test/bin/python -m pip install --upgrade pip | |
| - run: /tmp/tbm-wheel-test/bin/python -m pip install dist/*.whl | |
| - name: Smoke test installed wheel | |
| working-directory: /tmp | |
| run: | | |
| /tmp/tbm-wheel-test/bin/python - <<'PY' | |
| import numpy as np | |
| from tbm import InitialGuess, TBMConfig, TBMProblem, solve | |
| def rollout(initial_states, control_segments): | |
| states = np.zeros((initial_states.shape[0], control_segments.shape[1] + 1, 1)) | |
| states[:, 0, :] = initial_states | |
| for step in range(control_segments.shape[1]): | |
| states[:, step + 1, 0] = states[:, step, 0] + control_segments[:, step, 0] | |
| return states | |
| result = solve( | |
| TBMProblem( | |
| state_dim=1, | |
| control_dim=1, | |
| horizon=2, | |
| initial_state=np.array([0.0]), | |
| rollout=rollout, | |
| ), | |
| InitialGuess(controls=np.zeros((1, 1))), | |
| TBMConfig(max_iterations=1), | |
| ) | |
| assert result.history | |
| PY |