SkillAgentSearch skills...

finite-horizon-lqr

Solving finite-horizon LQR via dynamic programming for MPC.

Install / Use

npx skills add benchflow-ai/skillsbench --skill finite-horizon-lqr

Installs into whichever agent you are using.

About this skill
📄

SKILL.md

Installable skill definition

Quality Score

69/100

Supported Platforms

Universal

Our assessment of finite-horizon-lqr

finite-horizon-lqr scores 69/100 on our quality scale, 3367th of 4,258 Development & Engineering skills we index.

Its SKILL.md is 1.1 KB long, split into 6 sections with 4 code examples: fairly brief, so expect to fill in details yourself.

With 1,813 GitHub stars, it is one of the more widely adopted skills in the catalogue.

Substance
14/30
Structure
18/20
Description
8/15
Adoption
14/20
Freshness
15/15

Maintenance, license and trust

  • The repository was last updated about 2 months ago, so finite-horizon-lqr is actively maintained.
  • It is released under the Apache-2.0 license, a permissive license that allows use, modification and commercial use with attribution.
  • Its trust signals score 100/100, with no cautions. These come from repository metadata, not a code audit — read the skill file before letting an agent act on it.

finite-horizon-lqr compared with similar skills

All 4 of these similar skills score higher than finite-horizon-lqr; compare them before choosing.

SkillScoreStarsUpdatedFormat
finite-horizon-lqr (this skill)by benchflow-ai691.8k2mo agoSKILL.md
Agent-Reachby Panniantong10086.9k15d agoCLAUDE.md
headroomby headroomlabs-ai10074.2ktodayCLAUDE.md
ai-job-searchby MadsLorentzen10044.6k1d agoCLAUDE.md
claude-howtoby luongnv8910041.7ktodayCLAUDE.md

Frequently asked questions

How do I install finite-horizon-lqr?
Run npx skills add benchflow-ai/skillsbench --skill finite-horizon-lqr. The install tabs above show the steps for each supported agent.
Which AI agents does finite-horizon-lqr work with?
It is written for Universal, as a SKILL.md file. Other agents that read the same format can often use it too.
Is finite-horizon-lqr safe to use?
It is Apache-2.0-licensed and scores 100/100 on trust signals. Skills are instructions an agent will follow, so read the file before installing it and do not approve commands you do not understand.
Is finite-horizon-lqr still maintained?
The repository was last updated about 2 months ago, so finite-horizon-lqr is actively maintained.

name: finite-horizon-lqr description: Solving finite-horizon LQR via dynamic programming for MPC.

Finite-Horizon LQR for MPC

Problem Formulation

Minimize cost over horizon N:

J = Σ(k=0 to N-1) [x'Qx + u'Ru] + x_N' P x_N

Backward Riccati Recursion

Initialize: P_N = Q (or LQR solution for stability)

For k = N-1 down to 0:

K_k = inv(R + B'P_{k+1}B) @ B'P_{k+1}A
P_k = Q + A'P_{k+1}(A - B @ K_k)

Forward Simulation

Starting from x_0:

u_k = -K_k @ x_k
x_{k+1} = A @ x_k + B @ u_k

Python Implementation

def finite_horizon_lqr(A, B, Q, R, N, x0):
    nx, nu = A.shape[0], B.shape[1]
    K = np.zeros((nu, nx, N))
    P = Q.copy()

    # Backward pass
    for k in range(N-1, -1, -1):
        K[:,:,k] = np.linalg.solve(R + B.T @ P @ B, B.T @ P @ A)
        P = Q + A.T @ P @ (A - B @ K[:,:,k])

    # Return first control
    return -K[:,:,0] @ x0

MPC Application

At each timestep:

  1. Measure current state x
  2. Solve finite-horizon LQR from x
  3. Apply first control u_0
  4. Repeat next timestep

Related Skills

View on GitHub
GitHub Stars1.8k
CategoryDevelopment
Updated2mo ago
Forks368

Languages

PDDL

Trust signals

100/100

From repository metadata: license, adoption, age and documentation. Not a code audit — see the Safety scan above for what the skill file itself contains.

No cautions