Karthik Elamvazhuthi
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.

      Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Explore these features while you wait
      Complete general settings
      Bookmark and like published notes
      Write a few more notes
      Complete general settings
      Write a few more notes
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.

    Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Explore these features while you wait
    Complete general settings
    Bookmark and like published notes
    Write a few more notes
    Complete general settings
    Write a few more notes
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Denoising LTI Systems In this lecture, we specialize our diffusion based feedback control to Linear Time Invariant Systems (LTIs), the Gaussian distributions of control theory (sorry, not sorry). Given that literature on methods to stabilize LTIs are *over-rich*, this might seem like a wasteful application. So let me calm your *BUT WHYYY?!*-nerves with two reasons to explore this case: 1. It provides a fun new way to solve the well known problem of steering a system to a target equilibrium using feedback. 2. It easily generalizes to broader objectives such as introducing multi-stability in a system. Lets consider the control system \begin{equation} \dot{x} = Ax+Bu. \end{equation} with $A$ and $B$ matrices of appropriate dimensions. The method to feedback control using the above model is identitical to what we saw in the [driftless nonlinear situtation](https://hackmd.io/QjdpXVeOSrWwPv_ON3QJNA). **i) Initialize the forward noising process at states that one wants to steer the system into**: \begin{equation} dX = -AX+\sqrt{2}BdW. \end{equation} $$X_0 \sim p_0(x)$$ **ii) Denoise the system back to goal configurations using the score function.** \begin{equation} \dot{x} = Ax+Bk(t,x). \end{equation} **where k(t,x) is learned from the forward process, is the denoising control. If system is controllable, all points eventually get steered into the points where $p_0(x)$ is positive.** A nice thing about the linear case is that [we know](https://hackmd.io/@clopenloop/H1StU_wO-g) for the forward noising process the probability density $p_t(x)$ evolves according to $$p_t(x) = \int_{\mathbb{R}^d} K(t,x,y) p_0(y)dy.$$ with kernel $$K(t,x,y)= \frac{1}{(2\pi)^{d/2} \, (\det \Sigma_t)^{1/2}} \exp\!\left( -\frac{1}{2} \bigl(x - e^{-tA} y\bigr)^\top \Sigma_t^{-1} \bigl(x - e^{-tA} y\bigr) \right),$$ where $$\Sigma_t = 2 \int_0^t e^{-sA} \, B B^\top \, e^{sA^\top} \, ds .$$ Lets see how this can be used in practice and how the feedback law simplifies in certain cases. ### Steering the System to the Origin using Time-varying Feedback First, we consider the situation where goal configuration is just a single state. Take the origin for example. Then we initialize the forward process at the origin: $$p_0(x) = \delta_{0}$$ or $X_0(\omega) = 0$ with probability 1. In this case, $$p_t(x) = K(t,x,0)$$ Substituting the expression we get, $$p_t(x) = \frac{1}{(2\pi)^{n/2} \, (\det \Sigma_t)^{1/2}} \exp\!\left( -\frac{1}{2} \bigl(x ^\top \Sigma_t^{-1} x) \right)$$ Computing the score we get, $$\frac{\nabla p_t(x)}{p_t(x)} = \frac{\Sigma_t^{-1}x}{K(t,x,0)}{K(t,x,0)} = \Sigma_t^{-1}x$$ The forward process has the same probability density as the ODE: $$\dot{x} = -Ax - Bu \quad u = B^T\Sigma_t^{-1}x. $$ That the probability density of the two processes are the same can be seen as before, using the corresponding equations for evolution of probability densities: We know that $p_0(x) = \delta_0$ and $p_t(x) >0$ for all $x \in \mathbb{R}^d, t>0$ Considering the reverse process we get, $$\dot{x} = Ax + Bu \quad u = B^T\Sigma_{T-t}^{-1}x $$ [Recall that](https://hackmd.io/QjdpXVeOSrWwPv_ON3QJNA) the Fokker-Planck equation of the forward process and the continuity equation of the reverse process have identical solutions, upto a time change: *Fokker-Planck equation of the forward process is given by,* $$\frac{\partial p_t(x)}{\partial t} = \nabla \cdot( [Ax] p_t(x)) + \nabla \cdot( BB^T \nabla p_t(x)) $$ *This equation can be equivalently written as the continuity equation with control $u = B^T \frac{\nabla p_t(x)}{p_t(x) } = B^T\Sigma_{T-t}^{-1}x$ is given by* $$\frac{\partial p_t(x)}{\partial t} = \nabla \cdot( [Ax + Bu] p_t(x)).$$ Since $\lim_{t \rightarrow 0} p_t(x) = \delta_0$, we get that the control system (or the reverse process), $$\dot{x} = Ax + Bu$$ converges to $$\lim_{t \rightarrow T} x(t) = 0$$ in some sense. ### Comparison with Minimum Energy Control It is an interesting phenomena, that we have recovered a control law using the controllability Gramian. This is similar to how the Gramian provides the [minimum energy control](https://en.wikipedia.org/wiki/Minimum_energy_control) to steer a system from one initial state to another. However, the minimum energy control is usually given in open loop form. In order to get the solution in feedback form, one has to solve a Riccati equation, which for the finite horizon case doesn't have a closed form solution. While we might be tempted to conclude that we have recovered the minimum energy control in feedback form, the feedback control we have constructed blows up as $t \rightarrow T$ due to the degeneracy of the Gramian inverse in this limit. ### Stabilizing to Multiple Equalibria A similar strategy works if we have multiple target equilibrium points. Let $$p_0(x) = \frac{1}{2}\delta_{a} + \frac{1}{2}\delta_{b}$$ for two points, $a,b$ in ${\ker} ~ A$. In this case, $$p_t(x) = \frac{1}{2}K(t,x,a)+ \frac{1}{2}K(t,x,b).$$ The score function in this case becomes, $$\frac{\nabla p_t(x)}{p_t(x)} = \frac{ \Sigma_t^{-1}(x-a) K(t,x,a)+\Sigma_t^{-1}(x-b) K(t,x,b) }{K(t,x,a)+ K(t,x,b)} $$ This gives us the closed-loop system in reverse: $$\dot{x} = Ax + Bu \quad u = B^T\frac{\nabla p_t(x)}{p_t(x)} $$ ### Numerical Example Following is an example for a four dimensional linear system, with two position coordinates and two velocity coordinates, with accelerations as the controls. The system is first stabilized to the origin. The system is the following. \begin{align} \begin{aligned} \dot{x}_1 &= x_2, \ \ \dot{x}_2 = x_1 + u_1 \ \ \dot{x}_3 = x_2, \ \ \dot{x}_4 = x_3 + u_2 \end{aligned} \end{align} The plots show the evolution of the position coordinates. ![trajectories](https://hackmd.io/_uploads/HyRXxMFtbg.gif) In the next example, we stabilize to a combination of two target positions with $0$ velocities both in $x-$ and $y-$ coordinates. ![trajectories](https://hackmd.io/_uploads/ByhmuRtAye.gif) ### Steering to More General Distributions $p_0(x)$ For more general distributions computing the kernel $K(t,x,y)$ can be expensive. So one instead learns the score loss: $$ \mathbb{E}_{x \sim p^{\rm fwd}_t} \left[ \left\| s_\theta(t, x) - \nabla \log p_t(x) \right\|^2 \right]. $$ See post by [Yang Song]( https://yang-song.net/blog/2021/score/), on how this loss can be minimized if one has samples of $p_t(x)$ (which we get by running the forward process from multiple initial conditions sampled from $p_0(x)$. Once the score has been learned, we apply the feedback law $u(t) = B^T\nabla p_{T-t}(x)$ If one wants the solution of the reverse proces to converge in distribution exactly to $p_0(x)$, not just to the support of $p_0(x)$, it is also important that the forward process is stable and converges to a invariant distirbution $p_{\infty}$: $$p_{\infty}(x) = \frac{1}{(2\pi)^{n/2} \, (\det \Sigma_{\infty})^{1/2}} \exp\!\left( -\frac{1}{2} x ^\top \Sigma_{\infty}^{-1} x \right),$$ where $$\Sigma_{\infty} = 2 \int_0^{\infty} e^{sA} \, B B^\top \, e^{sA^\top} \, ds$$ In general, the denoising algorithm can be summarized in the following way. $$\boxed{\begin{aligned} &\textbf{Algorithm (Score Matching for LTI Feedback Control)}\ \\[4pt] &1.\ \text{Sample $X_i(0) \sim p_0(x)$}. \\[4pt] & 2.\ \text{Run the forward process} \\ & \qquad \qquad dX = -AX + \sqrt{2}BdW \\ & 2.\ \text{Sample } x^i_0 \sim p_0(x) &3.\ \text{ Simulate the forward process } t). \\[4pt] & 3. \ \text{Compute the score matching loss:} \\ &\qquad\qquad \mathcal{L}(\theta) = \mathbb{E}_{x \sim p^{\rm fwd}_t} \left[ \left\| s_\theta(t, x) - \nabla \log p_t(x) \right\|^2 \right]. \\[4pt] &4.\ \text{Stabilize the control system using learnt score} \\ & \quad 4.1 \ \text{If goal is density control to $p_0(x)$, sample}, x_i(0) \sim p_\infty(x),\\ &\qquad\qquad \dot{x}_i(t) = A x_i(t) + B u(t), \quad u(t) = B^T s_\theta(t, x_i(t)). \\[4pt] & \quad 4.2 \ \text{If goal is to steer the system to support of $p_0(x)$, $x(0)$ can be arbitary}, \\ &\qquad\qquad \dot{x}_i(t) = A x_i(t) + B u(t), \quad u(t) = B^T s_\theta(t, x_i(t)). \\[4pt] \end{aligned}} $$ ## References The contents of this blog are based on the presentation in our preprint, [Score Matching Diffusion Based Feedback Control and Planning of Nonlinear Systems](https://www.researchgate.net/publication/390746280_Score_Matching_Diffusion_Based_Feedback_Control_and_Planning_of_Nonlinear_Systems) by myself, Darshan Gadginmath and Fabio Pasqualetti.

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password
    or
    Sign in via Facebook Sign in via X(Twitter) Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    By signing in, you agree to our terms of service.

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully