Introduction
These are notes for tutorials of the subject “Optimal and Predictive Control System” taught at the Faculty of Mechanical Engineering at the Czech Technical University in Prague.
Dating back to the 1950s optimal control is an every evolving field currently fueled by the incredible (from a historic point of view) amounts of computational power at our disposal. Although in this course we only cover the fundamentals as applied to linear system which can be successfully implemented on microcontrollers, cutting-edge approaches push hardware to its limits, allowing for the control of walking robots, autonomous vehicles, etc.
The materials are loosely divided into three blocks. We cover the basics of numerical optimization which we will become relevant for optimal control only at the very end of the course. Regardless we will attempt to provide examples that demonstrate their utility as we go. Then we will move on to the main content of the course. Starting from the quite abstract concept of the Bellman principle we cover the topic of the linear-quadratic regulator (LQR) from which we will transition to model predictive control (MPC).
We will apply each control strategy to the system of a bi-rotor, i.e. a quad-rotor simplified into the horizontal plane. As supplementary materials we will show how its dynamic model can be derived.
DISCLAIMER: These notes have not gone through a peer review process and are likely to contain (hopefully only minor) mistakes.
Controllability/Reachability
Controllability and reachability are defined for discrete-time systems as:
- A system is controllable if from any state one can achieve the state using a series of inputs .
- A state is reachable if it can be achieved by applying a series of inputs when starting from the initial state .
For continuous-time systems they are similarly defined as:
- A system is controllable if from any state one can achieve the state using a control policy , .
- A state is reachable if it can be achieved by applying a control policy , when starting from the initial state .
For linear systems all states are reachable if the system is controllable.
Controlability of LTI Discrete-Time Systems
The first states of a linear time-invariant system assuming an initial state and a series of inputs , can be expressed as For square matrices that satisfy their own characteristic equation the Cayley-Hamilton theorem states that for we may express as a linear combination of the lower matrix powers of : Therefore, the state can be rewritten as which can be manipulated into the form where is the controllability matrix.
The same substitution can be applied also for subsequent timesteps up-to infinity, changing only the particular form of the vector of inputs’ linear combinations. This has two consequences:
- All states reachable in steps are also reachable in steps (with unlimited inputs).
- If is rank deficient, some directions in the state-space cannot be effected by the inputs and therefore the system is uncontrollable.
Controlability of LTI Continuous-Time Systems
The state of a linear time-invariant system at time , starting from the initial state and influenced by a continuous input , can be expressed as For square matrices that satisfy their own characteristic equation the Cayley-Hamilton theorem has a consequence that the inifinite series can be expressed using a finite number of terms After substituting it back into the second term of (1) we attain which can be further manipulated into the form where is the controllability matrix. If is rank deficient, some directions in the state-space cannot be effected by the inputs and therefore the system is uncontrollable.
State-Space Representation of Mechanical Systems
Equations of Motion
Let us consider manipulator equations in the form who’s left-hand side may be for example derived from the system’s kinetic and potential energy expressed in generalized coordinates by expanding Lagrange equations of the second kind where . First by separating the Lagrangian into its components and then applying the change rule If the external forces are linearly dependent on inputs , such that , the terms of (1) as derived by this approach are
Continuous-time dynamics
Most commonly used state-space representation of a mechanical system in continuous time is attained by concatenating and to form the system’s state
Linearization
The system’s dynamics can be linearized by performing a Taylor expansion around a point which yields where also .
If is a fixed point, i.e. , first order partial derivatives of the system’s dynamics simplify to as terms involving drop out because for all fixed points. Partial derivatives of also disappear as all of its terms contain second degree products of velocities and all velocities must be equal to zero at a fixed point.
Explicit Euler method discretization
The most basic approach with which we may discretize continuous-time dynamics of a nonlinear system is by integrating the systems state with a timestep of using the explicit Euler method
Linearization
Compared to more advanced integration methods, linearization of these discrete time dynamics around a point is trivial:
Cart-Pole Equations of Motion
For generalized coordinates the system’s kinetic and potential energy are where The individual terms of the manipulator equations1 are then assuming a single input is acting in the direction of .
Linearization in the upright configuration
From the equations we may see that for the state and input vectors all points are stationary. In this configuration the relevant terms for the system’s linearization are
-
The python script for the derivation of the following terms can be found here. A very similar form of these equations of motion can also be found in section 3.2.1 of Underactuated2023. ↩
Bi-Rotor Equations of Motion
As a bi-rotor (quadcopter simplified to 2D) is essentially a rigid body, its equations of motion can be easily derived as
Linearization in a hovering configuration
From the EoM we may see that for the state description all points are stationary points, for which the system’s linearization is trivial
Derivation in manipulator equation form
For those who want to validate the equations by deriving the manipulator equations, kinetic and potential energy for generalized coordinates are which should yield The manipulation matrix can then be derived separately by evaluating thrust vectors and differentiating moment arms.
Bi-Rotor with Payload
For generalized coordinates the system’s kinetic and potential energy are where The two forces acting on the system and their action arms are The individual terms of the manipulator equations are then
Convex optimization problems
The vast majority of numerical optimization problems can be written in the form where are optimized variables, is the objective function, are inequality constraints and are equality constraints. Here we assume that , , and lie in and that constraints and define a non-empty set of feasible solutions.
Based on the properties of , , and , different approaches can be taken to solve the optimization problem. For example, if the objective function is convex and the constraint are affine the problem has a unique solution (optimal value of the objective function) that can be found using gradient descend. In this course we will focus on this type of problems which are classified as convex.
We will start with a general overview of Lagrangian Duality and KKT conditions which are applicable to both convex and non-convex optimization problems. Then we will describe two specific types of convex optimization problems: linear programming (LP) and quadratic programming (QP).
Lagrangian Duality
In the following section we will derive the so-called dual problem of a (primal) optimization problem, following the derivation demonstrated in a series of short lectures which accompany the book Bierlaire2018. Possibly the most important property of the dual problem (from a practical point of view) is that it is convex even if the primal optimization problem is not Boyd2004.
Let us consider a constrained optimization problem in the form to which we will refer to as the primal problem. With regard to this problem, let us define the Lagrangian where and are Lagrange multipliers, and the dual function
Theorem
Let be the solution to the primal problem. If , then
Proof
(For any and , I can find an that minimizes the Lagrangian as well as or better than by violating the constraints.)
and
(Because if and then )
Corollary
Let be the solution to the primal problem and feasible w.r.t its constraints. If and , , then
Dual problem
As was proven provides a lower bound on the solution of the primal problem when . The dual problem can then be regarded as maximing this lower bound by penalizing violations of the primal problem’s constraints using the Lagrange multipliers:
The second condition states that we consider on and such that the dual function is bounded. This is necessary for the problem to be well posed.
(Weak duality) theorem
If is the solution to the primal problem and is the solution to the dual problem, then
Corollary
If one problem is unbounded the other is infeasible.
Corollary
If such that they are optimal.
Karuch-Kuhn-Tucker Conditions
The Karuch-Kuhn-Tucker (KKT) conditions are first order necessary conditions for finding the solution of an optimization problem in the form Furthermore, they are also sufficient conditions for convex problems, i.e. those where , are convex and is affine (linear) Boyd2004.
A solution satisfying these conditions gives us not only but also the Lagrange multipliers and present in the Lagrangian
The conditions are as follows:
-
stationarity (The linear combination of the constraints’ gradients has to be equal to the objective function’s gradient.)
-
primal feasibility (Constraints of the stated optimization problem have to be satisfied.)
-
dual feasibility (For a given , the columns of define a polyhedral cone in which must lie.)
-
complementary slackness (If lies inside the feasible set w.r.t to the condition , then and therefore .)
Physical interpretation
The KKT conditions can be intuitively derived though an analogy where is a potential field, for example of gravity of magnetism. Let us first address only the inequality constrained case where the inequality constraints can be regarded as physical barriers. If we then recall the Lagrangian the multipliers and can be viewed as contact forces acting against the influence of the potential field.
From this analogy we can immediately recover the dual feasibility and complementary slackness conditions (4-5) as contact forces can only be positive and do not act at a distance. The stationarity condition (1) (without the term related to the equality constraint) can then be interpreted as the contact forces and the pull of potential field being in equilibrium, which must occur at a local minima. Lastly, we are considering only solutions within the bounds of the inequality constraints, as if we were initially placed within them, satisfying the primal feasibility condition (2).
To incorporate equality constraints into this analogy we can simply reformulate them as likening them to being sandwiched between two surfaces. As we are always in contact there is no need for a complementary slackness condition and due to its bi-directional nature, elements of can be both positive and negative. Therefore we must only include a primal feasibilty condition (2) and add an additional term to the stationarity condition (1).
Linear Programming
Let us consider a constrained optimization problem in the form
As both the objective function and constraints are linear the problem is convex. For this reason KKT conditions are not only necessary but also sufficient if a feasible w.r.t the constraints exists.
KKT conditions
The KKT conditions of this problem can be states as:
Dual problem
The dual problem of the LP problem can be written as where the Lagrangian can be manipulated into the form As we are only looking for bound solutions (last constraint) the condition must be satisfied and therefore When substituted back into the original dual problem, after basic manipulations, we attain
Quadratic Programming
Let us consider a constrained optimization problem in the form where .
As the objective function is quadratic and the constraints linear the problem is convex. For this reason KKT conditions are not only necessary but also sufficient if a feasible w.r.t the constraints exists.
KKT Conditions
The KKT conditions of this problem can be states as:
Dual problem
The dual problem of the QP problem can be written as where the Lagrangian can be manipulated into the form Its critical point can be found by solving which yields When substituted back into the original dual problem, after basic manipulations, we attain
Bellman Principle
According to Bellman1966 “an optimal policy has the property that, whatever the initial state and initial decision are, the remaining decisions must constitute an optimal policy with regard to the state resulting from the first decision.” When applied recursively, this means that decisions at all states of an optimal trajectory must appear to be optimal when considering only the future behavior of the system. While the statement might sound rather vague, Bellman’s principle is the foundation of optimal control, applicable to both continuous-time and discrete-time systems and trajectories analyzed not only on finite but also infinite time horizons.
In the following subsections we will overview the Bellman and the Hamilton-Jacobi-Bellman (HJB) equation which are the consequence of Bellman’s principle when applied to the discrete-time and continuous-time optimal control problems. Regardless of the representation, the idea is find a sequence of control inputs that minimize the total cost of a trajectory, defined on a horizon. Instead of looking for the entire sequence at once, the Bellman principle allows us to break it down into a sequence of problems, described by the aforementioned equations. For their derivation we introduce the concept of the cost-to-go, i.e. the remainder of the total cost from any point on the horizon to its end, assuming a particular sequence of inputs. In the case of the optimal sequence of inputs we refer to the corresponding cost-to-go as the value function. The value function figures on the left-hand side of both equations where is expressed recursively.
This is high level overview which without additional context might be incomprehensible. Hopefully the following subsections will provide the necessary context in the form of rigorous derivations and later also applications. Especially the derivations are likely to be sparse on text, so always feel free to jump back.
To emphasize the relevance of Bellman’s principle in present day research a mention of the differential dynamic programming algorithm is called for. While the original algorithm was introduces in Mayne1966 its extensions are vibrant area of contemporary research.
Bellman Equation
For a discrete-time linear system, with dynamics in the form let us assume we are trying to minimize the total cost of a trajectory where the initial state is prescribed. The concept of the total cost can be generalized for any to a cost-to-go for which we may define a value function and an optimal control policy the application of which results in the system following the optimal sequence of states .
The so-called Bellman equation can then be derived by formulating the value function for step recursively, using the value function for step . From its definition, it is apparent that where Assuming we don’t know what the optimal input at step is, we may pose the right-hand side of (1) as an optimization problem Equation (2) is then referred to as the Bellman equation.
Hamilton-Jacobi-Bellman Equation
Let us assume we are trying to minimize the total cost of a continuous-time system’s trajectory , with dynamics in the form starting from the state .
The concept of the total cost can be generalized for any to a cost-to-go for which we may define a value function and optimal control policy the application of which results in the system following an optimal trajectory , .
For the previously defined value function the Hamilton-Jacobi-Bellman (HJB) equation can be derived1 as
-
An overview of the derivation is presented by Steven Brunton in one of his videos Brunton2022-HJB also available here. As a note, there is a small mistake, acknowledged by the presenter in the comments, at 9:11 of the video where “” should be replaced with “”. ↩
Linear-Quadratic Regulator
The linear-quadratic regulator gets its name from the linear model of the system and the quadratic cost function used for its design. For these, the optimal controller can be derived analytically and takes the form of linear state feedback making its implementation particularly simple.
The systems can be described in both the discrete-time and continuous-time domain and particular variants of the LQR allow for time-variant systems. Cost functions must then reflect the type of the system. For time-invariant systems, the cost function can either take the form of a time-invariant running cost integrated over an infinite horizon, or a sum of a final cost and a running cost (optionally time-variant) integrated over a finite horizon. If the system is time-variant, only the second option is available.
In the following sections we will cover four variants based on the time-domain and horizon
- discrete-time x continuous-time,
- finite-horizon x infinite-horizon.
Many more variants exist including those for reference tracking, dead-beat control, and even nonlinear trajectory optimization.
Discrete-Time Finite-horizon Linear-Quadratic Regulator
For a linear time-variant discrete-time system and a quadratic total cost of its trajectory the optimal controller can be derived based on the assumption that the value function takes the form When substituted into the Bellman Equation along with the system’s dynamics we attain To find the minimum, we may take the gradient of its argument (which is by design quadratic and convex) with respect to , set it to zero and find the solution (optimal control input)
The input can then be substituted back into (1). As the equation must hold for all , through basic manipulations we then attain the discrete-time dynamic Riccati equation (DDRE)
for a finite horizon .
Discrete-Time Infinite-horizon Linear-Quadratic Regulator
For a linear time-invariant discrete-time system and a quadratic total cost of its trajectory the optimal controller can be derived based on the assumption that the value function on the infinite horizon takes the time-invariant form
When substituted into the Bellman Equation along with the system’s dynamics we attain To find the minimum, we may take the gradient of its argument (which is by design quadratic and convex) with respect to , set it to zero and find the solution (optimal control input)
The input can then be substituted back into (1). As the equation must hold for all , through basic manipulations we then attain the discrete-time algebraic Riccati equation (DARE)
Continuous-Time Infinite-Horizon Linear-Quadratic Regulator
For a linear time-variant continuous-time system and a quadratic total cost where , , and , of its trajectory , the optimal controller can be derived based on the assumption that the value function takes the form When substituted into the Hamilton-Jacobi-Bellman Equation along with the system’s dynamics we attain To find the minimum, we may take the gradient of its argument (which is by design quadratic and convex) with respect to , set it to zero and find the solution (optimal control input)
The input can then be substituted back into (1). As the equation must hold for all , through basic manipulations we then attain the differential Riccati equation (DRE) for a finite horizon . Supplemented with the boundary conditon , the DRE forms an initial value problem (IVP) which can be solved using numerical integration. However, solving the problem is not straght-forward. The positive semi-definiteness of is a property that is not inherently preserved by all integration methods. This necessitates the use of either symplectic integration methods (often tailored for DREs) or factorizing .
Continuous-Time Infinite-Horizon Linear-Quadratic Regulator
For a linear time-invariant continuous-time system and a quadratic total cost where and , of its trajectory , the optimal controller can be derived based on the assumption that the value function takes the form When substituted into the Hamilton-Jacobi-Bellman Equation along with the system’s dynamics we attain To find the minimum, we may take the gradient of its argument (which is by design quadratic and convex) with respect to , set it to zero and find the solution (optimal control input)
The input can then be substituted back into (1). As the equation must hold for all , through basic manipulations we then attain the continuous-time algebraic Riccati equation (CARE)
Model Predictive Control
Model predictive control (MPC) is a control strategy which relies on the system’s model to predict and optimize its trajectory. This is done repeatedly to form a feedback loop. Trajectory optimization therefore lies as the heart of MPC. Typically the optimization problems are solved using gradient based methods which guarantees that the globally optimal solution is found only if the problem is convex. For nonconvex problems we have to settle for local minima. In this case, the initial estimate of the solution determines which local minimum is found.
We will focus on solving the trajectory optimization problem in discrete time. That is not to say that continuous-time formulations do not exist. For example, collocation methods for trajectory optimization are a well research field. However, the transcription produces an optimization problem differing only in additional “algebraic” decision variables Diehl2009.
The basic unconstrained trajectory optimization problem takes the form where is the final cost, the running cost, are the system’s dynamics, and is the initial state. In addition to constraints (2b-c) we may include additional constraints such as
- equality
- inequality
- box
- second-order cone
- …
The decision of which constraints are included should not be made only based on problem at hand but also the solver/method we want to use.
Linear Quadratic Trajectory Optimization Problems
Unconstrained Problems
Let us start by addressing the case where dynamics of our system are linear and the cost functions quadratic This problem is very similar to that of finite-horizon LQR. In fact, it differs only in the inclusion of the cross term , which can also be easily incorporated into LQR and linear terms and which can be accounted for in LQR if one considers the value function in the form . Also there is an additional term who’s utility we will show later, when discussing nonlinear trajectory optimization.
There are a few approach that can be used to solve this problem which differ mostly in their algorithmic complexity based on how the sparse structure of optimization problem is exploited.
Condensing
One way to exploit the block sparse structure is to eliminate states from the problem’s decision variables. As the constraint (2b) corresponds to the evolution of a linear time-varying system, states are fully determined by inputs and the initial state As a consequence of these eliminations, the resulting optimization problem is unconstrained and the matrix (of the quadratic term) in the objective function is dense. The algorithmic complexity of condensing is typically .
Solving the KKT system
Another way to exploit the sparse structure is to solve the problem’s KKT conditions
either using sparse linear algebra routines or by manual factorizations. In both cases the algorithmic complexity of can be achieved.
Riccati recursion
Riccati recursion is a process of factorizing the system of KKT conditions. If we consider the KKT conditions we can step-by-step condense them into the form where To tackle the KKT system as a whole we start by setting and traversing the horizon backwards to . The optimal inputs are given as an affine function of
The name “Riccati recursion” is not incidental. In fact there is a close relationship between the factorization process we have just described and obtaining the optimal control using discrete-time finite-horizon LQR. First of all, terms and can be used to form the value function Then if we look at (3a) we can see that it differs from the discrete-time dynamics Riccati equation only in the inclusion of the cross term . In fact if we were to include terms , , , in the problem when deriving DT-FH-LQR, we would also have terms and given by (3) and the optimal control input would take the form of (4).
The full derivation of the Riccati recursion is located here.
Constrained Problems
In addition to (2b-c) we may also add other affine equality/inequality constraints, such as at which point the problem is still classified as a quadratic program. In this case, without the knowledge of constrained optimization method, we can either use optimization modeling languages or use sparse solvers for QP. Alternatively, if constrained optimization methods are applied, they generally form a sequence of problems similar to (2) which can be solved using the Riccati recursion.
Nonlinear Trajectory Optimization Problems
Unconstrained Problems
Lets return to the unconstrained trajectory optimization problem The simplest way to solve this problem is using sequential quadratic programming (SQP). As the name suggest the approach involves forming a sequence of quadratic programs. These programs have the same same structure as the linear-quadratic problem which is achieved by evaluating Taylor expansions of cost functions (second-order) and the system’s dynamics (first-order). If we consider a nominal trajectory , (not necessarily dynamically feasible) we may linearize the system’s dynamics along it where and also, using the same notation, create quadratic approximations of the final and running cost Provided an initial nominal trajectory the SQP algorithm repeatedly solves the problem producing an update , to the nominal trajectory in a manor that is not dissimilar to the Newton method for unconstrained optimization. Ideally the nominal trajectory can be updated at every iteration using but typically line-search strategies must be used. Also the quadratic problem is not necessarily convex in which case it must be regularized. The problem (2) itself has the same exact form of the unconstrained linear-quadratic problem we previously described so once line-search and regularization are handled, we can use the same exact techniques.
Constrained Problems
Similarly to how we linearized the system’s dynamics it is common to also linearize additional constraints, e.g. However, for some types of constraints, such as second-order cones, there are specialized ways in which they can be effectively handled (see ADMM).
Due to the special structure of the trajectory optimization problem, many specialized solvers capable of handling additional constraints exist. As nonlinear MPC is still extremely computationally demanding these solvers are tailored to handle specific types of constraints, also making deliberate choices when it comes to how the algorithms converge (Altro, Crocoddyl, MJPC).
Optimal Luenberger Observer
Finite horizon
Let us consider a LTI system with additive Gaussian noise and a Luenberger observer The state estimate’s error and its covariance can be expressed recursively as The gain can then be designed such that is minimized. This can be achieved by finding the stationary point , where Substituting (3) back into (2b) we attain the DDRE which governs the evolution of the state error’s covariance.
The state of the observer then consists of and , its dynamics described by (1) and (4). This observer can also be used in the case where the dynamics of the system are time variant.
Infinite horizon
In the case where the covariances of the process and measurement noise are time-invariant, i.e. we can also design the gain of the observer based on the steady-state error covariance at . The covariance can be obtained by solving the DARE based on which we evaluate the gain
Duality with LQR
It is of note that the form of (4) and (5) is identical to those of the LQR with different matrices:
| LQR | Luenberger |
|---|---|
Kalman Filter
Let us consider a LTI system with additive Gaussian noise In addition to the state estimate the state of the Kalman Filter includes the error covariance where is the state estimate’s error.
The Kalman filter estimates the state in two steps, first creating an a priori state estimate and error covariance where and then performing a correction based on the measurement and Kalman gain , to attain the a posteriori state estimate and error covariance as The Kalman gain is designed to minimize the a posteriori error covariance by finding the stationary point of (1b) After substituting (2) into (1b) we can manipulate the equation into the “Joseph” form or alternatively the simplified form which is numerically less stable.
Car Importer
A car importer is planning to import two models of JDM cars. In one shipment he can transport 60 cars at an investment of 50 million CZK. The purchase price of the two models is 2.5 million and 0.5 million CZK. He then expects a profit of 250 thousand CZK per unit sold of the first model and 75 thousand CZK of the second model. How many units of each model should he buy to maximize his profit, expecting every car will be sold?
Mathematical Model
Canonical Form
where
Maximum Flow Optimization
We have a network (represented as directed graph). The graph has a “Source” of a medium (it can be for example gas, water, or electricity) and Sink with additional nodes in between. All edges between source and sink has defined maximal capacity.
graph LR;
A["Source"];
D["Sink"];
A-->|"10"|B1;
A-->|"8"|B2;
B1-->|"6"|C1;
B1-->|"2"|C2;
B2-->|"4"|C1;
B2-->|"5"|C2;
C1-->|"8"|D;
C2-->|"9"|D;
What is the maximum amount medium we can transmit through the sink?
Mathematical Model
Let us first define our optimization variables as individual flows through the edges of our graph
graph LR;
A["Source"];
D["Sink"];
A--->|"x₀ ≤ 10"|B1;
A--->|"x₁ ≤ 8"|B2;
B1-->|"x₂ ≤ 6"|C1;
B1-->|"x₃ ≤ 2"|C2;
B2-->|"x₄ ≤ 4"|C1;
B2-->|"x₅ ≤ 5"|C2;
C1-->|"x₆ ≤ 8"|D;
C2-->|"x₇ ≤ 9"|D;
we may then write the problem as
where
Canonical Form
Manipulating the objective into the canonical form can be done simply with To deal with the constraints let us first formulate the equality constraints in matrix form as: where Equivalently we may write it as Together with the upper bounds they can be now rewritten into the canonical form
Shortest Path Problem
Interestingly, the problem of finding the shortest path through a directed weighed graph has a tight approximation in the form of an LP. Let’s consider a weighed graph
graph LR;
A["Origin"];
D["Destination"];
A-->|"10"|B1;
A-->|"8"|B2;
B1-->|"6"|C1;
B1-->|"2"|C2;
B2-->|"4"|C1;
B2-->|"5"|C2;
C1-->|"8"|D;
C2-->|"9"|D;
The weight of each edge can be regarded as a distance or any other abstract cost associated with traversing it.
Mathematical Model
Let’s assign decision variables to each edge of the graph.
graph LR;
A["Origin"];
D["Destination"];
A-->|"x₀"|B1;
A-->|"x₁"|B2;
B1-->|"x₂"|C1;
B1-->|"x₃"|C2;
B2-->|"x₄"|C1;
B2-->|"x₅"|C2;
C1-->|"x₆"|D;
C2-->|"x₇"|D;
If we select to traverse a specific edge which is associated with the cost , where are the weights of individual edges. Naturally we must also include the constraint to ensure that we traverse through the graph as well as constraints ensuring continuity in the graph’s vertices. One would expect that would have to be binary, but they can be in fact continuous variables.
The problem as a whole takes the form where
Undirected Graph Problem
If the graph is undirected we are solving the problem This problem can in-fact be reformulated into an LP by introducing a vector of additional decision variables , where if we traverse the given edge in the opposite direction
Economic Dispatch
We have three power plants each producing electricity to satisfy the demand of . Each of the power plants has an upper and lower capacity limit and and a quadratic model of the cost associated with its power output . Numerical values for the capacity limits and cost coefficients are provided in the table bellow.
| 1 | 20 | 5 | 0.02 | 200 | 1000 |
| 2 | 25 | 4 | 0.015 | 300 | 1500 |
| 3 | 30 | 3 | 0.01 | 100 | 800 |
How much power should each power plant provide, to minimize the overall cost?
Mathematical Model
Always ON
Assuming all power plants must be powered on at all times, the problem can be modeled as
ON/OFF
Lets now assume that we may also power on/off each power plant based on the demand. This necessitates the inclusion of additional binary decision variables in the problem
The problem remains quadratic but, due to the binary decision variables , is now classified as a MIQP.
Derivation of the Riccati Recursion
To illustrate the process, let us consider the KKT conditions Using the last row we can express as and consequently eliminate it from the KKT system In a similar fashion we may eliminate attaining where Finally, we may also eliminate to attain where This process can be repeated for .
Trajectory Optimization Using OSQP
For embedded applications we may want to use QP solvers with code generation such as OSQP. The particular form of the QP program it solves lends itself to LQ trajectory optimization problems with additional box constraints, e.g.
OSQP form
To coincide with the form of the QP program described in the documentation of OSQP we define a vector of decision variables for which the objective function contains the terms The constrains are then incorporated using
Optimization Modeling Languages
CVXPY
“Open source Python-embedded modeling language for convex optimization problems”
Pyomo
“Python-based, open-source optimization modeling language with a diverse set of optimization capabilities”
JuMP
“JuMP is a modeling language and collection of supporting packages for mathematical optimization in Julia”
Solvers
OSQP
“Numerical optimization package for solving convex quadratic programs”
- Uses the alternating direction method of multipliers (ADMM)
IPOPT
“Open source software package for large-scale nonlinear optimization”
- Uses the interior point (IP) method