def</span><span class="w"> </span><span class="nf">_optimize_gamma</span><span class="p">(</span><span class="n">resid_sq</span><span class="p">,</span> <span class="n">max_transitions</span><span class="p">):</span>
<span class="w">            </span><span class="sa">r</span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd">            Solves the following optimization problem :</span>

<span class="sd">                minimize       c * x</span>

<span class="sd">            where c = resid_sq ,