• 沒有找到結果。

Fourth Order of Runge-Kutta Formula for Numerical Method

Chapter 2 Theoretical Foundation

2.5 Fourth Order of Runge-Kutta Formula for Numerical Method

function of the error functionJ. But after one whole epoch, the training of the weighting vector Wmay be not enough. One way to solve this problem is to add the number of the time sequence point of the desired output U =(u1,u2,...uk,...um), and calculate more number of time sequence point of the network output

) from a control system in the steady state. Even we just use the same total time with the higher sampling rate to get more points, it maybe produce big run-off error because of the difference of the two neighbor points maybe too small. To avoid the problems above, we can use more than one epoch. After one whole epoch training of the weighting vector W, we can take the final value of the weighting vector W of the first epoch as the initial value of the weighting vector W of the second epoch, and we will get the new value of the network output

)) we can take the final value of the weighting vector W of the second epoch as the initial value of the weighting vector W of the third epoch. And we can repeat this method till we finish the last epoch, and the training of the weighting vector W is good enough.

2.5 Fourth Order of Runge-Kutta Formula for Numerical Method

In [19], we use the fourth order of Runge-Kutta formula which provides a good approximation and efficient way for numerical method. Let an initial value problem as following equations:

0

Then, the fourth order of Runge-Kutta formula for this problem can be written by the following equations:

)

Chapter 3

Control of Inverted Pendulum System (IPS)

3.1 Dynamics of Inverted Pendulum System (IPS)

M

Fig-3.1. The inverted pendulum system (IPS)

In [16, 20], the half-axle length of the IPS l= 0.5 meter; the cart mass of the IPS M = control force to push the cart. We substitute the values above, and we can get the following equation:

×u

3.2 Design of Reference Controller

Linearize the equation (3-1), by settingcos

θ

1 =1 ,sin

θ

1 =

θ

1 ,

θ

22 = 0, and we

can get the following equation: following equation:

× u And we present (3-5) by matrix form

⎟⎟ So the equation of the reference controller of IPS is equation (3-9). Let the IPS initial angle=20 degree and initial angular speed=20 degree/sec, and the simulation time=10 sec. With the equations (3-2) and (3-9), we can get the results of the IPS controlled by the reference controller, and we show them in the following figures:

Fig-3.2. The control force of the reference controller

Fig-3.3. The output angle of IPS controlled by the reference controller

Fig-3.4. The output angular speed of IPS controlled by the reference controller

3.3 Architecture and Algorithm of Weighting Training

ϕ ()

Fig-3.5. The architecture of the HNN controller in the training phase

We use the following parameters of HNN controller: the resistor=1(ohm), the capacitor=0.01(Farr), the amplification constant=-30, and the learning rate=0.001.

In the training phase, we note that the Hopfield neural network (HNN) doesn’t control the IPS. So we can imagine that when trainw11,w12,w21 andw22 by the set of time of the reference controller and the IPS pauses until the HNN circuit is in the steady state. And we continue to trainw11,w12,w21 andw22 by the next set of

So we can consider that in the training phase, the circuit is already in the steady state, so no current passes to both capacitors C (it is equal to both capacitors C are open, C=0), so we can get the equation bellow (by the circuit theorem: the voltage drop equals the multiplication of the resistance and the current):

2

We have the equation bellow (by the circuit theorem: current equals the multiplication of the conductance and the voltage):

)

The effect ofϕ(•) is as voltage amplifier, so we can write the equations bellow:

( ) tanh( )

The equation of the output of Hopfield neural network, the HNN controller‘s control signal u is bellow:

) ( x

1

x

2

c

u

=

amp

× +

(3-13) We define the error J as the measurement of the half squared distance between the reference controller’s control signal u and the HNN controller’s control signalu . And we write the equation bellow:

)2

half squared distance between the reference controller’s control signal u and the HNN controller’s control signal u will be smaller. How can we reach this task? We can deal it by trainingw11,w12,w21 and w22with the steepest descent method as we introduced in the section 2.3. Let us take w11 for example to show how it to be trained. First, we can write the equation bellow to show how we get the better next value ofw11: where η is the learning rate, and we should calculate the value of

w11

J

∂ . We can use

the chain rule to write the equation bellow:

11 From the equation (3-14), we have the equation bellow:

) From the equation (3-13), we have the equation bellow:

camp From the equation (3-12), we have the equation bellow:

2

From the equation (3-10), (3-11), we have the equation bellow:

)

So, from the equations (3-16), (3-17), (3-18), (3-19) and (3-20), we have equation bellow:

