   w_(i+1) + v_i^const2 &lt;= w_i, etc...</span>
<span class="comment">%</span>
<span class="comment">% where variables are v_i, y_i, and w_i.</span>

<span class="comment">% discretization size</span>
M = 50;
<span class="comment">% M = 1000; % takes a few minutes to process constraints</span>

<span class="comment">% problem constants</span>
g1 = 0.42;
g2 = 0.69;
Nmax = 5*10^18;
Nmin = 5*10^16;
Nref = 10^17;
Dn0 = 20.72;
ni0 = 1.4*(10^10);
WB = 10^(-5);
C =  WB^2/((M^2)*(Nref^g1)*Dn0);

<span class="comme