Showing posts with label Control Systems. Show all posts
Showing posts with label Control Systems. Show all posts

Friday, 17 November 2017

The Linear Quadratic Regulator

Optimal Control and Linear-Quadratic-Regulator (LQR)

Today, I will not write an introductory passage to write off my blog. Because, writing an introduction to Optimal Control in itself will required a blog. However, I will add in small tidbits as and when needed.
To understand the topic, we need some basic definitions with us.

1.
A control system can be represented in terms of State Space, as follows,

In the above formulation,
is the state vector; .
is the output vector; .
is the input vector; .
is the System Matrix; .
is the Input Matrix; .
is the Output Matrix; .
is the Feed-forward Matrix; .
Now, for a system to be controllable, we first define a matrix , called the controllability matrix, such that,

The system is controllable if has full row rank (i.e. rank() ).

We will assume that we deal with Controllable systems only.

Usually, a single input system’s state feedback controller is designed using the Eigen-value method, or Pole Placement method.

2.
Pole placement method is the methodology of finding the control vector in the form
So, the state space representation changes as,

is found as,

Here, are the desired pole locations. Note that is defined as

However, for a multi-input system the feedback gain i.e. is not unique.
Linear Quadratic Control strategy is used to deal with this issue.

Now, we dive into the Linear Quadratic Regulator (LQR) formulation, for an -input and -state system with ,. Consider a system,

Our aim is to find an open loop control , for such that we minimize:

where and are symmetric positive semi-definite matrices.
is a symmetric positive definite matrix. Note that , and are fixed and given data.
The controller aim is to basically keep close to 0 especially at , which is the final time.
In ,
  • works against the transient response.
  • works against the finite state.
  • works against the control effort.
The above formulation can regulate the output near .
Note that, we can define, and as where,
We can now have a theorem as follows,
For a system with fixed initial and final conditions, ; and clearly . We define our time horizon as such that . We find such that our cost function, is minimized. is defined as,

Here, the first term of is the final cost and the second term is the recurring cost.


Now, we will formulate some important functions that will convert the which is a constrained optimal control problem to a unconstrained optimal control problem. [THIS MAY NOT MAKE SENSE TO YOU, WHICH IS NATURAL. HOLD ON].

Note that, ( ) is called the Lagrangian.
is the Hamiltonian operator. Defined in terms of and as in . Or it can be defined as,

The above definition is in terms of as defined in the theorem. So, we define in the same lines. Just for convenience of computation.

can be written as
Equation , and together form a set of differential equations (in and , obviously) with split boundary conditions at and . Now, we can easily define in terms of or/and .
As mentioned earlier, the solution is found by converting from a constrained optimal problem to a constrained optimal problem using a Lagrange multiplier function :

Notice that,

Therefore,

As the Hamiltonian Function is defined in , thus,

The necessary condition for an optimal solution is of the modified cost with respect to all variations of the system be minimal at all times from to .
We will define analytically in the next post and formulate the Riccati Equation that will lay the foundation to some amazing control strategies.
Cheers!

Tuesday, 31 January 2017

Control Systems Engineering with MATLAB - 1

Hello guys,
I hope you liked my previous blog on making your own R packages. If you haven’t yet seen it, please have a look at it here|How I made my first R Package?.


Today, I will do some very elementary Control system using MATLAB.


This blog post will have a little mathematics, so, brace yourselves.


Whenever, we talk of transfer functions, we think of Transfer functions, now what are transfer functions?
To keep it simple, if your = and your = ,
Then, the transfer function is given by the ratio of the laplace transform of the change in to the change in , mathematically,


= , here means Transfer function in -domain; Laplace domain is generally callled the -domain.


I believe, this is a very common fact. Now, let’s do some MATLAB.


We define a transfer function in MATLAB using the function tf function.


An illustration is as follows,
Imgur


You can change the co-efficients as you wish. just change the numbers inside the [ ].


For example,
H = tf([1 2], [1 2 3]), will yield,
=


Now, we convert the transfer function from to , basically from continuous to discrete domain,


For this, we use the c2d function, which is basically the continuous to discrete function for MATLAB.


The function looks like G = c2d(_transfer function_, _sampling time_),
So, for,
H = tf([1 2], [1 2 3])
the c2d function when applied will look like,
G = c2d(H, 0.1) 
0.1 second is the sampling time.


Have a look at this picture,
Imgur


Similarly, the d2c command also does the reverse, but, as your intuition speaks, since we are going into the continuous from the discrete domain, we don’t need a sampling time.


So, the syntax is,

I = d2c(G)


Look at the image below,
Imgur




That is all for today folks. In the next blog, I will be talking about Gain and Phase margins, Bode Plots and various other control engineering concepts.
Cheers!