Substitute equations (3-21) to the equations (3-15), we have equation bellow:

)

)

Hopfield NN controller

u u

Fig-3.6. The architecture of the IPS controlled by the HNN controller

In the working phase, the HNN is a real time controller, responding to control the IPS.

The value of the set ofw11,w12,w21 and w22 is fixed. And as a real time controller, the circuit is dynamic, so we cannot ask the circuit always in the steady state, so we should know that the current passing the both capacitors C is not always zero.

Actually, it is very complicated to calculate the output of IPS. In the working phase, the architecture is the recurrent neural network. The output of IPS is(

θ

1(t),

θ

2(t)), and (

θ

1(t),

θ

2(t)) will affect the values of the current (i1(t),i2(t)), and the current(i1(t),i2(t)) will affect the values of the voltage(v1(t),v2(t)), and the time-varying current passing the capacitors will affect the values of the voltage(v1(t),v2(t)), too. The voltage(v1(t),v2(t)) will be amplified by

ϕ

(•) to

get the values of(x1(t),x2(t)), and the values of x1(t) and x2(t) will affect i1(t) and i2(t) respectively, and (x1(t)+x2(t))×camp will get the control signal u(t) . Of course, the control signal u(t) will affect the output of the IPS(

θ

1(t),

θ

2(t)) by the IPS equation (3-2). So this is a complicated recurrent control system. So we don’t calculate the analytic solution of this system. Instead, we try to use the numerical method to simulate this system.

3.4 Simulation Result

3.4.1 Seeking for Weighting Factors

First, we should try to seek a good set ofw11,w12,w21 and w22. With the equations (3-22), (3-23), (3-34) and (3-25), we may use many training epochs for get better training results. How can we use training epochs to get better results? First, we define a new parameter: the total error during the whole timeJ as the following equation: t

= Where the parameter J(k) is just the detailed presentation of J , with

))2 discrete time point). And to emphasize the inference of the epoch number to the total error during the whole time we can write the equation bellow:

= let J become small enough. We can show this in the following figure, Fig-3.7, and t we can find that using 6 epochs is good enough for simulation.

Fig-3.7. The total error Jt(epo) and the last epoch error J(k,6)

By the simulation, we can find a set ofw11,w12,w21 and w22, and we write it down as(w11,w12,w21,w22)=(0.1755,0.01367,0.1755,0.01367).

In fact, the seeking of a good set ofw11,w12,w21 and w22 is the process of the training iteration in the whole time and every epoch, and we can show the training iteration process (in the last epoch) in the whole time by the following figure.

Fig-3.8. The last epoch training iteration process ofw11,w12,w21 and w22

3.4.2 IPS Controlled by HNN Controller Trained with the Same Initial State

After we seek the values ofw11,w12,w21 and w22, we can begin to run the simulation of the IPS controlled by the HNN controller in real time. We use the Matlab with the 4th order of Runge-Kutta formula to simulate IPS controlled by HNN controller. By the simulation, we can get the following figures as the results.

Fig-3.9. The control forces of IPS: reference controller (dash line) and HNN controller (solid line)

Fig-3.10. The output angles of IPS: reference controller (dash line) and HNN controller (solid line)

Fig-3.11. The output angular speeds of IPS: reference controller (dash line) and HNN controller (solid line)

Fig-3.12. The node 1 voltage v1 of the HNN circuit

Fig-3.13. The node 2 voltage v2 of the HNN circuit

3.4.3 IPS Controlled by HNN Controller Trained with Different Initial State

We use the following examples to examine the abilities of HNN controllers to control IPS with initial state different from the initial state of training the HNN controller. We can let the values ofw11,w12,w21 and w22 be the same with section 3.4.1, so

) 01367 . 0 , 1755 . 0 , 01367 . 0 , 1755 . 0 ( ) , , ,

