{"id":3631,"date":"2014-05-07T16:12:48","date_gmt":"2014-05-07T21:12:48","guid":{"rendered":"https:\/\/blogs.mathworks.com\/seth\/?p=3631"},"modified":"2014-05-12T08:43:38","modified_gmt":"2014-05-12T13:43:38","slug":"optimizing-the-hyperloop-trajectory","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/simulink\/2014\/05\/07\/optimizing-the-hyperloop-trajectory\/","title":{"rendered":"Optimizing the Hyperloop Trajectory"},"content":{"rendered":"<p>This week, <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/399849\">Matt Brauer<\/a> is back to describe further analysis of the <a href=\"http:\/\/en.wikipedia.org\/wiki\/Hyperloop\">hyperloop transportation concept<\/a>.<\/p>\r\n\r\n<p><strong>The world is not flat<\/strong><\/p>\r\n\r\n<!--introduction-->\r\n<p>We previously published <a href=\"https:\/\/blogs.mathworks.com\/seth\/2013\/11\/22\/hyperloop-not-so-fast\/\">two-dimensional analysis<\/a> for deriving a route for the hyperloop based on lateral acceleration limits. This time I looked at the other dimension of the problem: <strong>Elevation<\/strong>.  This will complete the input data needed to fully <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/44878-hyperloop-model--systems-architecture-\">simulate the Hyperloop<\/a>.<\/p>\r\n<!--\/introduction-->\r\n\r\n<p>I used optimization to determine the best elevation profile, combining pillars and tunnels along the route. I ended up with about <strong>86 km of tunnels<\/strong>, with the longest continuous tunnel being about 2 km long. This result is about three times the amount of tunneling indicated in the <a href=\"\">alpha design document<\/a>. Of course, this conclusion is heavily influenced by the approach used to optimize pillar height and vertical g-forces.<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2014Q2\/animatedElevationProfile.gif\" alt=\"Derived elevation profile for the hyperloop\" \/>\r\n<em>Derived elevation profile for the hyperloop<\/em><\/p>\r\n\r\n<p>Here\u2019s how I came to my results.<\/p>\r\n\r\n<p><strong>Assumptions and Formulation<\/strong><\/p>\r\n\r\n<p>I started with the assumption that the 2-D route is fixed. This assumption makes elevation a 1-D problem, which is simpler than tackling three dimensions simultaneously. However, the problem is still non-trivial. I decided to use the <a href=\"https:\/\/www.mathworks.com\/products\/optimization\/\">Optimization Toolbox<\/a> for the heavy lifting.<\/p>\r\n\r\n<p>In my experience, there are four critical elements that guide successful use of optimization techniques:<\/p>\r\n\r\n<ul>\r\n\t<li>Formulation of the data<\/li>\r\n\t<li>Cost function<\/li>\r\n\t<li>Optimization routine configuration<\/li>\r\n\t<li>Initial Guess<\/li>\r\n<\/ul>\r\n\r\n<p>The right combination of these elements can be very effective at solving complex problems. I\u2019ll describe briefly how I set these elements to solve this problem.<\/p>\r\n\r\n<p><strong>Data to be optimized<\/strong><\/p>\r\n\r\n<p>I chose a simple formulation for the optimization data. I used a vector of pillar heights\/depths spaced every 30m along the route. I found that to keep the optimization problem manageable I needed to break up the route into 12 sub-sections. The convergence time seemed to rise asymptotically with larger data sets. <\/p>\r\n\r\n<p><strong>Defining the cost function<\/strong><\/p>\r\n\r\n<p>To perform a numeric optimization, there must be a quantified evaluation of the solution. This cost function can then be minimized using the Optimization Toolbox to converge on the best solution. I chose to incorporate two elements into the cost function; (1) construction costs due to height\/depth of the tube and (2) passenger comfort based on vertical acceleration. I created the tables below to quantify these cost elements at each point along the route.<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2014Q2\/CostFunctionsWithNotes.png\" alt=\"Cost tables for Construction Costs and Passenger Comfort\" \/>\r\n<em>Cost tables for Construction Costs and Passenger Comfort<\/em><\/p>\r\n\r\n<p>The equation below is used to arrive at a final value for the complete route. I can influence the relative priority of passenger comfort and construction costs by adjusting <tt>wConst<\/tt> and <tt>wComf<\/tt>.<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2014Q2\/costFcn.png\" alt=\"Cost function for Construction Costs and Passenger Comfort\" \/><\/p>\r\n\r\n<p><strong>Configuring the Optimization Routine<\/strong><\/p>\r\n\r\n<p>To calculate the cost function on the optimization data, I needed additional data such as ground elevation. I was able to pass these data to my cost function <tt>elevOpt<\/tt> by creating the function handle below. This statement defines <tt>x<\/tt> as the optimization data, but allows <tt>z_dist<\/tt> (translational distance), <tt>z_elev<\/tt> (ground elevation) and <tt>z_vel<\/tt> (vehicle velocity) to be passed as arguments as well.<\/p>\r\n\r\n<code><span class=\"comment\">% Create function handle for passing additional data<\/span>\r\nhandle_trajOpt  = @(x)elevOpt(x,z_dist,z_elev,z_vel);\r\n<\/code>\r\n\r\n<p>I tried several different optimization algorithms and found the best results using the quasi-newton algorithm of <a href=\"https:\/\/www.mathworks.com\/help\/optim\/ug\/fminunc.html\"><tt>fminunc<\/tt><\/a>. I also had to increase the maximum iterations and function evaluations to ensure that I reached an adequate solution.<\/p>\r\n\r\n<code><span class=\"comment\">% Set options<\/span>\r\noptions     = optimoptions(@fminunc,<span class=\"string\">'Algorithm'<\/span>,<span class=\"string\">'quasi-newton'<\/span>,<span class=\"keyword\">...<\/span>\r\n            <span class=\"string\">'Display'<\/span>,<span class=\"string\">'iter'<\/span>,<span class=\"string\">'MaxIter'<\/span>,5000,<span class=\"string\">'PlotFcns'<\/span>,{@optimplotfval,@plotElevOpt},<span class=\"keyword\">...<\/span>\r\n            <span class=\"string\">'MaxFunEvals'<\/span>,1e7);\r\n<\/code>\r\n\r\n<p><strong>The initial guess<\/strong><\/p>\r\n\r\n<p>I started my investigation trying two different starting points; a constant 3m height above the ground and an absolutely flat trajectory with constant elevation. It was interesting how the initial guess for the trajectory would affect the speed of the optimization and the final result. I was able to visualize how the results were shaping up with a customized plotting function. You can see in the code above how that function, <tt>plotElevOpt<\/tt>, was passed as a <tt>PlotFcns<\/tt> parameter in the optimization options.<\/p>\r\n\r\n<p>Here are two examples with the uniform and flat seeds. To keep them interesting, these plots have been sped up about 5x.<\/p>\r\n\r\n<code><span class=\"codeinput\">[x, ~, ~, ~ ]   = fminunc(handle_trajOpt,x0,options);<\/span><\/code>\r\n\r\n<p>Here is the evolution of the optimization starting with a constant 3m height above the ground:<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2014Q2\/EqualHtOpt.gif\" alt=\"Optimization with uniform height initial guess\" \/>\r\n<em>Optimization with uniform height initial guess<\/em><\/p>\r\n\r\n<p>And now starting with a flat constant elevation:<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2014Q2\/FlatOpt.gif\" alt=\"Optimization with flat initial guess\" \/>\r\n<em>Optimization with flat initial guess<\/em><\/p>\r\n\r\n<p>For several of the route sections, a hybrid of the two worked best. I ended up using the <a href=\"https:\/\/www.mathworks.com\/help\/curvefit\/fit.html\"><tt>fit<\/tt><\/a> function from the <a href=\"https:\/\/www.mathworks.com\/products\/curvefitting\/\">Curve Fitting Toolbox<\/a> on the constant height trajectory to start with a smoother curve as initial guess. This profile generally followed the ground elevation but didn't have the excessive vertical acceleration peaks. For flatter sections, this initial guess came very close to the final solution.<\/p>\r\n\r\n<p><strong>Now it\u2019s your turn<\/strong><\/p>\r\n\r\n<p>How would you approach identifying the optimal Hyperloop route? Let us know by leaving a <a href=\"https:\/\/blogs.mathworks.com\/seth\/?p=3631&#comment\">comment here<\/a>.<\/p>","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img decoding=\"async\"  class=\"img-responsive\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2014Q2\/FlatOpt.gif\" onError=\"this.style.display ='none';\" \/><\/div><!--introduction-->\r\n<p>We previously published <a href=\"https:\/\/blogs.mathworks.com\/seth\/2013\/11\/22\/hyperloop-not-so-fast\/\">two-dimensional analysis<\/a> for deriving a route for the hyperloop based on lateral acceleration limits. This time I looked at the other dimension of the problem: <strong>Elevation<\/strong>.  This will complete the input data needed to fully <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/44878-hyperloop-model--systems-architecture-\">simulate the Hyperloop<\/a>.... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/simulink\/2014\/05\/07\/optimizing-the-hyperloop-trajectory\/\">read more >><\/a><\/p>","protected":false},"author":41,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[121,71,30],"tags":[348,383,93],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts\/3631"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/users\/41"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/comments?post=3631"}],"version-history":[{"count":29,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts\/3631\/revisions"}],"predecessor-version":[{"id":3666,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts\/3631\/revisions\/3666"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/media?parent=3631"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/categories?post=3631"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/tags?post=3631"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}