https://github.com/kuo-lab/simplelocomotionmodel
Raw File
Tip revision: fc46ca7f88d6f91ec43bb77f0d8809df2eb73ee8 authored by Art Kuo on 14 February 2023, 22:04:04 UTC
extra readme about cloning and downloading
Tip revision: fc46ca7
shortwalks.html
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head>

<meta charset="utf-8">
<meta name="generator" content="quarto-1.1.251">

<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">


<title>Dynamic optimization of human walking speeds</title>
<style>
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
div.columns{display: flex; gap: min(4vw, 1.5em);}
div.column{flex: auto; overflow-x: auto;}
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
ul.task-list{list-style: none;}
ul.task-list li input[type="checkbox"] {
  width: 0.8em;
  margin: 0 0.8em 0.2em -1.6em;
  vertical-align: middle;
}
pre > code.sourceCode { white-space: pre; position: relative; }
pre > code.sourceCode > span { display: inline-block; line-height: 1.25; }
pre > code.sourceCode > span:empty { height: 1.2em; }
.sourceCode { overflow: visible; }
code.sourceCode > span { color: inherit; text-decoration: inherit; }
div.sourceCode { margin: 1em 0; }
pre.sourceCode { margin: 0; }
@media screen {
div.sourceCode { overflow: auto; }
}
@media print {
pre > code.sourceCode { white-space: pre-wrap; }
pre > code.sourceCode > span { text-indent: -5em; padding-left: 5em; }
}
pre.numberSource code
  { counter-reset: source-line 0; }
pre.numberSource code > span
  { position: relative; left: -4em; counter-increment: source-line; }
pre.numberSource code > span > a:first-child::before
  { content: counter(source-line);
    position: relative; left: -1em; text-align: right; vertical-align: baseline;
    border: none; display: inline-block;
    -webkit-touch-callout: none; -webkit-user-select: none;
    -khtml-user-select: none; -moz-user-select: none;
    -ms-user-select: none; user-select: none;
    padding: 0 4px; width: 4em;
    color: #aaaaaa;
  }
pre.numberSource { margin-left: 3em; border-left: 1px solid #aaaaaa;  padding-left: 4px; }
div.sourceCode
  {   }
@media screen {
pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; }
}
code span.al { color: #ff0000; font-weight: bold; } /* Alert */
code span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */
code span.at { color: #7d9029; } /* Attribute */
code span.bn { color: #40a070; } /* BaseN */
code span.bu { color: #008000; } /* BuiltIn */
code span.cf { color: #007020; font-weight: bold; } /* ControlFlow */
code span.ch { color: #4070a0; } /* Char */
code span.cn { color: #880000; } /* Constant */
code span.co { color: #60a0b0; font-style: italic; } /* Comment */
code span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */
code span.do { color: #ba2121; font-style: italic; } /* Documentation */
code span.dt { color: #902000; } /* DataType */
code span.dv { color: #40a070; } /* DecVal */
code span.er { color: #ff0000; font-weight: bold; } /* Error */
code span.ex { } /* Extension */
code span.fl { color: #40a070; } /* Float */
code span.fu { color: #06287e; } /* Function */
code span.im { color: #008000; font-weight: bold; } /* Import */
code span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */
code span.kw { color: #007020; font-weight: bold; } /* Keyword */
code span.op { color: #666666; } /* Operator */
code span.ot { color: #007020; } /* Other */
code span.pp { color: #bc7a00; } /* Preprocessor */
code span.sc { color: #4070a0; } /* SpecialChar */
code span.ss { color: #bb6688; } /* SpecialString */
code span.st { color: #4070a0; } /* String */
code span.va { color: #19177c; } /* Variable */
code span.vs { color: #4070a0; } /* VerbatimString */
code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warning */
div.csl-bib-body { }
div.csl-entry {
  clear: both;
}
.hanging div.csl-entry {
  margin-left:2em;
  text-indent:-2em;
}
div.csl-left-margin {
  min-width:2em;
  float:left;
}
div.csl-right-inline {
  margin-left:2em;
  padding-left:1em;
}
div.csl-indent {
  margin-left: 2em;
}
</style>


<script src="shortwalks_files/libs/clipboard/clipboard.min.js"></script>
<script src="shortwalks_files/libs/quarto-html/quarto.js"></script>
<script src="shortwalks_files/libs/quarto-html/popper.min.js"></script>
<script src="shortwalks_files/libs/quarto-html/tippy.umd.min.js"></script>
<script src="shortwalks_files/libs/quarto-html/anchor.min.js"></script>
<link href="shortwalks_files/libs/quarto-html/tippy.css" rel="stylesheet">
<link href="shortwalks_files/libs/quarto-html/quarto-syntax-highlighting.css" rel="stylesheet" id="quarto-text-highlighting-styles">
<script src="shortwalks_files/libs/bootstrap/bootstrap.min.js"></script>
<link href="shortwalks_files/libs/bootstrap/bootstrap-icons.css" rel="stylesheet">
<link href="shortwalks_files/libs/bootstrap/bootstrap.min.css" rel="stylesheet" id="quarto-bootstrap" data-mode="light">

  <script src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml-full.js" type="text/javascript"></script>

</head>

<body class="fullcontent">

<div id="quarto-content" class="page-columns page-rows-contents page-layout-article">

<main class="content" id="quarto-document-content">

<header id="title-block-header" class="quarto-title-block default">
<div class="quarto-title">
<h1 class="title">Dynamic optimization of human walking speeds</h1>
</div>



<div class="quarto-title-meta">

    
    
  </div>
  

</header>

<section id="optimization-of-energy-and-time-predicts-dynamic-speeds-for-human-walking-carlisle2022optimizationenergytime" class="level2">
<h2 class="anchored" data-anchor-id="optimization-of-energy-and-time-predicts-dynamic-speeds-for-human-walking-carlisle2022optimizationenergytime">Optimization of energy and time predicts dynamic speeds for human walking <span class="citation" data-cites="carlisle2022OptimizationEnergyTime">(<a href="#ref-carlisle2022OptimizationEnergyTime" role="doc-biblioref">Carlisle and Kuo 2022</a>)</span></h2>
<p>Take walks of varying distances, and show how the optimal trajectory has an inverted-U velocity profile, with peak speed that increases with distance up to about 12 steps, leveling off thereafter. The cost function is net mechanical work, plus a linear cost of time with coefficient ctime.</p>
<section id="go-for-a-single-walk" class="level3">
<h3 class="anchored" data-anchor-id="go-for-a-single-walk">Go for a single walk</h3>
<p>Take a walk of 10 steps, starting and ending at rest. Find the optimal push-offs that minimize total work. The optimization is performed with <code>optwalktime</code> which uses a time cost (relative to work) of <code>tchange</code>.</p>
<div class="cell" data-execution_count="1">
<details>
<summary>Code</summary>
<div class="sourceCode cell-code" id="cb1"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="im">using</span> <span class="bu">DynLoco</span>, <span class="bu">Plots</span>, <span class="bu">Statistics</span></span>
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb1-3"><a href="#cb1-3" aria-hidden="true" tabindex="-1"></a>wstar4 <span class="op">=</span> <span class="fu">findgait</span>(<span class="fu">WalkRW2l</span>(α<span class="op">=</span><span class="fl">0.35</span>,safety<span class="op">=</span><span class="cn">true</span>), target<span class="op">=:</span>speed<span class="op">=&gt;</span><span class="fl">0.3</span>, varying<span class="op">=:</span>P)</span>
<span id="cb1-4"><a href="#cb1-4" aria-hidden="true" tabindex="-1"></a>ctime <span class="op">=</span> <span class="fl">0.015</span> <span class="co"># cost of time, to encourage hurrying</span></span>
<span id="cb1-5"><a href="#cb1-5" aria-hidden="true" tabindex="-1"></a>tchange <span class="op">=</span> <span class="fl">1.75</span> <span class="co"># boundary condition time to get up to speed (arbitrary, excluded from optimization) </span></span>
<span id="cb1-6"><a href="#cb1-6" aria-hidden="true" tabindex="-1"></a>p <span class="op">=</span> <span class="fu">plot</span>() </span>
<span id="cb1-7"><a href="#cb1-7" aria-hidden="true" tabindex="-1"></a>nsteps <span class="op">=</span> <span class="fl">10</span></span>
<span id="cb1-8"><a href="#cb1-8" aria-hidden="true" tabindex="-1"></a>result <span class="op">=</span> <span class="fu">optwalktime</span>(wstar4, nsteps, ctime<span class="op">=</span>ctime) <span class="co"># optimize work and time</span></span>
<span id="cb1-9"><a href="#cb1-9" aria-hidden="true" tabindex="-1"></a><span class="fu">multistepplot</span>(result, legend<span class="op">=</span><span class="cn">false</span>) <span class="co"># plot speed, push-off, terrain trajectories</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</details>
<div class="cell-output cell-output-display" data-execution_count="13">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="shortwalks_files/figure-html/cell-2-output-1.svg" class="img-fluid figure-img"></p>
<p></p><figcaption class="figure-caption">Speed vs time for a short walk. The mid-stance speeds, push-offs, and terrain heights are plotted vs discrete step number.</figcaption><p></p>
</figure>
</div>
</div>
</div>
<p>All quantities are plotted dimensionlessly, with base units of body mass <span class="math inline">\(M\)</span>, leg length <span class="math inline">\(L\)</span>, and gravitational acceleration <span class="math inline">\(g\)</span>. Thus speed is normalized by <span class="math inline">\(\sqrt(gL)\)</span> and time by <span class="math inline">\(\sqrt(L/g)\)</span>. For a typical leg length of <span class="math inline">\(L = 1 \mathrm{m}\)</span>, the dimensional speed is about 1.25 m/s, and step time about 0.55 s.</p>
</section>
<section id="go-for-walks-of-verying-distance" class="level3">
<h3 class="anchored" data-anchor-id="go-for-walks-of-verying-distance">Go for walks of verying distance</h3>
<p>The predicted speed profile varies with distance. Shorter walks have very brief and slower peaks, and are dominated by speeding up and slowing down. Longer walks have flatter and faster peaks, approching a steady walking speed. Relatively less time is spent speeding up and slowing down.</p>
<div class="cell" data-execution_count="2">
<details>
<summary>Code</summary>
<div class="sourceCode cell-code" id="cb2"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a>p <span class="op">=</span> <span class="fu">plot</span>() </span>
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a>walksteps <span class="op">=</span> [<span class="fl">1</span>, <span class="fl">2</span>, <span class="fl">3</span>, <span class="fl">4</span>, <span class="fl">5</span>, <span class="fl">6</span>, <span class="fl">7</span>, <span class="fl">10</span>, <span class="fl">15</span>, <span class="fl">20</span>] <span class="co"># take walks of this # of steps</span></span>
<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a>results <span class="op">=</span> <span class="fu">Array</span><span class="dt">{MultiStepResults,1}</span>(<span class="cn">undef</span>,<span class="fl">0</span>) <span class="co"># store each optimization result here</span></span>
<span id="cb2-4"><a href="#cb2-4" aria-hidden="true" tabindex="-1"></a><span class="cf">for</span> (i,nsteps) <span class="kw">in</span> <span class="fu">enumerate</span>(walksteps)</span>
<span id="cb2-5"><a href="#cb2-5" aria-hidden="true" tabindex="-1"></a>    result <span class="op">=</span> <span class="fu">optwalktime</span>(wstar4, nsteps, ctime<span class="op">=</span>ctime) <span class="co"># optimize with a cost of time</span></span>
<span id="cb2-6"><a href="#cb2-6" aria-hidden="true" tabindex="-1"></a>    <span class="fu">plotvees!</span>(p, result, tchange<span class="op">=</span>tchange, usespline<span class="op">=</span><span class="cn">false</span>, color<span class="op">=</span>i, speedtype<span class="op">=:</span>shortwalks, rampuporder<span class="op">=</span><span class="fl">1</span>, markersize<span class="op">=</span><span class="fl">2</span>) <span class="co"># plot instantaneous body speed vs. time</span></span>
<span id="cb2-7"><a href="#cb2-7" aria-hidden="true" tabindex="-1"></a>    <span class="fu">push!</span>(results, result) <span class="co"># add this optimization to results array</span></span>
<span id="cb2-8"><a href="#cb2-8" aria-hidden="true" tabindex="-1"></a><span class="cf">end</span></span>
<span id="cb2-9"><a href="#cb2-9" aria-hidden="true" tabindex="-1"></a>Plots.<span class="fu">display</span>(p) <span class="co"># instantaneous speed vs. distance profiles</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</details>
<div class="cell-output cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="shortwalks_files/figure-html/cell-3-output-1.svg" class="img-fluid figure-img"></p>
<p></p><figcaption class="figure-caption">Speed vs time for short walks; each trace is a different bout distance</figcaption><p></p>
</figure>
</div>
</div>
</div>
<p>Here the speeds are plotted as “body speed” each step, to match IMU. Model is parameterized by mid-stance speed each step, but IMU data only yields strides. As described by <span class="citation" data-cites="carlisle2022OptimizationEnergyTime">Carlisle and Kuo (<a href="#ref-carlisle2022OptimizationEnergyTime" role="doc-biblioref">2022</a>)</span>, we use estimated mid-stance times to estimate body speed.</p>
</section>
</section>
<section id="compare-three-objectives-energy-time-min-cot-constant-acceleration" class="level2">
<h2 class="anchored" data-anchor-id="compare-three-objectives-energy-time-min-cot-constant-acceleration">Compare three objectives: Energy-Time, min-COT, constant acceleration</h2>
<p>Walk a fixed number of steps, starting and ending at rest. The objectives are:</p>
<ul>
<li><strong>Energy-Time</strong> minimizes total energy (positive work) plus proportional time cost</li>
<li><strong>min-COT</strong> walks at a constant speed that minimizes cost of transport (energy per weight and distance traveled), with a trapezoidal speed profile. This is achieved by minimizing deviation from minCOT speed, to allow model to accelerate to that speed.</li>
<li><strong>Constant accel</strong> accelerates at a constant rate, to yield a triangular speed profile. Uses a minimum variance objective to produce a constant rate of velocity change.</li>
</ul>
<p>Compare for a fixed number of steps.</p>
<div class="cell" data-execution_count="3">
<details>
<summary>Code</summary>
<div class="sourceCode cell-code" id="cb3"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="co"># A minCOT nominal gait</span></span>
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a>wstar4n <span class="op">=</span> <span class="fu">findgait</span>(<span class="fu">WalkRW2l</span>(α<span class="op">=</span><span class="fl">0.35</span>, safety<span class="op">=</span><span class="cn">true</span>), target<span class="op">=:</span>speed<span class="op">=&gt;</span><span class="fl">0.4</span>, varying<span class="op">=:</span>P) <span class="co"># use a speed of 0.4 to match minCOT</span></span>
<span id="cb3-3"><a href="#cb3-3" aria-hidden="true" tabindex="-1"></a>nsteps <span class="op">=</span> <span class="fl">10</span></span>
<span id="cb3-4"><a href="#cb3-4" aria-hidden="true" tabindex="-1"></a>ctime <span class="op">=</span> <span class="fl">0.0195</span></span>
<span id="cb3-5"><a href="#cb3-5" aria-hidden="true" tabindex="-1"></a>tchange <span class="op">=</span> <span class="fl">1.75</span></span>
<span id="cb3-6"><a href="#cb3-6" aria-hidden="true" tabindex="-1"></a>nominalresult<span class="op">=</span><span class="fu">optwalktime</span>(wstar4n, nsteps, ctime <span class="op">=</span> ctime, boundarywork<span class="op">=</span><span class="cn">true</span>) <span class="co"># to compare with our usual solution</span></span>
<span id="cb3-7"><a href="#cb3-7" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-8"><a href="#cb3-8" aria-hidden="true" tabindex="-1"></a><span class="co"># minCOT walk. optwalkvar minimizes variance from nominal</span></span>
<span id="cb3-9"><a href="#cb3-9" aria-hidden="true" tabindex="-1"></a>minvarresult<span class="op">=</span><span class="fu">optwalkvar</span>(wstar4n, nsteps, boundarywork<span class="op">=</span><span class="cn">true</span>)</span>
<span id="cb3-10"><a href="#cb3-10" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-11"><a href="#cb3-11" aria-hidden="true" tabindex="-1"></a><span class="co"># steady acceleration walk, which tries to maintain same</span></span>
<span id="cb3-12"><a href="#cb3-12" aria-hidden="true" tabindex="-1"></a><span class="co"># acceleration each step, resulting in a triangular speed</span></span>
<span id="cb3-13"><a href="#cb3-13" aria-hidden="true" tabindex="-1"></a><span class="co"># profile</span></span>
<span id="cb3-14"><a href="#cb3-14" aria-hidden="true" tabindex="-1"></a>A <span class="op">=</span> <span class="fl">0.0655</span> <span class="co"># 1.9*wstar4n.vm/(nsteps*onestep(wstar4n).tf) # acceleration</span></span>
<span id="cb3-15"><a href="#cb3-15" aria-hidden="true" tabindex="-1"></a>v0 <span class="op">=</span> <span class="fl">0.11</span> <span class="co"># 0.8*A*tchange # a couple acceleration constants</span></span>
<span id="cb3-16"><a href="#cb3-16" aria-hidden="true" tabindex="-1"></a><span class="co"># chosen by hand to allow smooth transition from initiation</span></span>
<span id="cb3-17"><a href="#cb3-17" aria-hidden="true" tabindex="-1"></a><span class="co"># to push-off.</span></span>
<span id="cb3-18"><a href="#cb3-18" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-19"><a href="#cb3-19" aria-hidden="true" tabindex="-1"></a>constaccelresult <span class="op">=</span> <span class="fu">optwalktriangle</span>(wstar4n, nsteps, A <span class="op">=</span> A, boundarywork<span class="op">=</span><span class="cn">false</span>,boundaryvels<span class="op">=</span>(v0,v0))</span>
<span id="cb3-20"><a href="#cb3-20" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-21"><a href="#cb3-21" aria-hidden="true" tabindex="-1"></a><span class="co"># Make the plots</span></span>
<span id="cb3-22"><a href="#cb3-22" aria-hidden="true" tabindex="-1"></a>p <span class="op">=</span> <span class="fu">plot</span>(layout<span class="op">=</span>(<span class="fl">1</span>,<span class="fl">2</span>))</span>
<span id="cb3-23"><a href="#cb3-23" aria-hidden="true" tabindex="-1"></a><span class="fu">plotvees!</span>(p[<span class="fl">1</span>],nominalresult, tchange<span class="op">=</span>tchange, rampuporder<span class="op">=</span><span class="fl">1</span>, usespline <span class="op">=</span> <span class="cn">false</span>, markershape<span class="op">=:</span>circle,speedtype<span class="op">=:</span>shortwalks)</span>
<span id="cb3-24"><a href="#cb3-24" aria-hidden="true" tabindex="-1"></a><span class="fu">plotvees!</span>(p[<span class="fl">1</span>],minvarresult, tchange<span class="op">=</span>tchange, rampuporder<span class="op">=</span><span class="fl">1</span>, usespline <span class="op">=</span> <span class="cn">false</span>,markershape<span class="op">=:</span>circle, speedtype<span class="op">=:</span>shortwalks)</span>
<span id="cb3-25"><a href="#cb3-25" aria-hidden="true" tabindex="-1"></a><span class="fu">plotvees!</span>(p[<span class="fl">1</span>],constaccelresult, tchange<span class="op">=</span>tchange, rampuporder<span class="op">=</span><span class="fl">1</span>, usespline <span class="op">=</span> <span class="cn">false</span>,markershape<span class="op">=:</span>circle, speedtype<span class="op">=:</span>shortwalks, seriescolor<span class="op">=:</span>auto)</span>
<span id="cb3-26"><a href="#cb3-26" aria-hidden="true" tabindex="-1"></a><span class="fu">plot!</span>(p[<span class="fl">2</span>],[<span class="fl">0</span><span class="op">:</span>nsteps<span class="op">+</span><span class="fl">1</span>], [<span class="fl">1</span><span class="op">/</span><span class="fl">2</span><span class="op">*</span>nominalresult.vm0<span class="op">^</span><span class="fl">2</span>; nominalresult.steps.Pwork; <span class="cn">NaN</span>],markershape<span class="op">=:</span>circle,seriescolor<span class="op">=:</span>auto)</span>
<span id="cb3-27"><a href="#cb3-27" aria-hidden="true" tabindex="-1"></a><span class="fu">plot!</span>(p[<span class="fl">2</span>],[<span class="fl">0</span><span class="op">:</span>nsteps<span class="op">+</span><span class="fl">1</span>], [<span class="fl">1</span><span class="op">/</span><span class="fl">2</span><span class="op">*</span>minvarresult.vm0<span class="op">^</span><span class="fl">2</span>; minvarresult.steps.Pwork; <span class="cn">NaN</span>],markershape<span class="op">=:</span>circle,xticks<span class="op">=</span><span class="fl">0</span><span class="op">:</span>nsteps<span class="op">+</span><span class="fl">1</span>)</span>
<span id="cb3-28"><a href="#cb3-28" aria-hidden="true" tabindex="-1"></a><span class="fu">plot!</span>(p[<span class="fl">2</span>],[<span class="fl">0</span><span class="op">:</span>nsteps<span class="op">+</span><span class="fl">1</span>], [<span class="fl">1</span><span class="op">/</span><span class="fl">2</span><span class="op">*</span>constaccelresult.vm0<span class="op">^</span><span class="fl">2</span>; constaccelresult.steps.Pwork; <span class="cn">NaN</span>],markershape<span class="op">=:</span>circle,xticks<span class="op">=</span><span class="fl">0</span><span class="op">:</span>nsteps<span class="op">+</span><span class="fl">1</span>,seriescolor<span class="op">=:</span>auto)</span>
<span id="cb3-29"><a href="#cb3-29" aria-hidden="true" tabindex="-1"></a><span class="fu">plot!</span>(p[<span class="fl">2</span>],xlabel<span class="op">=</span><span class="st">"step"</span>, ylabel<span class="op">=</span><span class="st">"push-off work"</span>, legend<span class="op">=</span><span class="cn">false</span>)</span>
<span id="cb3-30"><a href="#cb3-30" aria-hidden="true" tabindex="-1"></a>energytimework <span class="op">=</span> <span class="fl">1</span><span class="op">/</span><span class="fl">2</span><span class="op">*</span>nominalresult.vm0<span class="op">^</span><span class="fl">2</span> <span class="op">+</span> <span class="fu">sum</span>(nominalresult.steps.Pwork)</span>
<span id="cb3-31"><a href="#cb3-31" aria-hidden="true" tabindex="-1"></a>mincotwork <span class="op">=</span> <span class="fl">1</span><span class="op">/</span><span class="fl">2</span><span class="op">*</span>minvarresult.vm0<span class="op">^</span><span class="fl">2</span> <span class="op">+</span> <span class="fu">sum</span>(minvarresult.steps.Pwork)</span>
<span id="cb3-32"><a href="#cb3-32" aria-hidden="true" tabindex="-1"></a>trianglework <span class="op">=</span> (<span class="fl">1</span><span class="op">/</span><span class="fl">2</span><span class="op">*</span>constaccelresult.vm0<span class="op">^</span><span class="fl">2</span> <span class="op">+</span> <span class="fu">sum</span>(constaccelresult.steps.Pwork))<span class="op">/</span>(<span class="fl">1</span><span class="op">/</span><span class="fl">2</span><span class="op">*</span>nominalresult.vm0<span class="op">^</span><span class="fl">2</span> <span class="op">+</span> <span class="fu">sum</span>(nominalresult.steps.Pwork))</span>
<span id="cb3-33"><a href="#cb3-33" aria-hidden="true" tabindex="-1"></a>Plots.<span class="fu">display</span>(p)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</details>
<div class="cell-output cell-output-display">
<p><img src="shortwalks_files/figure-html/cell-4-output-1.svg" class="img-fluid"></p>
</div>
</div>
<p>Quantify the three predictions. The energy cost for each walk consists of the positive work for gait initiation plus the positive push-off work for all steps. Negative work is ignored, because equal magnitudes of positive and negative work are performed for this task. If there are constant efficiencies for muscles to perform positive and negative work, the physiological cost of negative work is proportional to positive work. This affects the total metabolic cost, but does not affect the optimal solutions.</p>
<div class="cell" data-execution_count="4">
<details>
<summary>Code</summary>
<div class="sourceCode cell-code" id="cb4"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a>threecosts <span class="op">=</span> [<span class="fl">1</span><span class="op">/</span><span class="fl">2</span><span class="op">*</span>nominalresult.vm0<span class="op">^</span><span class="fl">2</span> <span class="op">+</span> <span class="fu">sum</span>(nominalresult.steps.Pwork), <span class="fl">1</span><span class="op">/</span><span class="fl">2</span><span class="op">*</span>minvarresult.vm0<span class="op">^</span><span class="fl">2</span> <span class="op">+</span> <span class="fu">sum</span>(minvarresult.steps.Pwork), <span class="fl">1</span><span class="op">/</span><span class="fl">2</span><span class="op">*</span>constaccelresult.vm0<span class="op">^</span><span class="fl">2</span> <span class="op">+</span> <span class="fu">sum</span>(constaccelresult.steps.Pwork)]</span>
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a><span class="fu">println</span>(<span class="st">"The energy-time work is </span><span class="sc">$</span>(threecosts[<span class="fl">1</span>])<span class="st">"</span>)</span>
<span id="cb4-3"><a href="#cb4-3" aria-hidden="true" tabindex="-1"></a><span class="fu">println</span>(<span class="st">"The min-COT work is </span><span class="sc">$</span>(threecosts[<span class="fl">2</span>])<span class="st">"</span>)</span>
<span id="cb4-4"><a href="#cb4-4" aria-hidden="true" tabindex="-1"></a><span class="fu">println</span>(<span class="st">"The const accel work is </span><span class="sc">$</span>(threecosts[<span class="fl">3</span>])<span class="st">"</span>)</span>
<span id="cb4-5"><a href="#cb4-5" aria-hidden="true" tabindex="-1"></a><span class="fu">bar</span>(threecosts,xticks<span class="op">=</span>((<span class="fl">1</span>,<span class="fl">2</span>,<span class="fl">3</span>),(<span class="st">"Energy-Time"</span>, <span class="st">"Steady min-COT"</span>, <span class="st">"Steady accel"</span>)),legend<span class="op">=</span><span class="cn">false</span>,ylabel<span class="op">=</span><span class="st">"Total work"</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</details>
<div class="cell-output cell-output-stdout">
<pre><code>The energy-time work is 0.21077394712113307
The min-COT work is 0.23455721768541665
The const accel work is 0.2752584233181397</code></pre>
</div>
<div class="cell-output cell-output-display" data-execution_count="16">
<p><img src="shortwalks_files/figure-html/cell-5-output-2.svg" class="img-fluid"></p>
</div>
</div>
<p>Minimization of cost of transport is not energetically optimal, in part because it requires a costly fast speed-up to reach the min-COT speed. It can be less costly to vary speed dynamically. Steady acceleration is also costly, due to expense of accelerating at high speeds, which requires considerable power.</p>
</section>
<section id="shorter-and-longer-step-lengths-do-not-affect-waveform-shapes" class="level2">
<h2 class="anchored" data-anchor-id="shorter-and-longer-step-lengths-do-not-affect-waveform-shapes">Shorter and longer step lengths do not affect waveform shapes</h2>
<p>Longer steps are more costly because of collisions, but doesn’t change peak speed much. For fixed number of steps, longer steps travel a greater total distance (in greater time) and reach a slightly higher speed. For a fixed distance, longer steps also obviously require fewer steps. The following plot shows fixed step lengths slightly shorter or longer than nominal.</p>
<p>Humans take longer steps at faster steady speeds. Applying the approximate preferred relationship here (step length increasing with <span class="math inline">\(v^0.42\)</span>) yields similar speed profiles to fixed step lengths. The model here modulates step length, but does not include the swing cost for doing so. That cost is thought to be relatively higher at fast speeds <span class="citation" data-cites="kuo2001SimpleModelBipedala">(<a href="#ref-kuo2001SimpleModelBipedala" role="doc-biblioref">Kuo 2001</a>)</span>.</p>
<div class="cell" data-execution_count="5">
<details>
<summary>Code</summary>
<div class="sourceCode cell-code" id="cb6"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a>wstar4 <span class="op">=</span> <span class="fu">findgait</span>(<span class="fu">WalkRW2l</span>(α<span class="op">=</span><span class="fl">0.35</span>,safety<span class="op">=</span><span class="cn">true</span>), target<span class="op">=:</span>speed<span class="op">=&gt;</span><span class="fl">0.3</span>, varying<span class="op">=:</span>P)</span>
<span id="cb6-2"><a href="#cb6-2" aria-hidden="true" tabindex="-1"></a>wstar43 <span class="op">=</span> <span class="fu">findgait</span>(<span class="fu">WalkRW2l</span>(α<span class="op">=</span><span class="fl">0.3</span>,safety<span class="op">=</span><span class="cn">true</span>), target<span class="op">=:</span>speed<span class="op">=&gt;</span><span class="fl">0.3</span>, varying<span class="op">=:</span>P) <span class="co"># shorter steps</span></span>
<span id="cb6-3"><a href="#cb6-3" aria-hidden="true" tabindex="-1"></a>wstar44 <span class="op">=</span> <span class="fu">findgait</span>(<span class="fu">WalkRW2l</span>(α<span class="op">=</span><span class="fl">0.4</span>,safety<span class="op">=</span><span class="cn">true</span>), target<span class="op">=:</span>speed<span class="op">=&gt;</span><span class="fl">0.3</span>, varying<span class="op">=:</span>P) <span class="co"># longer steps</span></span>
<span id="cb6-4"><a href="#cb6-4" aria-hidden="true" tabindex="-1"></a>wsteplens <span class="op">=</span> [wstar43, wstar4, wstar44]</span>
<span id="cb6-5"><a href="#cb6-5" aria-hidden="true" tabindex="-1"></a>ctime <span class="op">=</span> <span class="fl">0.015</span> <span class="co"># cost of time, to encourage hurrying</span></span>
<span id="cb6-6"><a href="#cb6-6" aria-hidden="true" tabindex="-1"></a>tchange <span class="op">=</span> <span class="fl">1.75</span></span>
<span id="cb6-7"><a href="#cb6-7" aria-hidden="true" tabindex="-1"></a>p <span class="op">=</span> <span class="fu">plot</span>()</span>
<span id="cb6-8"><a href="#cb6-8" aria-hidden="true" tabindex="-1"></a>walksteps <span class="op">=</span> [<span class="fl">1</span>, <span class="fl">2</span>, <span class="fl">3</span>, <span class="fl">4</span>, <span class="fl">5</span>, <span class="fl">6</span>, <span class="fl">7</span>, <span class="fl">10</span>, <span class="fl">15</span>, <span class="fl">20</span>] <span class="co"># take walks of this # of steps</span></span>
<span id="cb6-9"><a href="#cb6-9" aria-hidden="true" tabindex="-1"></a>results43 <span class="op">=</span> <span class="fu">Array</span><span class="dt">{MultiStepResults,1}</span>(<span class="cn">undef</span>,<span class="fl">0</span>) <span class="co"># store each optimization result here</span></span>
<span id="cb6-10"><a href="#cb6-10" aria-hidden="true" tabindex="-1"></a>results <span class="op">=</span> <span class="fu">Array</span><span class="dt">{MultiStepResults,1}</span>(<span class="cn">undef</span>,<span class="fl">0</span>) <span class="co"># store each optimization result here</span></span>
<span id="cb6-11"><a href="#cb6-11" aria-hidden="true" tabindex="-1"></a>results44 <span class="op">=</span> <span class="fu">Array</span><span class="dt">{MultiStepResults,1}</span>(<span class="cn">undef</span>,<span class="fl">0</span>) <span class="co"># store each optimization result here</span></span>
<span id="cb6-12"><a href="#cb6-12" aria-hidden="true" tabindex="-1"></a>peakspds <span class="op">=</span> <span class="fu">zeros</span>(<span class="fu">length</span>(walksteps))</span>
<span id="cb6-13"><a href="#cb6-13" aria-hidden="true" tabindex="-1"></a>peakspeeds43 <span class="op">=</span> <span class="fu">zeros</span>(<span class="fu">length</span>(walksteps))</span>
<span id="cb6-14"><a href="#cb6-14" aria-hidden="true" tabindex="-1"></a>peakspeeds44 <span class="op">=</span> <span class="fu">zeros</span>(<span class="fu">length</span>(walksteps))</span>
<span id="cb6-15"><a href="#cb6-15" aria-hidden="true" tabindex="-1"></a>durations <span class="op">=</span> <span class="fu">zeros</span>(<span class="fu">length</span>(walksteps))</span>
<span id="cb6-16"><a href="#cb6-16" aria-hidden="true" tabindex="-1"></a>durations43 <span class="op">=</span> <span class="fu">zeros</span>(<span class="fu">length</span>(walksteps))</span>
<span id="cb6-17"><a href="#cb6-17" aria-hidden="true" tabindex="-1"></a>durations44 <span class="op">=</span> <span class="fu">zeros</span>(<span class="fu">length</span>(walksteps))</span>
<span id="cb6-18"><a href="#cb6-18" aria-hidden="true" tabindex="-1"></a><span class="cf">for</span> (i,nsteps) <span class="kw">in</span> <span class="fu">enumerate</span>(walksteps)</span>
<span id="cb6-19"><a href="#cb6-19" aria-hidden="true" tabindex="-1"></a>    result <span class="op">=</span> <span class="fu">optwalktime</span>(wsteplens[<span class="fl">1</span>], nsteps, ctime<span class="op">=</span>ctime) <span class="co"># optimize with a cost of time</span></span>
<span id="cb6-20"><a href="#cb6-20" aria-hidden="true" tabindex="-1"></a>    <span class="fu">plotvees!</span>(result, tchange<span class="op">=</span>tchange, usespline<span class="op">=</span><span class="cn">false</span>, color<span class="op">=</span>i, speedtype<span class="op">=:</span>shortwalks, rampuporder<span class="op">=</span><span class="fl">1</span>, markersize<span class="op">=</span><span class="fl">2</span>) <span class="co"># plot instantaneous speed vs. time</span></span>
<span id="cb6-21"><a href="#cb6-21" aria-hidden="true" tabindex="-1"></a>    <span class="fu">push!</span>(results43, result) <span class="co"># add this optimization to results array</span></span>
<span id="cb6-22"><a href="#cb6-22" aria-hidden="true" tabindex="-1"></a>    peakspeeds43[i] <span class="op">=</span> <span class="fu">maximum</span>(<span class="fu">stepspeeds</span>(result.steps)[<span class="fl">2</span>])</span>
<span id="cb6-23"><a href="#cb6-23" aria-hidden="true" tabindex="-1"></a>    durations43[i] <span class="op">=</span> result.totaltime</span>
<span id="cb6-24"><a href="#cb6-24" aria-hidden="true" tabindex="-1"></a>    result <span class="op">=</span> <span class="fu">optwalktime</span>(wsteplens[<span class="fl">2</span>], nsteps, ctime<span class="op">=</span>ctime) <span class="co"># optimize with a cost of time</span></span>
<span id="cb6-25"><a href="#cb6-25" aria-hidden="true" tabindex="-1"></a>    <span class="fu">plotvees!</span>(result, tchange<span class="op">=</span>tchange, usespline<span class="op">=</span><span class="cn">false</span>, color<span class="op">=</span>i, speedtype<span class="op">=:</span>shortwalks, rampuporder<span class="op">=</span><span class="fl">1</span>, markersize<span class="op">=</span><span class="fl">2</span>) <span class="co"># plot instantaneous speed vs. time</span></span>
<span id="cb6-26"><a href="#cb6-26" aria-hidden="true" tabindex="-1"></a>    <span class="fu">push!</span>(results, result) <span class="co"># add this optimization to results array</span></span>
<span id="cb6-27"><a href="#cb6-27" aria-hidden="true" tabindex="-1"></a>    peakspds[i] <span class="op">=</span> <span class="fu">maximum</span>(<span class="fu">stepspeeds</span>(result.steps)[<span class="fl">2</span>])</span>
<span id="cb6-28"><a href="#cb6-28" aria-hidden="true" tabindex="-1"></a>    durations[i] <span class="op">=</span> result.totaltime</span>
<span id="cb6-29"><a href="#cb6-29" aria-hidden="true" tabindex="-1"></a>    result <span class="op">=</span> <span class="fu">optwalktime</span>(wsteplens[<span class="fl">3</span>], nsteps, ctime<span class="op">=</span>ctime)<span class="co"># # optimize with a cost of time</span></span>
<span id="cb6-30"><a href="#cb6-30" aria-hidden="true" tabindex="-1"></a>    <span class="fu">plotvees!</span>(result, tchange<span class="op">=</span>tchange, usespline<span class="op">=</span><span class="cn">false</span>, color<span class="op">=</span>i, speedtype<span class="op">=:</span>shortwalks, rampuporder<span class="op">=</span><span class="fl">1</span>, markersize<span class="op">=</span><span class="fl">2</span>) <span class="co"># plot instantaneous speed vs. time</span></span>
<span id="cb6-31"><a href="#cb6-31" aria-hidden="true" tabindex="-1"></a>    <span class="fu">push!</span>(results44, result) <span class="co"># add this optimization to results array</span></span>
<span id="cb6-32"><a href="#cb6-32" aria-hidden="true" tabindex="-1"></a>    peakspeeds44[i] <span class="op">=</span> <span class="fu">maximum</span>(<span class="fu">stepspeeds</span>(result.steps)[<span class="fl">2</span>])</span>
<span id="cb6-33"><a href="#cb6-33" aria-hidden="true" tabindex="-1"></a>    durations44[i] <span class="op">=</span> result.totaltime</span>
<span id="cb6-34"><a href="#cb6-34" aria-hidden="true" tabindex="-1"></a><span class="cf">end</span> <span class="co"># longer steps took longer and resulted in almost same peak speed but of course traveled farther</span></span>
<span id="cb6-35"><a href="#cb6-35" aria-hidden="true" tabindex="-1"></a>distances43 <span class="op">=</span> [<span class="fu">sum</span>(result.steps.steplength) for result <span class="kw">in</span> results43]</span>
<span id="cb6-36"><a href="#cb6-36" aria-hidden="true" tabindex="-1"></a>distances <span class="op">=</span> [<span class="fu">sum</span>(result.steps.steplength) for result <span class="kw">in</span> results]</span>
<span id="cb6-37"><a href="#cb6-37" aria-hidden="true" tabindex="-1"></a>distances44 <span class="op">=</span> [<span class="fu">sum</span>(result.steps.steplength) for result <span class="kw">in</span> results44]</span>
<span id="cb6-38"><a href="#cb6-38" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb6-39"><a href="#cb6-39" aria-hidden="true" tabindex="-1"></a><span class="co"># now applying steps increasing with v^0.42 using WalkRW2lvs (linearized, varying step length)</span></span>
<span id="cb6-40"><a href="#cb6-40" aria-hidden="true" tabindex="-1"></a>wstar4vs <span class="op">=</span> <span class="fu">findgait</span>(<span class="fu">WalkRW2lvs</span>(α<span class="op">=</span><span class="fl">0.35</span>,safety<span class="op">=</span><span class="cn">true</span>), target<span class="op">=:</span>speed<span class="op">=&gt;</span><span class="fl">0.3</span>, varying<span class="op">=:</span>P)</span>
<span id="cb6-41"><a href="#cb6-41" aria-hidden="true" tabindex="-1"></a>ctime <span class="op">=</span> <span class="fl">0.05</span> <span class="co"># cost of time, to encourage hurrying</span></span>
<span id="cb6-42"><a href="#cb6-42" aria-hidden="true" tabindex="-1"></a>tchange <span class="op">=</span> <span class="fl">1.75</span></span>
<span id="cb6-43"><a href="#cb6-43" aria-hidden="true" tabindex="-1"></a><span class="co">#pv = plot()</span></span>
<span id="cb6-44"><a href="#cb6-44" aria-hidden="true" tabindex="-1"></a>walksteps <span class="op">=</span> [<span class="fl">1</span>, <span class="fl">2</span>, <span class="fl">3</span>, <span class="fl">4</span>, <span class="fl">5</span>, <span class="fl">6</span>, <span class="fl">7</span>, <span class="fl">10</span>, <span class="fl">15</span>, <span class="fl">20</span>] <span class="co"># take walks of this # of steps</span></span>
<span id="cb6-45"><a href="#cb6-45" aria-hidden="true" tabindex="-1"></a>resultvss <span class="op">=</span> <span class="fu">Array</span><span class="dt">{MultiStepResults,1}</span>(<span class="cn">undef</span>,<span class="fl">0</span>) <span class="co"># store each optimization result here</span></span>
<span id="cb6-46"><a href="#cb6-46" aria-hidden="true" tabindex="-1"></a>tees <span class="op">=</span> <span class="fu">zeros</span>(<span class="fu">length</span>(walksteps),<span class="fl">3</span>)</span>
<span id="cb6-47"><a href="#cb6-47" aria-hidden="true" tabindex="-1"></a>peakspeedvss <span class="op">=</span> <span class="fu">zeros</span>(<span class="fu">length</span>(walksteps))</span>
<span id="cb6-48"><a href="#cb6-48" aria-hidden="true" tabindex="-1"></a>durationvss <span class="op">=</span> <span class="fu">zeros</span>(<span class="fu">length</span>(walksteps))</span>
<span id="cb6-49"><a href="#cb6-49" aria-hidden="true" tabindex="-1"></a><span class="cf">for</span> (i,nsteps) <span class="kw">in</span> <span class="fu">enumerate</span>(walksteps)</span>
<span id="cb6-50"><a href="#cb6-50" aria-hidden="true" tabindex="-1"></a>    result <span class="op">=</span> <span class="fu">optwalktime</span>(wstar4vs, nsteps, ctime<span class="op">=</span>ctime) <span class="co"># optimize with a cost of time</span></span>
<span id="cb6-51"><a href="#cb6-51" aria-hidden="true" tabindex="-1"></a>    <span class="fu">plotvees!</span>(result, tchange<span class="op">=</span>tchange, usespline<span class="op">=</span><span class="cn">false</span>, speedtype<span class="op">=:</span>shortwalks, color<span class="op">=</span>i, rampuporder<span class="op">=</span><span class="fl">1</span>, markersize<span class="op">=</span><span class="fl">2</span>, linestyle<span class="op">=:</span>dot) <span class="co"># plot instantaneous speed vs. time</span></span>
<span id="cb6-52"><a href="#cb6-52" aria-hidden="true" tabindex="-1"></a>    <span class="fu">push!</span>(resultvss, result)</span>
<span id="cb6-53"><a href="#cb6-53" aria-hidden="true" tabindex="-1"></a>    peakspeedvss[i] <span class="op">=</span> <span class="fu">maximum</span>(<span class="fu">stepspeeds</span>(result.steps)[<span class="fl">2</span>])</span>
<span id="cb6-54"><a href="#cb6-54" aria-hidden="true" tabindex="-1"></a>    durationvss[i] <span class="op">=</span> result.totaltime</span>
<span id="cb6-55"><a href="#cb6-55" aria-hidden="true" tabindex="-1"></a>     <span class="co"># add this optimization to results array</span></span>
<span id="cb6-56"><a href="#cb6-56" aria-hidden="true" tabindex="-1"></a><span class="cf">end</span></span>
<span id="cb6-57"><a href="#cb6-57" aria-hidden="true" tabindex="-1"></a>distancevss <span class="op">=</span> [<span class="fu">sum</span>(result.steps.steplength) for result <span class="kw">in</span> resultvss] </span>
<span id="cb6-58"><a href="#cb6-58" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb6-59"><a href="#cb6-59" aria-hidden="true" tabindex="-1"></a>Plots.<span class="fu">display</span>(p) <span class="co"># instantaneous speed vs. distance profiles</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</details>
<div class="cell-output cell-output-display">
<p><img src="shortwalks_files/figure-html/cell-6-output-1.svg" class="img-fluid"></p>
</div>
</div>
</section>
<section id="the-valuation-of-time-affects-peak-speed-but-preserves-self-similarity-of-speed-profiles" class="level2">
<h2 class="anchored" data-anchor-id="the-valuation-of-time-affects-peak-speed-but-preserves-self-similarity-of-speed-profiles">The valuation of time affects peak speed, but preserves self-similarity of speed profiles</h2>
<p>Here we vary the valuation of time <span class="math inline">\(c_T\)</span> by an order of magnitude, and find that it causes peak speeds to approximately double. The main plot below shows variations in <span class="math inline">\(c_T\)</span> and in step length all scaled to resemble each other and superimposed. The scaling is used to demonstrate self-similarity of speed profiles regardless of step length and <span class="math inline">\(c_T\)</span>. The insets show variation in step length in unscaled form (horizontal insets, also shown above), and variation in <span class="math inline">\(c_T\)</span> in unscaled form (vertical insets).</p>
<p>Walks are shown for between 1 and 20 steps, for three fixed step lengths (plus varying step length according to human preference), for six different valuations of time (<span class="math inline">\(c_T\)</span> ranging 0.006 to 0.06). All units are dimensionless, using body mass <span class="math inline">\(M\)</span>, leg length <span class="math inline">\(L\)</span>, and gravitational acceleration <span class="math inline">\(g\)</span> as base units. For a person of typical leg length <span class="math inline">\(L = 1\,\textrm{m}\)</span>, the nominal speed is equivalent to 1.25 m/s.</p>
<div class="cell" data-execution_count="6">
<details>
<summary>Code</summary>
<div class="sourceCode cell-code" id="cb7"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a>wstar4 <span class="op">=</span> <span class="fu">findgait</span>(<span class="fu">WalkRW2l</span>(α<span class="op">=</span><span class="fl">0.35</span>), target<span class="op">=:</span>speed<span class="op">=&gt;</span><span class="fl">0.3</span>, varying<span class="op">=:</span>P)</span>
<span id="cb7-2"><a href="#cb7-2" aria-hidden="true" tabindex="-1"></a>ctimes <span class="op">=</span> (<span class="fl">0.006</span>, <span class="fl">0.015</span>, <span class="fl">0.0276</span>, <span class="fl">0.0384</span>, <span class="fl">0.0492</span>, <span class="fl">0.06</span>) <span class="co"># valuation of time over a large range</span></span>
<span id="cb7-3"><a href="#cb7-3" aria-hidden="true" tabindex="-1"></a>tchange <span class="op">=</span> <span class="fl">1.75</span></span>
<span id="cb7-4"><a href="#cb7-4" aria-hidden="true" tabindex="-1"></a>walksteps <span class="op">=</span> [<span class="fl">1</span>, <span class="fl">2</span>, <span class="fl">3</span>, <span class="fl">4</span>, <span class="fl">5</span>, <span class="fl">6</span>, <span class="fl">7</span>, <span class="fl">10</span>, <span class="fl">15</span>, <span class="fl">20</span>] <span class="co"># take walks of this # of steps</span></span>
<span id="cb7-5"><a href="#cb7-5" aria-hidden="true" tabindex="-1"></a>peaks <span class="op">=</span> <span class="fu">zeros</span>(<span class="fu">length</span>(walksteps),<span class="fu">length</span>(ctimes))</span>
<span id="cb7-6"><a href="#cb7-6" aria-hidden="true" tabindex="-1"></a>durations <span class="op">=</span> <span class="fu">similar</span>(peaks)</span>
<span id="cb7-7"><a href="#cb7-7" aria-hidden="true" tabindex="-1"></a>results <span class="op">=</span> <span class="fu">Array</span><span class="dt">{MultiStepResults,2}</span>(<span class="cn">undef</span>,(<span class="fu">length</span>(walksteps),<span class="fu">length</span>(ctimes))) <span class="co"># store each optimization result here</span></span>
<span id="cb7-8"><a href="#cb7-8" aria-hidden="true" tabindex="-1"></a><span class="cf">for</span> (j,ctime) <span class="kw">in</span> <span class="fu">enumerate</span>(ctimes)</span>
<span id="cb7-9"><a href="#cb7-9" aria-hidden="true" tabindex="-1"></a>    <span class="cf">for</span> (i,nsteps) <span class="kw">in</span> <span class="fu">enumerate</span>(walksteps)</span>
<span id="cb7-10"><a href="#cb7-10" aria-hidden="true" tabindex="-1"></a>        result <span class="op">=</span> <span class="fu">optwalktime</span>(wstar4, nsteps, ctime<span class="op">=</span>ctime) <span class="co"># optimize with a cost of time</span></span>
<span id="cb7-11"><a href="#cb7-11" aria-hidden="true" tabindex="-1"></a>        peaks[i,j] <span class="op">=</span> <span class="fu">maximum</span>(<span class="fu">stepspeeds</span>(result.steps)[<span class="fl">2</span>])</span>
<span id="cb7-12"><a href="#cb7-12" aria-hidden="true" tabindex="-1"></a>        durations[i,j] <span class="op">=</span> result.totaltime</span>
<span id="cb7-13"><a href="#cb7-13" aria-hidden="true" tabindex="-1"></a>        results[i,j] <span class="op">=</span> result</span>
<span id="cb7-14"><a href="#cb7-14" aria-hidden="true" tabindex="-1"></a>    <span class="cf">end</span></span>
<span id="cb7-15"><a href="#cb7-15" aria-hidden="true" tabindex="-1"></a><span class="cf">end</span></span>
<span id="cb7-16"><a href="#cb7-16" aria-hidden="true" tabindex="-1"></a>tbase <span class="op">=</span> durations[<span class="kw">end</span>,<span class="fl">2</span>]</span>
<span id="cb7-17"><a href="#cb7-17" aria-hidden="true" tabindex="-1"></a>vbase <span class="op">=</span> peaks[<span class="kw">end</span>,<span class="fl">2</span>]</span>
<span id="cb7-18"><a href="#cb7-18" aria-hidden="true" tabindex="-1"></a>pleft <span class="op">=</span> <span class="fu">plot</span>(; )<span class="co">#@layout [grid(1,3); a{0.86h}])</span></span>
<span id="cb7-19"><a href="#cb7-19" aria-hidden="true" tabindex="-1"></a>pright <span class="op">=</span> <span class="fu">plot</span>(; layout<span class="op">=</span><span class="fu">grid</span>(<span class="fl">6</span>,<span class="fl">1</span>))</span>
<span id="cb7-20"><a href="#cb7-20" aria-hidden="true" tabindex="-1"></a>ptop <span class="op">=</span> <span class="fu">plot</span>(; layout<span class="op">=</span><span class="fu">grid</span>(<span class="fl">1</span>,<span class="fl">3</span>))</span>
<span id="cb7-21"><a href="#cb7-21" aria-hidden="true" tabindex="-1"></a><span class="cf">for</span> (j, ctime) <span class="kw">in</span> <span class="fu">enumerate</span>(ctimes)</span>
<span id="cb7-22"><a href="#cb7-22" aria-hidden="true" tabindex="-1"></a>    <span class="cf">for</span> (i,nsteps) <span class="kw">in</span> <span class="fu">enumerate</span>(walksteps)</span>
<span id="cb7-23"><a href="#cb7-23" aria-hidden="true" tabindex="-1"></a>        result <span class="op">=</span> results[i,j]</span>
<span id="cb7-24"><a href="#cb7-24" aria-hidden="true" tabindex="-1"></a>        <span class="fu">plotvees!</span>(pright,result, tchange<span class="op">=</span>tchange, color<span class="op">=</span>i, usespline<span class="op">=:</span><span class="cn">false</span>, speedtype<span class="op">=:</span>shortwalks,markersize<span class="op">=</span><span class="fl">0</span>, subplot<span class="op">=</span>j,</span>
<span id="cb7-25"><a href="#cb7-25" aria-hidden="true" tabindex="-1"></a>            xticks <span class="op">=</span> [<span class="fl">20</span>,<span class="fl">40</span>], yticks<span class="op">=</span>[<span class="fl">0.2</span>,<span class="fl">0.4</span>,<span class="fl">0.6</span>],xguide<span class="op">=</span><span class="st">""</span>,yguide<span class="op">=</span><span class="st">""</span>,tickfontsize<span class="op">=</span><span class="fl">4</span>,</span>
<span id="cb7-26"><a href="#cb7-26" aria-hidden="true" tabindex="-1"></a>            xlims<span class="op">=</span>(<span class="fl">0</span>,<span class="fu">maximum</span>(durations)<span class="op">+</span><span class="fl">3</span>tchange), ylims<span class="op">=</span>(<span class="fl">0</span>,<span class="fu">maximum</span>(peaks)), linewidth<span class="op">=</span><span class="fl">0.5</span>) <span class="co"># subplot instantaneous speed vs. time</span></span>
<span id="cb7-27"><a href="#cb7-27" aria-hidden="true" tabindex="-1"></a>        <span class="fu">plotvees!</span>(pleft,result, tchange<span class="op">=</span>tchange, color<span class="op">=</span>i, usespline<span class="op">=:</span><span class="cn">false</span>, speedtype<span class="op">=:</span>shortwalks,markersize<span class="op">=</span><span class="fl">2</span>, tscale <span class="op">=</span> tbase<span class="op">/</span>(durations[<span class="kw">end</span>,j]), </span>
<span id="cb7-28"><a href="#cb7-28" aria-hidden="true" tabindex="-1"></a>            vscale <span class="op">=</span> vbase<span class="op">/</span>peaks[<span class="kw">end</span>,j],subplot<span class="op">=</span><span class="fl">1</span>) <span class="co"># main scaled speed vs time</span></span>
<span id="cb7-29"><a href="#cb7-29" aria-hidden="true" tabindex="-1"></a>    <span class="cf">end</span></span>
<span id="cb7-30"><a href="#cb7-30" aria-hidden="true" tabindex="-1"></a><span class="cf">end</span></span>
<span id="cb7-31"><a href="#cb7-31" aria-hidden="true" tabindex="-1"></a><span class="cf">for</span> (i,result) <span class="kw">in</span> <span class="fu">enumerate</span>(resultvss) <span class="co"># add in the variable step length results computed above in resultvss (dash-dot lines)</span></span>
<span id="cb7-32"><a href="#cb7-32" aria-hidden="true" tabindex="-1"></a>    <span class="fu">plotvees!</span>(pleft,result, tchange<span class="op">=</span>tchange, usespline<span class="op">=</span><span class="cn">false</span>, speedtype<span class="op">=:</span>shortwalks, color<span class="op">=</span>i, markersize<span class="op">=</span><span class="fl">2</span>, linestyle<span class="op">=:</span>dashdot,subplot<span class="op">=</span><span class="fl">1</span>,</span>
<span id="cb7-33"><a href="#cb7-33" aria-hidden="true" tabindex="-1"></a>    tscale <span class="op">=</span> tbase<span class="op">/</span>(durationvss[<span class="kw">end</span>]),vscale <span class="op">=</span> vbase<span class="op">/</span>peakspeedvss[<span class="kw">end</span>]) <span class="co"># plot instantaneous speed vs. time</span></span>
<span id="cb7-34"><a href="#cb7-34" aria-hidden="true" tabindex="-1"></a>    <span class="fu">plotvees!</span>(ptop,result, tchange<span class="op">=</span>tchange, color<span class="op">=</span>i, usespline<span class="op">=:</span><span class="cn">false</span>, speedtype<span class="op">=:</span>shortwalks,markersize<span class="op">=</span><span class="fl">0</span>, </span>
<span id="cb7-35"><a href="#cb7-35" aria-hidden="true" tabindex="-1"></a>        xticks <span class="op">=</span> [<span class="fl">20</span>,<span class="fl">40</span>], yticks<span class="op">=</span>[<span class="fl">0.2</span>,<span class="fl">0.4</span>,<span class="fl">0.6</span>],subplot<span class="op">=</span><span class="fl">2</span>,xguide<span class="op">=</span><span class="st">""</span>,yguide<span class="op">=</span><span class="st">""</span>,tickfontsize<span class="op">=</span><span class="fl">4</span>,</span>
<span id="cb7-36"><a href="#cb7-36" aria-hidden="true" tabindex="-1"></a>        xlims<span class="op">=</span>(<span class="fl">0</span>,<span class="fu">maximum</span>(durations)<span class="op">+</span><span class="fl">3</span>tchange), ylims<span class="op">=</span>(<span class="fl">0</span>,<span class="fu">maximum</span>(peaks)), linewidth<span class="op">=</span><span class="fl">0.5</span>)</span>
<span id="cb7-37"><a href="#cb7-37" aria-hidden="true" tabindex="-1"></a><span class="cf">end</span></span>
<span id="cb7-38"><a href="#cb7-38" aria-hidden="true" tabindex="-1"></a><span class="cf">for</span> (i,result) <span class="kw">in</span> <span class="fu">enumerate</span>(results43) <span class="co"># add in shorter steps (dashed lines)</span></span>
<span id="cb7-39"><a href="#cb7-39" aria-hidden="true" tabindex="-1"></a>    <span class="fu">plotvees!</span>(pleft,result, tchange<span class="op">=</span>tchange, color<span class="op">=</span>i, usespline<span class="op">=:</span><span class="cn">false</span>, speedtype<span class="op">=:</span>shortwalks,markersize<span class="op">=</span><span class="fl">2</span>, tscale <span class="op">=</span> tbase<span class="op">/</span>(durations43[<span class="kw">end</span>]), </span>
<span id="cb7-40"><a href="#cb7-40" aria-hidden="true" tabindex="-1"></a>        vscale <span class="op">=</span> vbase<span class="op">/</span>peakspeeds43[<span class="kw">end</span>],subplot<span class="op">=</span><span class="fl">1</span>, linestyle<span class="op">=:</span>dash)</span>
<span id="cb7-41"><a href="#cb7-41" aria-hidden="true" tabindex="-1"></a>    <span class="fu">plotvees!</span>(ptop,result, tchange<span class="op">=</span>tchange, color<span class="op">=</span>i, usespline<span class="op">=:</span><span class="cn">false</span>, speedtype<span class="op">=:</span>shortwalks,markersize<span class="op">=</span><span class="fl">0</span>, </span>
<span id="cb7-42"><a href="#cb7-42" aria-hidden="true" tabindex="-1"></a>        xticks <span class="op">=</span> [<span class="fl">20</span>,<span class="fl">40</span>], yticks<span class="op">=</span>[<span class="fl">0.2</span>,<span class="fl">0.4</span>,<span class="fl">0.6</span>],subplot<span class="op">=</span><span class="fl">1</span>,xguide<span class="op">=</span><span class="st">""</span>,yguide<span class="op">=</span><span class="st">""</span>,tickfontsize<span class="op">=</span><span class="fl">4</span>,</span>
<span id="cb7-43"><a href="#cb7-43" aria-hidden="true" tabindex="-1"></a>        xlims<span class="op">=</span>(<span class="fl">0</span>,<span class="fu">maximum</span>(durations)<span class="op">+</span><span class="fl">3</span>tchange), ylims<span class="op">=</span>(<span class="fl">0</span>,<span class="fu">maximum</span>(peaks)), linewidth<span class="op">=</span><span class="fl">0.5</span>)</span>
<span id="cb7-44"><a href="#cb7-44" aria-hidden="true" tabindex="-1"></a><span class="cf">end</span></span>
<span id="cb7-45"><a href="#cb7-45" aria-hidden="true" tabindex="-1"></a><span class="cf">for</span> (i,result) <span class="kw">in</span> <span class="fu">enumerate</span>(results44) <span class="co"># add in longer steps (dotted lines)</span></span>
<span id="cb7-46"><a href="#cb7-46" aria-hidden="true" tabindex="-1"></a>    <span class="fu">plotvees!</span>(pleft,result, tchange<span class="op">=</span>tchange, color<span class="op">=</span>i, usespline<span class="op">=:</span><span class="cn">false</span>, speedtype<span class="op">=:</span>shortwalks,markersize<span class="op">=</span><span class="fl">2</span>, tscale <span class="op">=</span> tbase<span class="op">/</span>(durations44[<span class="kw">end</span>]), </span>
<span id="cb7-47"><a href="#cb7-47" aria-hidden="true" tabindex="-1"></a>        vscale <span class="op">=</span> vbase<span class="op">/</span>peakspeeds44[<span class="kw">end</span>],subplot<span class="op">=</span><span class="fl">1</span>, linestyle<span class="op">=:</span>dot)</span>
<span id="cb7-48"><a href="#cb7-48" aria-hidden="true" tabindex="-1"></a>    <span class="fu">plotvees!</span>(ptop,result, tchange<span class="op">=</span>tchange, color<span class="op">=</span>i, usespline<span class="op">=:</span><span class="cn">false</span>, speedtype<span class="op">=:</span>shortwalks,markersize<span class="op">=</span><span class="fl">0</span>,  </span>
<span id="cb7-49"><a href="#cb7-49" aria-hidden="true" tabindex="-1"></a>        xticks <span class="op">=</span> [<span class="fl">20</span>,<span class="fl">40</span>], yticks<span class="op">=</span>[<span class="fl">0.2</span>,<span class="fl">0.4</span>,<span class="fl">0.6</span>],subplot<span class="op">=</span><span class="fl">3</span>, xguide<span class="op">=</span><span class="st">""</span>,yguide<span class="op">=</span><span class="st">""</span>,tickfontsize<span class="op">=</span><span class="fl">4</span>,</span>
<span id="cb7-50"><a href="#cb7-50" aria-hidden="true" tabindex="-1"></a>        xlims<span class="op">=</span>(<span class="fl">0</span>,<span class="fu">maximum</span>(durations)<span class="op">+</span><span class="fl">3</span>tchange), ylims<span class="op">=</span>(<span class="fl">0</span>,<span class="fu">maximum</span>(peaks)), linewidth<span class="op">=</span><span class="fl">0.5</span>)</span>
<span id="cb7-51"><a href="#cb7-51" aria-hidden="true" tabindex="-1"></a><span class="cf">end</span></span>
<span id="cb7-52"><a href="#cb7-52" aria-hidden="true" tabindex="-1"></a><span class="fu">println</span>(<span class="st">"Durations of a factor of "</span>, (durations[<span class="kw">end</span>,<span class="fl">1</span>]<span class="op">+</span><span class="fl">2</span>tchange)<span class="op">/</span>(durations[<span class="kw">end</span>,<span class="kw">end</span>]<span class="op">+</span><span class="fl">2</span>tchange))</span>
<span id="cb7-53"><a href="#cb7-53" aria-hidden="true" tabindex="-1"></a><span class="fu">println</span>(<span class="st">"Peak speeds over a range of "</span>, peaks[<span class="kw">end</span>,<span class="kw">end</span>]<span class="op">/</span>peaks[<span class="kw">end</span>,<span class="fl">1</span>])</span>
<span id="cb7-54"><a href="#cb7-54" aria-hidden="true" tabindex="-1"></a><span class="fu">println</span>(<span class="st">"  about "</span>, peaks[<span class="kw">end</span>,<span class="fl">1</span>]<span class="fu">*sqrt</span>(<span class="fl">9.81</span>),<span class="st">" to "</span>, peaks[<span class="kw">end</span>,<span class="kw">end</span>]<span class="fu">*sqrt</span>(<span class="fl">9.81</span>), <span class="st">"m/s"</span>)</span>
<span id="cb7-55"><a href="#cb7-55" aria-hidden="true" tabindex="-1"></a>peaks[<span class="kw">end</span>,<span class="op">:</span>]<span class="fu">*sqrt</span>(<span class="fl">9.81</span>)</span>
<span id="cb7-56"><a href="#cb7-56" aria-hidden="true" tabindex="-1"></a><span class="fu">plot</span>(ptop, pleft, pright, layout<span class="op">=</span> <span class="pp">@layout</span> [ [a{<span class="fl">0.15</span>h}; b] c{<span class="fl">0.15</span>w}])</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</details>
<div class="cell-output cell-output-stdout">
<pre><code>Durations of a factor of 1.931255229426271
Peak speeds over a range of 2.102877847668059
  about 0.9904474300431949 to 2.0827899599175943m/s</code></pre>
</div>
<div class="cell-output cell-output-display" data-execution_count="18">
<p><img src="shortwalks_files/figure-html/cell-7-output-2.svg" class="img-fluid"></p>
</div>
</div>
</section>
<section id="peak-speeds-and-durations-increase-with-distance" class="level2">
<h2 class="anchored" data-anchor-id="peak-speeds-and-durations-increase-with-distance">Peak speeds and durations increase with distance</h2>
<p>Peak speeds increase toward a saturating value with increasing distance. This relationship is self-similar, in that even with different fixed or varying step lengths, the saturating behavior is similar.</p>
<p>The time duration to walk a distance also increases with distance, approaching a straight asymptote with longer distances. The prediction is more curved for shorter distances.</p>
<p>The following plot shows how peak speeds increase with distance. Greater <span class="math inline">\(c_T\)</span> shifts the peak speed upward. The thin lines show the absolute durations, and the thick lines show the durations after scaling them to demonstrate self-similarity. (The results here also include different step lengths.)</p>
<div class="cell" data-execution_count="7">
<details>
<summary>Code</summary>
<div class="sourceCode cell-code" id="cb9"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a>distances <span class="op">=</span> [<span class="fu">sum</span>(result.steps.steplength) for result <span class="kw">in</span> results]</span>
<span id="cb9-2"><a href="#cb9-2" aria-hidden="true" tabindex="-1"></a>p1<span class="op">=</span><span class="fu">plot</span>(distances, peaks, xlabel<span class="op">=</span><span class="st">"Distance"</span>, ylabel<span class="op">=</span><span class="st">"Peak speed"</span>, xlims<span class="op">=</span>(<span class="fl">0</span>,<span class="fu">maximum</span>(distances)), ylims<span class="op">=</span>(<span class="fl">0</span>,<span class="cn">Inf</span>),legend<span class="op">=</span><span class="cn">false</span>, linewidth<span class="op">=</span><span class="fl">0.2</span>)</span>
<span id="cb9-3"><a href="#cb9-3" aria-hidden="true" tabindex="-1"></a><span class="fu">plot!</span>(p1, distances43, peakspeeds43, linestyle<span class="op">=:</span>dash, linewidth<span class="op">=</span><span class="fl">0.2</span>)</span>
<span id="cb9-4"><a href="#cb9-4" aria-hidden="true" tabindex="-1"></a><span class="fu">plot!</span>(p1, distances44, peakspeeds44, linestyle<span class="op">=:</span>dot, linewidth<span class="op">=</span><span class="fl">0.2</span>)</span>
<span id="cb9-5"><a href="#cb9-5" aria-hidden="true" tabindex="-1"></a><span class="fu">plot!</span>(p1, distancevss, peakspeedvss, linestyle<span class="op">=:</span>dashdot, linewidth<span class="op">=</span><span class="fl">0.2</span>)</span>
<span id="cb9-6"><a href="#cb9-6" aria-hidden="true" tabindex="-1"></a><span class="fu">plot!</span>(p1, distances, (peaks <span class="op">.*</span> <span class="fu">middle</span>(peaks[<span class="kw">end</span>,<span class="op">:</span>]) <span class="op">./</span> <span class="fu">maximum</span>(peaks,dims<span class="op">=</span><span class="fl">1</span>)), linewidth<span class="op">=</span><span class="fl">0.5</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</details>
<div class="cell-output cell-output-display" data-execution_count="19">
<p><img src="shortwalks_files/figure-html/cell-8-output-1.svg" class="img-fluid"></p>
</div>
</div>
<p>The following shows how walking durations increase with distance. Greater <span class="math inline">\(c_T\)</span> results in shorter durations, but the relationship is self-similar. The thin lines show the absolute durations, and the thick lines show the durations after scaling them to demonstrate self-similarity.</p>
<div class="cell" data-execution_count="8">
<details>
<summary>Code</summary>
<div class="sourceCode cell-code" id="cb10"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb10-1"><a href="#cb10-1" aria-hidden="true" tabindex="-1"></a>p1<span class="op">=</span><span class="fu">plot</span>(distances, durations, xlabel<span class="op">=</span><span class="st">"Distance"</span>, ylabel<span class="op">=</span><span class="st">"Duration"</span>,legend<span class="op">=</span><span class="cn">false</span>,linewidth<span class="op">=</span><span class="fl">0.2</span>)</span>
<span id="cb10-2"><a href="#cb10-2" aria-hidden="true" tabindex="-1"></a><span class="fu">plot!</span>(distances, durations <span class="op">.*</span> <span class="fu">middle</span>(durations[<span class="kw">end</span>,<span class="op">:</span>])<span class="op">./</span> <span class="fu">maximum</span>(durations,dims<span class="op">=</span><span class="fl">1</span>), linewidth<span class="op">=</span><span class="fl">0.5</span>,xlabel<span class="op">=</span><span class="st">"Distance"</span>, ylabel<span class="op">=</span><span class="st">"Duration"</span>,legend<span class="op">=</span><span class="cn">false</span>)</span>
<span id="cb10-3"><a href="#cb10-3" aria-hidden="true" tabindex="-1"></a><span class="fu">plot!</span>(distances43, durations43 <span class="op">.*</span> <span class="fu">middle</span>(durations[<span class="kw">end</span>,<span class="op">:</span>])<span class="op">./</span> <span class="fu">maximum</span>(durations43,dims<span class="op">=</span><span class="fl">1</span>), linewidth<span class="op">=</span><span class="fl">0.5</span>,xlabel<span class="op">=</span><span class="st">"Distance"</span>, ylabel<span class="op">=</span><span class="st">"Duration"</span>,legend<span class="op">=</span><span class="cn">false</span>,linestyle<span class="op">=:</span>dash)</span>
<span id="cb10-4"><a href="#cb10-4" aria-hidden="true" tabindex="-1"></a><span class="fu">plot!</span>(distances44, durations44 <span class="op">.*</span> <span class="fu">middle</span>(durations[<span class="kw">end</span>,<span class="op">:</span>])<span class="op">./</span> <span class="fu">maximum</span>(durations44,dims<span class="op">=</span><span class="fl">1</span>), linewidth<span class="op">=</span><span class="fl">0.5</span>,xlabel<span class="op">=</span><span class="st">"Distance"</span>, ylabel<span class="op">=</span><span class="st">"Duration"</span>,legend<span class="op">=</span><span class="cn">false</span>,linestyle<span class="op">=:</span>dash)</span>
<span id="cb10-5"><a href="#cb10-5" aria-hidden="true" tabindex="-1"></a><span class="fu">plot!</span>(distancevss, durationvss <span class="op">.*</span> <span class="fu">middle</span>(durations[<span class="kw">end</span>,<span class="op">:</span>])<span class="op">./</span> <span class="fu">maximum</span>(durationvss,dims<span class="op">=</span><span class="fl">1</span>), linewidth<span class="op">=</span><span class="fl">0.5</span>,xlabel<span class="op">=</span><span class="st">"Distance"</span>, ylabel<span class="op">=</span><span class="st">"Duration"</span>,legend<span class="op">=</span><span class="cn">false</span>,linestyle<span class="op">=:</span>dash)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</details>
<div class="cell-output cell-output-display" data-execution_count="20">
<p><img src="shortwalks_files/figure-html/cell-9-output-1.svg" class="img-fluid"></p>
</div>
</div>
</section>
<section id="valuation-of-time-affects-peak-speed" class="level2">
<h2 class="anchored" data-anchor-id="valuation-of-time-affects-peak-speed">Valuation of time affects peak speed</h2>
<p>The following plot shows peak speed vs valuation of time <span class="math inline">\(c_T\)</span>. The thin lines show the absolute speeds, and the thick lines show the speeds after scaling them to demonstrate self-similarity. Also included here are walks of various distances, where longer walks have a peak speed that is nearly steady, and shorter walks have only brief peaks. Nevertheless, peak speed increases with <span class="math inline">\(c_T\)</span>, with a roughly cube root relationship.</p>
<div class="cell" data-execution_count="9">
<details>
<summary>Code</summary>
<div class="sourceCode cell-code" id="cb11"><pre class="sourceCode julia code-with-copy"><code class="sourceCode julia"><span id="cb11-1"><a href="#cb11-1" aria-hidden="true" tabindex="-1"></a><span class="co">## Vary ct and # steps, with finer increments than before</span></span>
<span id="cb11-2"><a href="#cb11-2" aria-hidden="true" tabindex="-1"></a>morectimes <span class="op">=</span> <span class="fu">range</span>(ctimes[begin], ctimes[<span class="kw">end</span>], length<span class="op">=</span><span class="fl">16</span>)</span>
<span id="cb11-3"><a href="#cb11-3" aria-hidden="true" tabindex="-1"></a>walksteps <span class="op">=</span> [<span class="fl">1</span>,<span class="fl">2</span>,<span class="fl">3</span>,<span class="fl">4</span>,<span class="fl">5</span>,<span class="fl">6</span>, <span class="fl">7</span>, <span class="fl">10</span>, <span class="fl">15</span>, <span class="fl">20</span>] <span class="co"># take walks of this # of steps</span></span>
<span id="cb11-4"><a href="#cb11-4" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb11-5"><a href="#cb11-5" aria-hidden="true" tabindex="-1"></a>cresults <span class="op">=</span> [<span class="fu">optwalktime</span>(wstar4, nsteps, ctime<span class="op">=</span>ctime) for nsteps <span class="kw">in</span> walksteps, ctime <span class="kw">in</span> morectimes]</span>
<span id="cb11-6"><a href="#cb11-6" aria-hidden="true" tabindex="-1"></a>cpeaks <span class="op">=</span> [<span class="fu">maximum</span>(<span class="fu">stepspeeds</span>(r.steps)[<span class="fl">2</span>]) for r <span class="kw">in</span> cresults]</span>
<span id="cb11-7"><a href="#cb11-7" aria-hidden="true" tabindex="-1"></a>cdurations <span class="op">=</span> [r.totaltime for r <span class="kw">in</span> cresults]</span>
<span id="cb11-8"><a href="#cb11-8" aria-hidden="true" tabindex="-1"></a>sec <span class="op">=</span> <span class="fu">sqrt</span>(<span class="fl">1</span><span class="op">/</span><span class="fl">9.81</span>); mps <span class="op">=</span> <span class="fu">sqrt</span>(<span class="fl">9.81</span>)</span>
<span id="cb11-9"><a href="#cb11-9" aria-hidden="true" tabindex="-1"></a>p1<span class="op">=</span><span class="fu">plot</span>(morectimes, mps<span class="op">.*</span>cpeaks<span class="op">'</span>,legend<span class="op">=</span><span class="cn">false</span>,xlabel<span class="op">=</span><span class="st">"c_t"</span>,ylabel<span class="op">=</span><span class="st">"peak speed"</span>,linewidth<span class="op">=</span><span class="fl">0.2</span>)</span>
<span id="cb11-10"><a href="#cb11-10" aria-hidden="true" tabindex="-1"></a><span class="fu">plot!</span>(p1,morectimes, mps<span class="op">.*</span>(cpeaks <span class="op">.*</span> <span class="fu">middle</span>(cpeaks[<span class="op">:</span>,<span class="kw">end</span>])<span class="op">./</span> <span class="fu">maximum</span>(cpeaks,dims<span class="op">=</span><span class="fl">2</span>))<span class="ch">',linewidth=1,legend=false, xlabel="valuation of time c_t",ylabel="peak speed")</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</details>
<div class="cell-output cell-output-display" data-execution_count="21">
<p><img src="shortwalks_files/figure-html/cell-10-output-1.svg" class="img-fluid"></p>
</div>
</div>
</section>
<section id="experimental-data" class="level2">
<h2 class="anchored" data-anchor-id="experimental-data">Experimental data</h2>
<p>The data from accompanying human subjects experiment are available in a <a href="https://github.com/kuo-lab/short_walk_experiment/">separate data and code repository</a>. The code is in Matlab, and the data files are in .mat format, which is compatible with HDF5.</p>
</section>
<section id="julia-code" class="level1">
<h1>Julia code</h1>
<p>This page is viewable as <a href="shortwalks.ipynb">Jupyter notebook</a>, <a href="shortwalks.jl">plain Julia</a> text, or <a href="shortwalks.html">HTML</a>.</p>
<section id="references" class="level2">


</section>
</section>

<div id="quarto-appendix" class="default"><section class="quarto-appendix-contents" role="doc-bibliography"><h2 class="anchored quarto-appendix-heading">References</h2><div id="refs" class="references csl-bib-body hanging-indent" role="doc-bibliography">
<div id="ref-carlisle2022OptimizationEnergyTime" class="csl-entry" role="doc-biblioentry">
Carlisle, R. Elizabeth, and Arthur D. Kuo. 2022. <span>“Optimization of Energy and Time Predicts Dynamic Speeds for Human Walking.”</span> <span>bioRxiv</span>. <a href="https://doi.org/10.1101/2022.07.15.500158">https://doi.org/10.1101/2022.07.15.500158</a>.
</div>
<div id="ref-kuo2001SimpleModelBipedala" class="csl-entry" role="doc-biblioentry">
Kuo, Arthur D. 2001. <span>“<a href="https://www.ncbi.nlm.nih.gov/pubmed/11476370">A Simple Model of Bipedal Walking Predicts the Preferred Speed-Step Length Relationship</a>.”</span> <em>Journal of Biomechanical Engineering</em> 123 (3): 264–69.
</div>
</div></section></div></main>
<!-- /main column -->
<script id="quarto-html-after-body" type="application/javascript">
window.document.addEventListener("DOMContentLoaded", function (event) {
  const toggleBodyColorMode = (bsSheetEl) => {
    const mode = bsSheetEl.getAttribute("data-mode");
    const bodyEl = window.document.querySelector("body");
    if (mode === "dark") {
      bodyEl.classList.add("quarto-dark");
      bodyEl.classList.remove("quarto-light");
    } else {
      bodyEl.classList.add("quarto-light");
      bodyEl.classList.remove("quarto-dark");
    }
  }
  const toggleBodyColorPrimary = () => {
    const bsSheetEl = window.document.querySelector("link#quarto-bootstrap");
    if (bsSheetEl) {
      toggleBodyColorMode(bsSheetEl);
    }
  }
  toggleBodyColorPrimary();  
  const icon = "";
  const anchorJS = new window.AnchorJS();
  anchorJS.options = {
    placement: 'right',
    icon: icon
  };
  anchorJS.add('.anchored');
  const clipboard = new window.ClipboardJS('.code-copy-button', {
    target: function(trigger) {
      return trigger.previousElementSibling;
    }
  });
  clipboard.on('success', function(e) {
    // button target
    const button = e.trigger;
    // don't keep focus
    button.blur();
    // flash "checked"
    button.classList.add('code-copy-button-checked');
    var currentTitle = button.getAttribute("title");
    button.setAttribute("title", "Copied!");
    setTimeout(function() {
      button.setAttribute("title", currentTitle);
      button.classList.remove('code-copy-button-checked');
    }, 1000);
    // clear code selection
    e.clearSelection();
  });
  function tippyHover(el, contentFn) {
    const config = {
      allowHTML: true,
      content: contentFn,
      maxWidth: 500,
      delay: 100,
      arrow: false,
      appendTo: function(el) {
          return el.parentElement;
      },
      interactive: true,
      interactiveBorder: 10,
      theme: 'quarto',
      placement: 'bottom-start'
    };
    window.tippy(el, config); 
  }
  const noterefs = window.document.querySelectorAll('a[role="doc-noteref"]');
  for (var i=0; i<noterefs.length; i++) {
    const ref = noterefs[i];
    tippyHover(ref, function() {
      // use id or data attribute instead here
      let href = ref.getAttribute('data-footnote-href') || ref.getAttribute('href');
      try { href = new URL(href).hash; } catch {}
      const id = href.replace(/^#\/?/, "");
      const note = window.document.getElementById(id);
      return note.innerHTML;
    });
  }
  var bibliorefs = window.document.querySelectorAll('a[role="doc-biblioref"]');
  for (var i=0; i<bibliorefs.length; i++) {
    const ref = bibliorefs[i];
    const cites = ref.parentNode.getAttribute('data-cites').split(' ');
    tippyHover(ref, function() {
      var popup = window.document.createElement('div');
      cites.forEach(function(cite) {
        var citeDiv = window.document.createElement('div');
        citeDiv.classList.add('hanging-indent');
        citeDiv.classList.add('csl-entry');
        var biblioDiv = window.document.getElementById('ref-' + cite);
        if (biblioDiv) {
          citeDiv.innerHTML = biblioDiv.innerHTML;
        }
        popup.appendChild(citeDiv);
      });
      return popup.innerHTML;
    });
  }
});
</script>
</div> <!-- /content -->



</body></html>
back to top