%% Begin README: Optimizing energy consumption of BLOODHOUND Supersonic car
% Using the <http://www.mathworks.com/products/symbolic/index.html Symbolic Math Toolbox>, an optimization problem is setup to minimize the energy consumption of a supersonic car.
% Then the Optimization Toolbox is used to optimize the energy
% consumption. Some sample equations developed in the <http://www.mathworks.com/products/symbolic/description5.html Symbolic Math
% Notebook app> are shown below.
%
%
% <<image/image.PNG>>
%
%
% Copyright 2012 The MathWorks, Inc.
%% References
%
% # Find the related webinar: *Using Analytical Tools to Gain Insight and Speed Up
% Numerical Analysis in MATLAB* <http://www.mathworks.com/wbnr73465 here>
% # For background into the *BLOODHOUND* project and for more details
% on this example, refer to
% <http://www.matlabexpo.com/uk/2012/proceedings/minimising-the-energy-consumed-during-the-run-of-bloodhound-ssc.html
% Optimizing energy consumption of BLOODHOUND Supersonic car>.
%% Setup
% <matlab:setup Run> setup if you directly opened this HTML page.
%
%% Derive dynamics of car in the Symbolic Math Notebook app
% The dynamics for the each stage of the car's run are derived and equations
% relevant for the objective function and constraints of optimization problem
% are setup.
%
% <matlab:open('BLOODHOUND_SSC.mn') Open notebook>
%% Optimize using Symbolically derived objective function and constraints
% The objective function and constraints were created by accessing
% expressions from the notebook and calling <http://www.mathworks.com/help/symbolic/matlabfunction.html matlabFunction> to convert
% into numeric code
%
% <matlab:optimisationSymbolic([5,30,32,33]) Run> the _*symbolic*_ based
% optimization for the initial guess specified below.
%
% <html>
% <table border=1><tr><td><strong>Event</td><td><strong>Times (s)</td></tr>
% <tr><td>Rocket Starts</td><td>5</td></tr>
% <tr><td>Engines shut off</td><td>30</td></tr>
% <tr><td>Chute 1 deploys</td><td>32</td></tr>
% <tr><td>Chute 2 deploys</td><td>33</td></tr>
% </table>
% </html>
%
%% Optimize using ODE suite based objective function and constraints
% The objective function and constraints use a time integration solver from
% MATLAB's ODE suite. Every time the objective function and the gradients
% are evaluated, the ODE solver is called. This is computationally more
% expensive than evaluating the symbolically derived expressions.
%
% <matlab:optimisationNumeric([5,30,32,33]) Run> the _*non-symbolic*_ based optimization for the same initial guess
% as specified above.
%
%% Solve symbolic based optimization in optimtool
% optimtool from the Optimization Toolbox is launched and set up with the symbolically derived objective
% function and constraints. The convergence to the optimial solution is
% shown visually. A pause is introduced in the plotting to show the
% convergence more clearly.
%
% <matlab:optimtool(optimproblemSymbolic) Open optimtool>
%
% Click *"Start"* in optimtool to start optimization.
%
%% Disclaimer
% *The Bloodhound Project Disclaimer on use of information and data:*
% Disclaimer on user of Bloodhound Programme Limited has provided this data as advisory and indicative and specifically and exclusively for the purpose of education. All facts, figures, concepts and principals provided relate only to the Bloodhound project. They may be inaccurate, out of date and subject to revision without notice. Under no circumstances should the data provided (or any derivative thereof) be used in whole or in part for any project, except in a purely theoretical environment. It should be understood that the entire project is experimental with high levels of personal risk and danger.
% Bloodhound Programme Limited, its directors, designers and associates do not accept any responsibility or liability whatsoever for use by any party of the data provided in breach of these terms.
% All data provided by Bloodhound Programme Limited is confidential and proprietary to the Bloodhound Programme Limited. All such data shall only be used for the purposes of education and shall not be used by any party for commercial gain.