(w11 w12 w21 w22 = is fixed for the initial state of IPS: the initial angle=20 (degree) and initial angular speed=20 (degree/sec) in the training phase. And then, we will examine the following pairs (initial angle (degree), initial angular speed (degree/sec)) of the initial state of IPS: (30, 20), (20, 30), (25, 25), and (10, 10) in the working phase as the following figures:

Fig-3.14. The control forces of IPS with initial angle=30 degree, initial angular speed=20 degree/sec: reference controller (dash line) and HNN controller (solid line)

Fig-3.15. The output angles of IPS with initial angle=30 degree, initial angular speed=20 degree/sec: reference controller (dash line) and HNN controller (solid line)

Fig-3.16. The output angular speeds of IPS with initial angle=30 degree, initial angular speed=20 degree/sec: reference controller (dash line) and HNN controller

(solid line)

Fig-3.17. The node 1 (2) voltage v1 (v2) of the HNN circuit with IPS initial angle=30 degree, initial angular speed=20 degree/sec

Fig-3.18. The control forces of IPS with initial angle=20 degree, initial angular speed=30 degree/sec: reference controller (dash line) and HNN controller (solid line)

Fig-3.19. The output angles of IPS with initial angle=20 degree, initial angular speed=30 degree/sec: reference controller (dash line) and HNN controller (solid line)

Fig-3.20. The output angular speeds of IPS with initial angle=20 degree, initial angular speed=30 degree/sec: reference controller (dash line) and HNN controller

(solid line)

Fig-3.21. The node 1 (2) voltage v1 (v2) of the HNN circuit with IPS initial angle=20 degree, initial angular speed=30 degree/sec

Fig-3.22. The control forces of IPS with initial angle=25 degree, initial angular speed=25 degree/sec: reference controller (dash line) and HNN controller (solid line)

Fig-3.23. The output angles of IPS with initial angle=25 degree, initial angular speed=25 degree/sec: reference controller (dash line) and HNN controller (solid line)

Fig-3.24. The output angular speeds of IPS with initial angle=25 degree, initial angular speed=25 degree/sec: reference controller (dash line) and HNN controller

(solid line)

Fig-3.25. The node 1 (2) voltage v1 (v2) of the HNN circuit with IPS initial angle=25 degree, initial angular speed=25 degree/sec

Fig-3.26. The control forces of IPS with initial angle=10 degree, initial angular speed=10 degree/sec: reference controller (dash line) and HNN controller (solid line)

Fig-3.27. The output angles of IPS with initial angle=10 degree, initial angular speed=10 degree/sec: reference controller (dash line) and HNN controller (solid line)

Fig-3.28. The output angular speeds of IPS with initial angle=10 degree, initial angular speed=10 degree/sec: reference controller (dash line) and HNN controller

(solid line)

Fig-3.29. The node 1 (2) voltage v1 (v2) of the HNN circuit with IPS initial angle=10 degree, initial angular speed=10 degree/sec

3.4.4 IPS Controlled by HNN Controller Trained by Nonlinear Reference Controller with the Same Initial State

To examine the ability of HNN controller to mimic the nonlinear reference controller, we use the following equation as the nonlinear reference controller of IPS:

)

Let the IPS initial angle=20 degree and initial angular speed=20 degree/sec, and the simulation time=20 sec. We can get the following three figures of IPS controlled by the nonlinear reference controller:

Fig-3.30. The control force of the nonlinear reference controller

Fig-3.31. The output angle of IPS controlled by the nonlinear reference controller

Fig-3.32. The output angular speed of IPS controlled by the nonlinear reference controller

We use the same parameters of HNN controller: the resistor=1(ohm), the capacitor=0.01(Farr), the amplification constant=-30, the learning rate=0.001, and 10 epochs for training, and we show the training process as the following two figures:

Fig-3.33. The total error Jt(epo) and the last epoch error J(k,10)

Fig-3.34. The last epoch training iteration process ofw11,w12,w21 and w22 By the simulation, we find the values ofw11,w12,w21 and w22, and we write it down as(w11,w12,w21,w22)=(0.1846,0.1876,0.1846,0.1876).Then, we show the following four figures as simulation result of IPS controlled by trained HNN controller:

Fig-3.35. The control forces of IPS: nonlinear reference controller (dash line) and

HNN controller (solid line)

Fig-3.36. The output angles of IPS: reference controller (dash line) and HNN controller (solid line)

Fig-3.37. The output angular speeds of IPS: reference controller (dash line) and HNN controller (solid line)

Fig-3.38. The node 1 (2) voltage v1 (v2) of the HNN circuit

3.4.5 IPS Controlled by HNN Controller Trained by Nonlinear Reference Controller with Different Initial State

We use the following examples to examine the abilities of HNN controllers to control IPS with initial state different from the initial state of training the HNN controller by the nonlinear reference controller. We let the values ofw11,w12,w21 and w22 be the same with section 3.4.4, so (w11,w12,w21,w22)=(0.1846,0.1876,0.1846,0.1876) is fixed for the initial state of IPS: the initial angle=20 (degree) and initial angular speed=20 (degree/sec) in the training phase. And then, we will examine the following pairs (initial angle (degree), initial angular speed (degree/sec)) of the initial state of IPS: (30, 30), and (10, 10) in the working phase as the following figures:

Fig-3.39. The control forces of IPS with initial angle=30 degree, initial angular speed=30 degree/sec: the nonlinear reference controller (dash line) and HNN

controller (solid line)

Fig-3.40. The output angles of IPS with initial angle=30 degree, initial angular speed=30 degree/sec: the nonlinear reference controller (dash line) and HNN

controller (solid line)

Fig-3.41. The output angular speeds of IPS with initial angle=30 degree, initial angular speed=30 degree/sec: the nonlinear reference controller (dash line) and HNN

controller (solid line)

Fig-3.42. The node 1 (2) voltage v1 (v2) of the HNN circuit with IPS initial angle=30 degree, initial angular speed=30 degree/sec

Fig-3.43. The control forces of IPS with initial angle=10 degree, initial angular speed=10 degree/sec: the nonlinear reference controller (dash line) and HNN

controller (solid line)

Fig-3.44. The output angles of IPS with initial angle=10 degree, initial angular speed=10 degree/sec: the nonlinear reference controller (dash line) and HNN

controller (solid line)

Fig-3.45. The output angular speeds of IPS with initial angle=10 degree, initial angular speed=10 degree/sec: the nonlinear reference controller (dash line) and HNN

controller (solid line)

Fig-3.46. The node 1 (2) voltage v1 (v2) of the HNN circuit with IPS initial angle=10 degree, initial angular speed=10 degree/sec

Chapter 4

Control of Ball and Beam System (BABS)

4.1 Dynamics of Ball and Beam System (BABS)

θ3 the ball is R=0.01(m); the gravity acceleration is G.=9.8(m/s ); the torque applied to 2 the beam is f (nt-m). With the ball positionθ1 , the ball velocityθ2, the beam angleθ3, and the beam angular speedθ4, we can get the equations bellow:

0

And we define

R2

B , and we can get the equations bellow:

2

We substitute the values of B, G, M, P, P above, and we can get the following b

4.2 Simulation of BABS Controlled by Reference Controller

We use the following equation as reference controller of BABS:

4 where f is the control torque. Let the BABS initial position (ball’s position) =0.2 meter, initial velocity (ball’s velocity) =0 meter/sec, initial angle (beam’s angle) =10 degree and initial angular speed (beam’s angular speed) =0 degree/sec, and the simulation time=15sec. With equation (4-7) and (4-8), we can get the results of the BABS controlled by the reference controller, and we can show them in the following figures.

Fig-4.2. The control torque of the reference controller

Fig-4.3. The ball’s position of BABS controlled by the reference controller

Fig-4.4. The ball’s velocity of BABS controlled by the reference controller

Fig-4.5. The beam’s angle of BABS controlled by the reference controller

Fig-4.6. The beam’s angular speed of BABS controlled by the reference controller

4.3 Architecture and Algorithm of Weighting Training

Fig-4.7. The architecture of the BABS controlled by the HNN controller in the training phase

We use the following parameters of HNN controller: the resistor=1(ohm), the capacitor=0.01(Farr), the amplification constant=-30, and the learning rate=0.001.

In the training phase, we note that the Hopfield neural network (HNN) doesn’t control the ball and beam system (BABS). So we can imagine that when train w11, w12, w , 13

w14, w21, w22, w , 23 w24, w , 31 w , 32 w , 33 w , 34 w41, w42, w and 43 w44 by the set of (u,

θ

1,d1,

θ

2,d2,

θ

3,d3,

θ

4,d4)(the value of the set is corresponding to this moment time t1), the time of the reference controller and the BABS pauses until the HNN circuit is in the steady state. And we continue to train w11, w12, w , 13 w14, w21, w22, w , 23 w24, w , 31 w , 32 w , 33 w , 34 w41, w42, w and 43 w44 by the next set of (u,

θ

1,d1,

θ

2,d2,

θ

3,d3,

θ

4,d4) (the value of the “next set” is corresponding to the next moment time t2).

So we can consider that in the training phase, the circuit is already in the steady state, so no current passes to the four capacitors C (it equals that the four capacitors C are open, C=0), so we can get the equations bellow (by the circuit theorem: the voltage drop equals the multiplication of the resistance and the current):

4

And we have the equation bellow (by the circuit theorem: current equals the multiplication of the conductance and the voltage):

)

And the effect ofϕ(•) is as voltage amplifier, so we can write the equations bellow:

And the equation of the output of Hopfield neural network, the HNN controller‘s control signal f is bellow:

