Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding timeshifted input trajectories to opty. #1

Open
chris-konrad opened this issue Jan 3, 2025 · 1 comment
Open

Adding timeshifted input trajectories to opty. #1

chris-konrad opened this issue Jan 3, 2025 · 1 comment

Comments

@chris-konrad
Copy link
Owner

chris-konrad commented Jan 3, 2025

Motivation

For a dynamic system $\dot{x}(t) = f(x(t)) + u(t-\tau)$, one may want to estimate the unknown input delay $\tau$. Currently, opty does not support timeshift symbols and hence can't explicitly estimate this delay (See csu-hmc#224).

Method

A potential way to enable opty to find the desired $\tau$ directly is outlined as follows (credits to @moorepants)

  • Substitute $u(t-\tau) = u'(t)$ and consider $u'(t)$ an unknown trajectory and $\tau$ an unknown free parameter.
  • Consider $u(t)$ a known trajectory.
  • Create instance constraints $c_i(u'[i], \tau) = u'[i] - u[i-\frac{\tau}{\Delta t}]$ for all collocation nodes enforcing that.

Calculating the constrain Jacobian

The timeshift constraints have to be added to the constraint jacobian. For the constraints $c_i$ as defined above, the Jacobian is

  • for midpoint integration:
    $G_i = [\frac{\partial c_i}{\partial u[i]}, \frac{\partial c_i}{\partial \tau}] = [1, \frac{u'[i-\frac{\tau}{\Delta t}+1] - u'[i-\frac{\tau}{\Delta t}-1]}{2\Delta t} \cdot \frac{1}{\Delta t}]$

  • for backwards euler integration:
    $G_i = [\frac{\partial c_i}{\partial u[i]}, \frac{\partial c_i}{\partial \tau}] = [1, \frac{u'[i-\frac{\tau}{\Delta t}] - u'[i-\frac{\tau}{\Delta t}-1]}{\Delta t} \cdot \frac{1}{\Delta t}]$

Status

Development is ongoing in branch input-time-shifts. The current code does not run without exceptions and the added functions are untested.

@chris-konrad
Copy link
Owner Author

TODO List

  • Add a function to identify and substitute trajectories with a timeshift (16cc611, 89b7db3)
  • Verify that timeshift trajectories are given in the correct format (6f79482)
  • Require unshifted input to be a known trajectory (11ab07d)
  • Generate instance constraints (89b7db3)
  • Enable _find_closest_free_index() to create the indices of constraints with timeshift (b52a96f, 1e9a710, 11ab07d)
  • Enable _instance_constraints_func() to handle timeshift constraints. (b52a96f, 1e9a710, 11ab07d)
  • Enable _instance_constraints_jacobian_indices() to handle timeshift constraints (6f79482).
  • Enable jacobian_indices() to find the dynamic indices of timeshift constraints
  • Test if constraints_jacobian() needs to be adressed
  • Test code and unittests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant