07.11.2014 Views

MATLAB Toolboxes - Air Transportation Systems Laboratory

MATLAB Toolboxes - Air Transportation Systems Laboratory

MATLAB Toolboxes - Air Transportation Systems Laboratory

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Introduction to <strong>MATLAB</strong><br />

<strong>MATLAB</strong> <strong>Toolboxes</strong><br />

Computer Applications in CEE<br />

Drs. Trani and Rakha<br />

Civil and Environmental Engineering<br />

Virginia Polytechnic Institute and State University<br />

Spring 2000<br />

Virginia Polytechnic Institute and State University 1 of 31


Sample <strong>Toolboxes</strong><br />

• <strong>MATLAB</strong> has been extended over the years to respond to<br />

the needs of various users<br />

• Several toolboxes exist to add to the power of the original<br />

language. For example:<br />

- Simulink<br />

- Fuzzy Logic<br />

- Neural Networks<br />

- Optimization<br />

- Controls<br />

- C/C++ compiler library<br />

- Real-time workshop<br />

Virginia Polytechnic Institute and State University 2 of 31


Simulink<br />

• Simulink is a powerful toolbox to solve systems of<br />

differential equations<br />

• Simulink has applications in <strong>Systems</strong> Theory, Control,<br />

Economics, <strong>Transportation</strong>, etc.<br />

• The Simulink approach is to represent systems of ODE<br />

using block diagram nomenclature<br />

• Simulink provides seamless integration with <strong>MATLAB</strong>.<br />

In fact, Simulink can call any <strong>MATLAB</strong> function<br />

• Simulink interfaces with other <strong>MATLAB</strong> toolboxes such<br />

as Neural Network, Fuzy Logic, and Optimization<br />

routines<br />

Virginia Polytechnic Institute and State University 3 of 31


Simulink Building Blocks<br />

• Simulink has a series of libraries to construct models<br />

• Libraries have object blocks that encapsulate code and<br />

behaviors<br />

• Connectors between blocks establish causality and flow<br />

of information in the model<br />

Virginia Polytechnic Institute and State University 4 of 31


Simulink Interface<br />

• The main application of Simulink is to model continuous<br />

systems<br />

• Perhaps systems that can be described using ordinary<br />

differential equations<br />

Virginia Polytechnic Institute and State University 5 of 31


Typical Simulink Libraries<br />

Shown are some typical Simulink libraries (Macintosh)<br />

Virginia Polytechnic Institute and State University 6 of 31


Sample Simulink Library (Windows and UNIX)<br />

The new Simulink interface in Windows/UNIX uses<br />

standard OOP interfaces (Visual C++, Visual Basic)<br />

Virginia Polytechnic Institute and State University 7 of 31


Simulink Example<br />

The following example illustrates the use of Simulink to<br />

solve a two vehicle car-following problem. This problem<br />

has been studied for the past 40 years in traffic flow<br />

theory<br />

ẋ˙ ( t + τ) fc = k( ẋ() t lc – ẋ t )<br />

k<br />

() fc<br />

where: is a gain constant of the response process<br />

ẋ˙ ( t + τ) fc<br />

is the acceleration of the following vehicle<br />

ẋ() t lc<br />

ẋ() t fc<br />

is the speed of the leading vehicle<br />

is the speed of the following vehicle<br />

Virginia Polytechnic Institute and State University 8 of 31


Set-Up of the Problem<br />

• Assume the velocity profile of the leading vehicle is<br />

known (we “drive” this car to test the response of the<br />

following vehicle)<br />

• Initially, assume no time lags in the acceleration response<br />

of the following vehicle ( )<br />

τ = 0<br />

• Test an emergency braking maneuver executed by the<br />

first vehicle at 3 m/s 2<br />

• Test a new scenario with a deterministic time lag<br />

response time of 0.75 seconds<br />

• Verify that both cars do not collide<br />

Virginia Polytechnic Institute and State University 9 of 31


Simulink Representation of the Car-Following<br />

Problem<br />

Car Following Problem<br />

Mux<br />

Mux1<br />

Speed Profiles<br />

1<br />

Xdot<br />

1<br />

X<br />

s<br />

Integrator<br />

s<br />

Integrator1<br />

Mux<br />

Mux<br />

Distance Profiles<br />

Speed LTU<br />

k (Xdot_ltu - Xdot_ftu)<br />

2<br />

Constant<br />

Xdot_ltu - Xdot_ftu<br />

1<br />

s<br />

Integrator2<br />

Virginia Polytechnic Institute and State University 10 of 31


Car-Following Model Output<br />

Velocity profiles for leading and trailing vehicles<br />

Speed (m/s)<br />

Time (s)<br />

Virginia Polytechnic Institute and State University 11 of 31


Car-Following Model Output<br />

The time space diagram below illustrates an emergency<br />

braking maneuver for the leading vehicle<br />

Space (m)<br />

Time (s)<br />

Virginia Polytechnic Institute and State University 12 of 31


Car-Following Model with Delay<br />

A pure transport delay block is added to the original<br />

model simulating the transport lag dynamics of a manmachine<br />

system<br />

Mux<br />

Mux1<br />

Speed Profiles<br />

Xdot<br />

1<br />

1<br />

X<br />

s<br />

Integrator<br />

s<br />

Integrator1<br />

Mux<br />

Mux<br />

Distance Profiles<br />

Transport<br />

Delay<br />

Speed LTU<br />

k (Xdot_ltu - Xdot_ftu)<br />

1<br />

Constant<br />

Xdot_ltu - Xdot_ftu<br />

1<br />

s<br />

Integrator2<br />

Virginia Polytechnic Institute and State University 13 of 31


Output of the Car-Following Model with Delay<br />

• The output suggests that a collision occurs with<br />

=0.75s.<br />

Space (m)<br />

τ<br />

Time (s)<br />

Virginia Polytechnic Institute and State University 14 of 31


Brief on C/C++ Compiler<br />

• Converts <strong>MATLAB</strong> M-Files to C and C++ code<br />

• Using this toolbox all graphics and math code can be<br />

converted to develop standalone applications<br />

• Typically requires <strong>MATLAB</strong> compiler and the <strong>MATLAB</strong><br />

C/C++ library<br />

• New features in version 5.3 also convert cell and<br />

structure arrays<br />

• My limited experience with this toolbox suggest<br />

substantial gains in speed if no vector operations have<br />

been implemented in the code<br />

• Vector operations show very little improvement when the<br />

code is compiled<br />

Virginia Polytechnic Institute and State University 15 of 31


Neural Network Toolbox<br />

P<br />

Input<br />

P<br />

RxQ<br />

1<br />

W1<br />

Z1xR<br />

b1<br />

n1<br />

Z1xQ<br />

F1<br />

a1<br />

Z1xQ<br />

W2<br />

Z2xZ1<br />

1 b2 Z2xQ 1<br />

F2 , a2 W3<br />

F3<br />

n2 Z2xQ<br />

n3<br />

Z3xZ2<br />

b3<br />

Z3xQ<br />

a3<br />

Z3xQ<br />

Z1x1<br />

Z2X1<br />

Z3x1<br />

• Provides 100+ functions to simplify the training,<br />

generalization and implementation of artificial neural<br />

networks<br />

• The functional implementation of the ANN toolbox is<br />

just through a series of <strong>MATLAB</strong> functions<br />

• All ANN functions are execued from the command line<br />

Virginia Polytechnic Institute and State University 16 of 31


Relevant Functions Provided<br />

• Layer initialization functions (Nguyen-Widrow)<br />

• Learning functions (gradients, perceptron, Widrow-Hoff)<br />

• Analysis functions (max. learning rate, error surface)<br />

• Line search functions (Golden section, backtraking)<br />

• Network functions (competitive, feed-forward wth<br />

backpropagation)<br />

• Performance functions (mean absolute error, SEE)<br />

• Training functions (BFGS, Bayesion regularization,<br />

Fletchel-Powell, Lavenberg-Marquardt, etc.)<br />

• Transfer functions (log signmoid, tangent sigmoid, etc.)<br />

Virginia Polytechnic Institute and State University 17 of 31


Problem:<br />

Example of ANN Using <strong>MATLAB</strong><br />

• To estimate aircraft fuel consumption based on aircraft<br />

performance parameters<br />

• Implementation on fast-time simulation models<br />

(SIMMOD, RAMS, etc.)<br />

Solution<br />

• Prototype model using <strong>MATLAB</strong>’s neural Network<br />

Toolbox<br />

• Verify the accuracy of the model with the current stateof-the<br />

art<br />

Virginia Polytechnic Institute and State University 18 of 31


Sample Data Presented in Flight Manual<br />

Virginia Polytechnic Institute and State University 19 of 31


Modeling Approach<br />

Training Data Set<br />

Learning Module<br />

Data Normalization<br />

Import Data<br />

Input learning pairs<br />

Forward<br />

Propagation<br />

Compute<br />

Error<br />

Initialize connection<br />

Weights<br />

Change and<br />

Update weights<br />

Configuration<br />

Parameters<br />

eg - maximum allowable error<br />

me- maximum allowable iterations<br />

YES<br />

NO<br />

Error<<br />

eg<br />

Number<br />

of cycles > me<br />

YES<br />

End of learning<br />

NO<br />

Virginia Polytechnic Institute and State University 20 of 31


Selected ANN Topology<br />

1<br />

w 1,1<br />

sum<br />

b 1 1<br />

sum<br />

n 1 1<br />

f1<br />

f1<br />

a 1 1<br />

w 2<br />

1,1<br />

sum<br />

sum<br />

2<br />

b<br />

1<br />

n 2 1<br />

f2<br />

f2<br />

a 2 1<br />

Target<br />

sum<br />

f1<br />

sum<br />

f2<br />

Altitude<br />

Mach<br />

sum<br />

f1<br />

sum<br />

f2<br />

sum<br />

n 3 1<br />

f3<br />

Fuel burn<br />

Initial<br />

Weight<br />

sum<br />

f1<br />

sum<br />

f2<br />

b 3 1<br />

ISA Cond.<br />

sum<br />

f1<br />

sum<br />

f2<br />

1<br />

w 8,4<br />

sum<br />

f1<br />

sum<br />

f2<br />

a 2 8<br />

sum<br />

f1<br />

sum<br />

n 2 8<br />

f2<br />

n 1 8<br />

a 1 8<br />

w 2 8,8<br />

b 2 8<br />

Where f1 - log-sigmoid transfer function<br />

f2 - tansigmoid transfer function<br />

f3 - purelin transfer function<br />

Virginia Polytechnic Institute and State University 21 of 31


ANN Data<br />

The data sets used to develop and train the ANN are<br />

shown below. Generalization of the ANN was conducted<br />

using another (random) data set<br />

Flight Phase<br />

Number of Testing Points<br />

Takeoff and Climbout Nor applicable (linear regression<br />

used instead)<br />

Climb to Cruise Altitude<br />

850 (Fuel)<br />

850 (Distance)<br />

Cruise 805<br />

Descent<br />

1210 (Fuel)<br />

140 (Distance)<br />

Virginia Polytechnic Institute and State University 22 of 31


Summary of Results (Fokker F100)<br />

The results shown in the table illustrate the accuracy of<br />

the model<br />

Flight Phase<br />

Climb<br />

• Distance<br />

• Fuel<br />

Cruise Specific<br />

<strong>Air</strong> Range<br />

Mean<br />

Error (%)<br />

0.377<br />

1.026<br />

Standard<br />

Deviation (%)<br />

0.305<br />

0.190<br />

Null Hypothesis<br />

(t-test at α 0.01)<br />

=<br />

Accept<br />

Accept<br />

-0.034 0.334 Accept<br />

Virginia Polytechnic Institute and State University 23 of 31


Flight Phase<br />

Descent<br />

• Distance<br />

• Fuel<br />

Mean<br />

Error (%)<br />

1.760<br />

1.423<br />

Standard<br />

Deviation (%)<br />

1.860<br />

1.177<br />

Null Hypothesis<br />

(t-test at α = 0.01)<br />

Accept<br />

Accept<br />

Virginia Polytechnic Institute and State University 24 of 31


Sample Results (Climb Fuel)<br />

• The results of training an ANN with 3 layers are shown<br />

below<br />

6000<br />

5000<br />

*<br />

Actual Data<br />

Estimated Data<br />

Climb Fuel (lb)<br />

4000<br />

3000<br />

2000<br />

1000<br />

0<br />

0 5 10 15 20 25 30 35 40<br />

Pressure Altitude (kft)<br />

Virginia Polytechnic Institute and State University 25 of 31


Absolute Error of ANN<br />

The errors of the ANN are very small as depicted in this<br />

graph for SFC<br />

160<br />

Frequency<br />

140<br />

120<br />

100<br />

80<br />

60<br />

40<br />

20<br />

Complete flight envelope<br />

0.60 < Mach < 0.75<br />

10,000 ft < altitude < 37,000 ft<br />

58,000 lb < weight < 98,000 lb<br />

805 data points<br />

0<br />

-1.5 -1 -0.5 0 0.5 1 1.5<br />

Specific Range Error (%)<br />

Virginia Polytechnic Institute and State University 26 of 31


Application of the Model to Complete Flight Plans<br />

The ANN model developed has been applied to a generic<br />

flight trajectory generator with very accurate results<br />

Flight plan way-points<br />

Constant heading<br />

segments<br />

30<br />

Descent<br />

Climb<br />

Altitude (kft)<br />

20<br />

10<br />

0<br />

80 MIA<br />

85<br />

Longitude (deg)<br />

90<br />

95<br />

Pseudo-globe circle route<br />

100 26<br />

27<br />

26.5<br />

28<br />

27.5<br />

DFW<br />

29<br />

28.5<br />

Latitude (deg)<br />

29.5<br />

Virginia Polytechnic Institute and State University 27 of 31


Complete Flight Plan Correlation<br />

Flight<br />

ROA a -<br />

MDW b<br />

MIA c -DFW d<br />

ROA-LGA e<br />

ATL f -MIA<br />

Cruise Flight<br />

Level (FL)<br />

Distance<br />

(nm) /<br />

Time (hr)<br />

a.ROA - Roanoke Regional <strong>Air</strong>port (Virginia)<br />

b.MDW - Midway <strong>Air</strong>port (Illinois)<br />

c.MIA - Miami International (Florida)<br />

d.DFW - Dallas-Forth Worth International (Texas)<br />

e.LGA - Laguardia <strong>Air</strong>port (New York)<br />

f. ATL - Atlanta Hartsfield International <strong>Air</strong>port (Georgia)<br />

Flight Manual<br />

Fuel Burn<br />

(lb)<br />

Neural Net<br />

Fuel Burn (lb)<br />

Percent<br />

Difference (%)<br />

280 448 / 1:08 6,457 6,546 1.37<br />

310 448 / 1:10 6,360 6,330 0.46<br />

310 972 / 2:24 11,851 11,865 0.12<br />

350 972 / 2:13 11,510 11,544 0.29<br />

290 352 / 0:57 5,298 5,260 0.71<br />

330 352 / 0:58 5,343 5,429 1.61<br />

290 518 / 1:20 6,990 7,047 0.80<br />

330 518 / 1:21 7,009 7,082 1.04<br />

Virginia Polytechnic Institute and State University 28 of 31


Sample Source Code<br />

% Initialize Weights and Biasis<br />

nns = 8; % Number of Neurons in each layer<br />

nns2 = 8;<br />

%********************************<br />

% For Climb Distance **<br />

%********************************<br />

[W31_cb_d,b31_cb_d,W32_cb_d,b32_cb_d,W33_cb_d,<br />

b33_cb_d ]=initff(P1_cbd,nns,'logsig',nns2 ...<br />

,'tansig',T1_cbd,'purelin');<br />

% Taining of the neural networks using Lavenberg-<br />

Marquardt Alogrithm<br />

Virginia Polytechnic Institute and State University 29 of 31


[W31_cb_d,b31_cb_d,W32_cb_d,b32_cb_d,W33_cb_<br />

d,b33_cb_d ]= trainlm(W31_cb_d,b31_cb_d,'logsig' ...<br />

,W32_cb_d,b32_cb_d,'tansig',W33_cb_d,b33_cb_d,'pure<br />

lin',P_cbd,Ta_cbd,tp);<br />

%********************************<br />

% For Climb Fuel **<br />

%********************************<br />

[W31_cb_f,b31_cb_f,W32_cb_f,b32_cb_f,W33_cb_f,b3<br />

3_cb_f ]=initff(P1_cbf,nns,'logsig',nns2,'tansig' ...<br />

,T1_cbf,'purelin');<br />

% Taining of the neural networks using Lavenberg-<br />

Marquardt Alogrithm<br />

[W31_cb_f,b31_cb_f,W32_cb_f,b32_cb_f,W33_cb_f,b3<br />

3_cb_f ]=<br />

trainlm(W31_cb_f,b31_cb_f,'logsig',W32_cb_f ...<br />

Virginia Polytechnic Institute and State University 30 of 31


,b32_cb_f,'tansig',W33_cb_f,b33_cb_f,'purelin',P_cbf,<br />

Ta_cbf,tp);<br />

Virginia Polytechnic Institute and State University 31 of 31

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!