finite-horizon-lqr

Compute optimal state-feedback gains for finite-horizon LQR problems.

Updated Jan 15, 2026
One-click install
npx skills add https://github.com/KaiserWhoLearns/skillsbench --skill finite-horizon-lqr
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: finite-horizon-lqr
Source: https://github.com/KaiserWhoLearns/skillsbench/tree/main/tasks/r2r-mpc-control/environment/skills/finite-horizon-lqr
Command: npx skills add https://github.com/KaiserWhoLearns/skillsbench --skill finite-horizon-lqr

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires numpy.

What problem does it solve?

Solves finite-horizon LQR problems for MPC by computing the optimal sequence of state-feedback gains.

Core Features & Use Cases

  • Backward Riccati recursion to compute optimal feedback gains for each step.
  • Forward simulation using the computed gains to generate the first control input from an initial state.
  • Applicable to linear-quadratic control problems within model-predictive control workflows and real-time scenarios.

Quick Start

Run finite-horizon LQR with your A, B, Q, R matrices and horizon N to compute the first control input from x0.

Frequently Asked Questions about finite-horizon-lqr

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I compute the first control input for a finite-horizon LQR problem?

To compute the first control input for finite-horizon LQR, provide your system matrices A, B, Q, R, the horizon N, and initial state x0. The solver performs backward Riccati recursion to calculate optimal feedback gains and returns the first input.

Can I use finite-horizon LQR for model-predictive control workflows?

Yes, finite-horizon LQR is designed for model-predictive control workflows. It computes a short-horizon policy by calculating optimal state-feedback gains, making it suitable for real-time linear-quadratic control scenarios.

What matrices do I need to run a finite-horizon LQR solver?

You need state matrix A, input matrix B, state cost matrix Q, input cost matrix R, the time horizon N, and the initial state x0 to run a finite-horizon LQR solver and generate the optimal control sequence.

Does finite-horizon LQR support linear time-varying systems?

Yes, finite-horizon LQR supports both linear time-invariant and time-varying systems. It applies backward Riccati recursion to compute the optimal sequence of state-feedback gains for your specified short horizon.

Do I need numpy to solve finite-horizon LQR problems with this approach?

Yes, you need numpy installed to solve finite-horizon LQR problems using this method. The solver relies on numpy for handling the matrix operations required during backward Riccati recursion and forward simulation.

What is the difference between finite-horizon and infinite-horizon LQR?

Finite-horizon LQR computes a distinct sequence of optimal state-feedback gains for each step over horizon N, whereas infinite-horizon LQR converges to a single steady-state gain. This makes finite-horizon suitable for short-horizon policies in MPC.