We define the error J as the measurement of the half squared distance between the reference controller’s control signal f and the HNN controller’s control signalf . And we write the equation bellow:

)2 half squared distance between the reference controller’s control signal f and the HNN controller’s control signal f will be smaller. How can we reach this task? We can deal it by training thew11, w12, w , 13 w14, w21, w22, w , 23 w24, w , 31 w , 32 w , 33 w , 34 w41, w42, w and 43 w44 with the steepest descent method. Let us take w11 for example to show how it to be trained. First, we can write the equation bellow to show how we get the better next value ofw11:

11 Where η is the learning rate, and we should calculate the value of

w11

J

∂ . We can

use the chain rule to write the equation bellow:

11 From the equation (4-13), we have the equation bellow:

) From the equation (4-12), we have the equation bellow:

camp From the equation (4-11), we have the equation bellow:

2

From the equation (4-9), (4-10), we have the equation bellow:

)

So, from the equations (4-15), (4-16), (4-17), (4-18) and (4-19), we have equation bellow:

Substitute equations (4-20) to the equations (4-14), we have equation bellow:

)

)

x1

Fig-4.8. The architecture of the BABS controlled by HNN controller

In the working phase, the HNN is a real time controller, responding to control the BABS. The value of the set ofw11, w12, w , 13 w14, w21, w22, w , 23 w24, w , 31 w , 32

w , 33 w , 34 w41, w42, w and 43 w44 is fixed. And as a real time controller, the circuit is dynamic, so we cannot ask the circuit always in the steady state, so we should know that the current passing the both capacitors C is not always zero.

Actually, it is very complicated to calculate the output of BABS. In the working phase, the architecture is the recurrent neural network. The output of BABS is(

θ

1(t),

θ

2(t),

θ

3(t),

θ

4(t)), and (

θ

1(t),

θ

2(t),

θ

3(t),

θ

4(t)) will affect the values of the current(i1(t),i2(t),i3(t),i4(t)), and the current(i1(t),i2(t),i3(t),i4(t)) will affect the values of the voltage(v1(t),v2(t),v3(t),v4(t)), and the time-varying current passing the capacitors will affect the values of the voltage

)) the control signal f(t) will affect the output of the BABS

)) recurrent control system. So we don’t calculate the analytic solution of this system.

Instead, we try to use the numerical method to simulate this system.

4.4 Simulation Result

4.4.1 Seeking for Weighting Factors

First, we should try to seek a good set ofw11, w12, w , 13 w14, w21, w22, w , 23 w24, w , 31 w , 32 w , 33 w , 34 w41, w42, w and 43 w44. With the equations (4-21), (4-22), (4-23), (4-24), (4-25), (4-26), (4-27), (4-28), (4-29), (4-30), (4-31), (4-32), (4-33), (4-34), (4-35)and (4-36), and we may use many training epochs for get better training results. And we can show that the total error during the whole time is the function of the epoch number and the error is the function of the time(last epoch for example) in the following figure, Fig-4.9, and we can find that using 20 epochs is good enough for simulation.

Fig-4.9. The total error Jt(epo) and the last epoch error J(k,20)

By the simulation, we can find a good set ofw11, w12, w , 13 w14, w21, w22, w , 23 w24, w , 31 w , 32 w , 33 w , 34 w41, w42, w and 43 w44, and we write it down as following equation in the matrix form:

⎥⎥ the whole time and every epoch, and we can show the training iteration process (in the last epoch) in the whole time by the following figures:

Fig-4.10. The last epoch training iteration process ofw11,w12,w and 13 w14

Fig-4.11. The last epoch training iteration process ofw21,w22,w and 23 w24

Fig-4.12. The last epoch training iteration process ofw ,31 w ,32 w and 33 w 34

Fig-4.13. The last epoch training iteration process ofw41,w42,w and 43 w44

4.4.2 BABS Controlled by HNN Controller Trained with the Same Initial State

After we have the values of the good set ofw11, w12, w , 13 w14, w21, w22, w , 23 w24, w , 31 w , 32 w , 33 w , 34 w41, w42, w and 43 w44, we can begin to run the simulation of the BABS controlled by the HNN controller in real time. We use the Matlab with the 4th order of Runge-Kutta formula to simulate it. Because its nonlinearity is very high, so we use the 4th order of Runge-Kutta formula to simulate BABS controlled by HNN controller. By the simulation, we can get the following figures as the results:

Fig-4.14. The control torques of BABS: reference controller (dash line) and HNN controller (solid line)

Fig-4.15. The ball’s positions of BABS: reference controller (dash line) and HNN

Fig-4.15. The ball’s positions of BABS: reference controller (dash line) and HNN