{
  "aliases": null,
  "backlinks": null,
  "body": "\n## Definition\n\nConsider a [[trajectory optimization|58895A7T4H]] problem on a fixed interval $[t_0, t_f]$: minimise $\\phi(x(t_f)) + \\int_{t_0}^{t_f} L(x, u, t) \\, dt$ subject to $x' = f(x, u, t)$, path constraints $c(x, u, t) \\le 0$ and boundary conditions $b(x(t_0), x(t_f)) = 0$.\nChoose a mesh $t_0 = \\tau_0 \u003c \\tau_1 \u003c \\cdots \u003c \\tau_N = t_f$ and an integer $s \\ge 1$.\nOn each interval $[\\tau_k, \\tau_{k+1}]$ choose $s$ collocation points $\\tau_k \\le \\tau_{k,1} \u003c \\cdots \u003c \\tau_{k,s} \\le \\tau_{k+1}$.\nThe *direct collocation* method replaces the problem by the following finite nonlinear program.\n\n1. The unknowns are the states $x_k$ at the mesh points and the controls at the collocation points. On each interval the state is a polynomial $p_k$ of degree at most $s$ with $p_k(\\tau_k) = x_k$.\n2. The dynamics are imposed only at the collocation points: $p_k'(\\tau_{k,j}) = f(p_k(\\tau_{k,j}), u(\\tau_{k,j}), \\tau_{k,j})$ for all $k$ and $j$, and the pieces join continuously, $p_k(\\tau_{k+1}) = x_{k+1}$.\n3. The path constraints hold at the collocation points and the boundary conditions at $x_0$ and $x_N$. The integral of $L$ becomes a quadrature sum.\n\nThe solution of this program is an approximate optimal trajectory.\n\n## Remarks\n\nEach choice of collocation points corresponds to an implicit [[Runge–Kutta method|7DBPJKYC6C]]; the state on each interval is a [[polynomial interpolant|SS1YMS2NPC]] of its values.\nWith $s = 2$ and the endpoints $\\tau_k, \\tau_{k+1}$ as collocation points, clause 2 becomes the trapezoidal rule $x_{k+1} - x_k = \\frac{h_k}{2} \\left( f(x_k, u_k, \\tau_k) + f(x_{k+1}, u_{k+1}, \\tau_{k+1}) \\right)$ with $h_k = \\tau_{k+1} - \\tau_k$.\nHermite–Simpson collocation uses the endpoints and the midpoint with a cubic state.\nThe nonlinear program is large but sparse, and it is usually solved by sequential quadratic programming or by interior-point methods.\n\nExample: minimise $\\int_0^1 \\frac{1}{2} u^2 \\, dt$ with $x' = u$, $x(0) = 0$, $x(1) = 1$, using trapezoidal collocation on a uniform mesh of step $h = 1/N$.\nThe program is: minimise $\\sum_{k=0}^{N-1} \\frac{h}{4} (u_k^2 + u_{k+1}^2)$ subject to $x_{k+1} - x_k = \\frac{h}{2} (u_k + u_{k+1})$, $x_0 = 0$, $x_N = 1$.\nThe choice $u_k = 1$, $x_k = k h$ satisfies all constraints.\nIt also satisfies the optimality conditions, with all multipliers of the dynamics constraints equal to one constant ($1$ or $-1$, by sign convention).\nIt reproduces the exact solution $u = 1$, $x(t) = t$ at the grid points.\n\nNon-example: direct single shooting integrates the dynamics forward from a guessed control and optimises only over the control values.\nIt is not collocation, because the states are not unknowns of the program.\n\n## Explanations\n\n### L1 human\n\nThe trajectory is replaced by grid values, the equations of motion are checked only at a few points per step, and a large finite optimisation problem is solved.\n",
  "commit": "ff8a40749dc16545e3d2fc637f6b0196e81d0bfa",
  "front": {
    "defines": "T58W34D60G",
    "kind": "definition",
    "msc": [
      "49M37",
      "49M25",
      "65L60"
    ],
    "name": "Direct collocation",
    "sources": [
      {
        "url": "https://en.wikipedia.org/wiki/Collocation_method"
      }
    ],
    "tag": "DT45YNKWSQ",
    "uses": [
      "58895A7T4H",
      "SS1YMS2NPC",
      "7DBPJKYC6C"
    ]
  },
  "kind": "definition",
  "link": "https://tamnd.github.io/math2/node/DT45YNKWSQ/",
  "links": [
    {
      "field": "defines",
      "target": "T58W34D60G"
    },
    {
      "field": "uses",
      "target": "58895A7T4H"
    },
    {
      "field": "uses",
      "target": "SS1YMS2NPC"
    },
    {
      "field": "uses",
      "target": "7DBPJKYC6C"
    }
  ],
  "markdown": "https://tamnd.github.io/math2/node/DT45YNKWSQ.md",
  "msc": [
    "49M37",
    "49M25",
    "65L60"
  ],
  "name": "Direct collocation",
  "prov": null,
  "role": "",
  "source": "https://github.com/tamnd/math2/blob/main/nodes/DT4/DT45YNKWSQ.md",
  "status": null,
  "tag": "DT45YNKWSQ",
  "uri": "m2://DT45YNKWSQ",
  "url": "https://tamnd.github.io/math2/wiki/direct-collocation-definition/",
  "writing": {
    "tag": "DT45YNKWSQ",
    "kind": "definition",
    "level": "W0",
    "next": [
      {
        "what": "an inventory row",
        "note": "the row of the inventory that the node accounts for",
        "have": 0,
        "want": 1
      },
      {
        "what": "a source with a locator",
        "have": 0,
        "want": 1
      }
    ]
  }
}
