7.5 PDE-Constrained Shape Optimization (fully automated)

We want to solve the PDE-constrained shape optimization problem

\[\underset{\Omega\subset \mathsf{D}}{\mbox{min}} \; J(u) := \int_\Omega |u-u_d|^q \; dx, \quad q\ge 2\]

subject to that \((\Omega,u)\) satisfy

\[\int_\Omega \nabla u \cdot \nabla v \; dx = \int_\Omega f v \; dx \; \quad \text{ for all } v \in H_0^1(\Omega),\]

where \(\Omega \subset \mathbb R^2\) for given \(u_d, f \in C^1(\mathbb R^2)\).

Again, we want to compute the shape derivative by differentiation of a suitably defined perturbed Lagrangian using automated differentiation. Here this is accounted for automatically by NGSolve. For details we refer to

  1. Gangl, K. Sturm, M. Neunteufel, J. Schöberl. Fully and Semi-Automated Shape Differentiation in NGSolve, Struct. Multidisc. Optim., 63, pp.1579-1607, 2021.

[1]:
from ngsolve import *
from ngsolve.webgui import Draw
from netgen.geom2d import SplineGeometry
from ngsolve.solvers import *
[2]:
geo = SplineGeometry()
geo.AddCircle(c=(0.5,0.5), r=0.5, bc = 'circle')
mesh = Mesh(geo.GenerateMesh(maxh = 0.08))
Draw(mesh)
[2]:
BaseWebGuiScene
[3]:
#given data of our problem (chosen such that \Omega^* = [0,1]^2 is the optimal shape)
f = CoefficientFunction(2*y*(1-y)+2*x*(1-x))
ud = x*(1-x)*y*(1-y)

grad_f = CoefficientFunction( (f.Diff(x), f.Diff(y) ) )
grad_ud = CoefficientFunction( (ud.Diff(x), ud.Diff(y) ) )
[4]:
fes = H1(mesh, order=2, dirichlet=".*")
gfu = GridFunction(fes)
scene_u = Draw (gfu, mesh, "state")

gfp = GridFunction(fes)
scene_p = Draw (gfp, mesh, "adjoint")

Note that (for linear problems) the operator on the left hand side of the adjoint equation is just the transpose of the state operator.

Automatic Shape Differentiation

The formula for the shape derivative was derived as the partial derivative of the perturbed Lagrangian (brought back to the original domain):

\[d\mathcal J(\Omega; X) = \frac{\partial}{\partial t} \left. \left( \int_\Omega |u - u_d^t|^q \,\mbox{det}(F_t) \mbox{d} x + \int_{\Omega} (F_t^{-\top}\nabla u) \cdot (F_t^{-\top} \nabla p)\, \mbox{det}(F_t) \, dx - \int_{\Omega}f^t p \,\mbox{det}(F_t) \,dx \right) \right \rvert_{t=0}\]

where

  • \(T_t(x)=x+tX(x)=y\)

  • \(F_t = DT_t = I+t DX\)

  • \(u_d^t = u_d \circ T_t\)

  • \(f^t = f \circ T_t\)

The integrand depends on the parameter \(t\) only via \(F_t\) and \(T_t\). We define the Lagrangian in this form, involving a parameter t that has the value 0.

In order to define the perturbed Lagrangian for a given problem, one needs to know transformation rules of differential operators, e.g.,

\[(\nabla u)\circ T_t = (\partial T_t)^{-T} \nabla (u \circ T_t)\]

for \(u \in H^1\).

Since these transformation rules are known by NGSolve for all implemented differential operators, also the step of defining the perturbed Lagrangian can be automated.

[5]:
VEC = H1(mesh, order=2, dim=2)
PHI, X = VEC.TnT()

def EquationFA(u,v):
    return ( grad(u)*grad(v)-f*v)*dx

q=4
def CostAutoFA(u):
    return (u-ud)**q*dx

def CostAuto2(u):
    return CostAutoFA(u)

LagrangianFA = CostAutoFA(gfu) + EquationFA(gfu,gfp)

State equation

Equation can also be used to define the bilinear form. The following defines left and right hand side of the PDE in a "BilinearForm":

[6]:
u, v = fes.TnT()

aAuto = BilinearForm(fes, symmetric=True)
aAuto += EquationFA(u,v)

Now the PDE can be conveniently solved by calling Newton’s method (which terminates after one iteration since the PDE is linear)

[7]:
gfu.vec[:]=0
Newton(aAuto,gfu,freedofs=fes.FreeDofs())
scene_u.Redraw()
Newton iteration  0
err =  0.13042435973102348
Newton iteration  1
err =  1.1032913546772452e-16

Adjoint equation

We set up the adjoint equation

\[\mbox{Find } p \in H_0^1(\Omega): \int_\Omega \nabla w \cdot \nabla p \, \mbox dx = - \partial_u J(u)(w) \quad \text{ for all } w \in H_0^1(\Omega)\]

where \(u\) is the solution to the state equation. For \(J(u) = \int_\Omega |u-u_d|^2 \mbox dx\), we get

\[\partial_u J(u)(w) = 2 \int_\Omega (u-u_d)w \,\mbox dx.\]

However, we can also use the Diff(…) command:

[8]:
p, w = fes.TnT()

fadjoint = LinearForm(fes)
fadjoint += -1*(CostAutoFA(gfu)).Diff(gfu,w)
[9]:
def SolveAdjointEquation():
    rhs = gfp.vec.CreateVector()
    rhs.data = fadjoint.vec - aAuto.mat.T * gfp.vec
    update = gfp.vec.CreateVector()
    update.data = aAuto.mat.Inverse(fes.FreeDofs()).T * rhs
    gfp.vec.data += update
[10]:
fadjoint.Assemble()
SolveAdjointEquation()
scene_p.Redraw()

Automatic Shape Differentiation

Denoting the integrand by \(G^{u,p}\), the shape derivative is given by

\[\begin{split}\begin{array}{rl} d\mathcal J(\Omega; X) =& \left( \left. \frac{\partial G^{u,p}}{\partial t} + \frac{d G^{u,p}}{dy} \cdot \frac{d T_t}{dt}\right)\right\rvert_{t=0} \\ =& \left. \frac{\partial G^{u,p}}{\partial t}\right\rvert_{t=0} + \frac{d G^{u,p}}{dy} \cdot X \end{array}\end{split}\]

The command .DiffShape(…) computes the shape derivative by automatically accounting for the corresponding transformations.

[11]:
dJOmegaAuto = LinearForm(VEC)
dJOmegaAuto += LagrangianFA.DiffShape(X)
[12]:
b = BilinearForm(VEC)
b += InnerProduct(grad(X),grad(PHI))*dx + InnerProduct(X,PHI)*dx

gfX = GridFunction(VEC)
[13]:
def SolveDeformationEquationAuto():
    rhs = gfX.vec.CreateVector()
    rhs.data = dJOmegaAuto.vec - b.mat * gfX.vec
    update = gfX.vec.CreateVector()
    update.data = b.mat.Inverse(VEC.FreeDofs()) * rhs
    gfX.vec.data += update
[14]:
b.Assemble()
dJOmegaAuto.Assemble()
SolveDeformationEquationAuto()
Draw(-gfX, mesh, "-gfX")
[14]:
BaseWebGuiScene
[15]:
# gfset denotes the deformation of the original domain and will be updated during the shape optimization
gfset = GridFunction(VEC)
gfset.Set((0,0))
mesh.SetDeformation(gfset)
sceneSet = Draw(gfset,mesh,"gfset")
SetVisualization (deformation=True)
[16]:
gfset.Set((0,0))
mesh.SetDeformation(gfset)
print('Cost at initial design', Integrate (CostAuto2(gfu), mesh))

scale = 0.5 / Norm(gfX.vec)
gfset.vec.data -= scale * gfX.vec
sceneSet.Redraw()
Cost at initial design 5.152244130814755e-09
[17]:
gfu.vec[:]=0
Newton(aAuto, gfu, fes.FreeDofs())
print('Cost at new design', Integrate (CostAuto2(gfu), mesh))
Newton iteration  0
err =  0.1539571560737845
Newton iteration  1
err =  1.2635277035484454e-16
Cost at new design 9.793297083297818e-10

Thus, the user has to enter the PDE (in its transformed form) only once.

Finally, let us again run the full algorithm:

[18]:
scene_u = Draw(gfu)
[19]:
#reset to and solve for initial configuration
gfset.Set((0,0))
mesh.SetDeformation(gfset)
scene_u.Redraw()
gfu.vec[:]=0
Newton(aAuto, gfu, fes.FreeDofs())

LineSearch = False


iter_max = 600
Jold = Integrate(CostAuto2(gfu), mesh)
converged = False
for k in range(iter_max):
    print('cost at iteration', k, ': ', Jold)
    mesh.SetDeformation(gfset)
    scene_u.Redraw()

    gfu.vec[:]=0
    Newton(aAuto, gfu, fes.FreeDofs(), printing = False)

    fadjoint.Assemble()
    SolveAdjointEquation()

    b.Assemble()
    dJOmegaAuto.Assemble()
    SolveDeformationEquationAuto()

    scale = 0.01 / Norm(gfX.vec)
    gfsetOld = gfset
    gfset.vec.data -= scale * gfX.vec

    Jnew = Integrate(CostAuto2(gfu), mesh)

    if LineSearch:
        while Jnew > Jold and scale > 1e-12:
            # input('a')
            scale = scale / 2

            if scale <= 1e-12:
                converged = True
                break

            gfset.vec.data = gfsetOld.vec - scale * gfX.vec
            mesh.SetDeformation(gfset)

            gfu.vec[:]=0
            Newton(aAuto, gfu, fes.FreeDofs(), printing = False)
            Jnew = Integrate(CostAuto(gfu), mesh)

    if converged==True:
        break
    Jold = Jnew

    Redraw(blocking=True)
Newton iteration  0
err =  0.13042435973102348
Newton iteration  1
err =  1.1032913546772452e-16
cost at iteration 0 :  5.152244130814755e-09
cost at iteration 1 :  4.942040315052278e-09
cost at iteration 2 :  4.585081411492748e-09
cost at iteration 3 :  4.249440980557088e-09
cost at iteration 4 :  3.934230926246944e-09
cost at iteration 5 :  3.6385762619912925e-09
cost at iteration 6 :  3.3616160503340724e-09
cost at iteration 7 :  3.1025043360794835e-09
cost at iteration 8 :  2.8604110705929723e-09
cost at iteration 9 :  2.6345230245966513e-09
cost at iteration 10 :  2.4240446863394626e-09
cost at iteration 11 :  2.2281991414270806e-09
cost at iteration 12 :  2.0462289298150803e-09
cost at iteration 13 :  1.8773968744302318e-09
cost at iteration 14 :  1.7209868744933654e-09
cost at iteration 15 :  1.5763046547393895e-09
cost at iteration 16 :  1.4426784591830562e-09
cost at iteration 17 :  1.3194596746124644e-09
cost at iteration 18 :  1.2060233642634607e-09
cost at iteration 19 :  1.1017686856714432e-09
cost at iteration 20 :  1.006119157883454e-09
cost at iteration 21 :  9.185227311982654e-10
cost at iteration 22 :  8.384515962699072e-10
cost at iteration 23 :  7.654016473209058e-10
cost at iteration 24 :  6.988914845968648e-10
cost at iteration 25 :  6.384608021036904e-10
cost at iteration 26 :  5.836679565498961e-10
cost at iteration 27 :  5.340864528118764e-10
cost at iteration 28 :  4.893000172852372e-10
cost at iteration 29 :  4.488958881947119e-10
cost at iteration 30 :  4.1245600135970885e-10
cost at iteration 31 :  3.7954606800853276e-10
cost at iteration 32 :  3.497035385815598e-10
cost at iteration 33 :  3.224279626838391e-10
cost at iteration 34 :  2.9718256556606e-10
cost at iteration 35 :  2.734241271728054e-10
cost at iteration 36 :  2.5068184304177957e-10
cost at iteration 37 :  2.286790598505091e-10
cost at iteration 38 :  2.0741713926515882e-10
cost at iteration 39 :  1.8711167400729794e-10
cost at iteration 40 :  1.6801624125408654e-10
cost at iteration 41 :  1.502955210288288e-10
cost at iteration 42 :  1.340064930638265e-10
cost at iteration 43 :  1.19130676829076e-10
cost at iteration 44 :  1.0560796580779415e-10
cost at iteration 45 :  9.335887914179761e-11
cost at iteration 46 :  8.229695729942483e-11
cost at iteration 47 :  7.233508979947753e-11
cost at iteration 48 :  6.338852880933332e-11
cost at iteration 49 :  5.53762094979999e-11
cost at iteration 50 :  4.8221248852235816e-11
cost at iteration 51 :  4.185106579754666e-11
cost at iteration 52 :  3.619733722937543e-11
cost at iteration 53 :  3.119588920801157e-11
cost at iteration 54 :  2.678656684957822e-11
cost at iteration 55 :  2.2913100695693302e-11
cost at iteration 56 :  1.952297596730753e-11
cost at iteration 57 :  1.656730628871613e-11
cost at iteration 58 :  1.4000711487116359e-11
cost at iteration 59 :  1.178119825449867e-11
cost at iteration 60 :  9.870042108059449e-12
cost at iteration 61 :  8.231668931388936e-12
cost at iteration 62 :  6.833534355412221e-12
cost at iteration 63 :  5.6459993089751435e-12
cost at iteration 64 :  4.642200293031801e-12
cost at iteration 65 :  3.797913225654571e-12
cost at iteration 66 :  3.091410276890533e-12
cost at iteration 67 :  2.5033094982807547e-12
cost at iteration 68 :  2.016418297374456e-12
cost at iteration 69 :  1.6155712170698355e-12
cost at iteration 70 :  1.2874668507720771e-12
cost at iteration 71 :  1.020499624339473e-12
cost at iteration 72 :  8.046147979342341e-13
cost at iteration 73 :  6.311813221604381e-13
cost at iteration 74 :  4.93956252135218e-13
cost at iteration 75 :  4.0069968796176774e-13
cost at iteration 76 :  3.6532623445353007e-13
cost at iteration 77 :  3.3593359233371227e-13
cost at iteration 78 :  3.0631953000974726e-13
cost at iteration 79 :  2.813141392558361e-13
cost at iteration 80 :  2.5730205363498936e-13
cost at iteration 81 :  2.362812098140028e-13
cost at iteration 82 :  2.1662119785427133e-13
cost at iteration 83 :  1.9907535315039381e-13
cost at iteration 84 :  1.8289671605245518e-13
cost at iteration 85 :  1.6830618822972515e-13
cost at iteration 86 :  1.5495410624076236e-13
cost at iteration 87 :  1.4284167840514353e-13
cost at iteration 88 :  1.3179948435191064e-13
cost at iteration 89 :  1.217465007635225e-13
cost at iteration 90 :  1.1259523680001342e-13
cost at iteration 91 :  1.0424243497871883e-13
cost at iteration 92 :  9.663764815316792e-14
cost at iteration 93 :  8.968086864764175e-14
cost at iteration 94 :  8.33382259691679e-14
cost at iteration 95 :  7.752294900328171e-14
cost at iteration 96 :  7.22084998919889e-14
cost at iteration 97 :  6.732431060963118e-14
cost at iteration 98 :  6.284703955285466e-14
cost at iteration 99 :  5.872210257639473e-14
cost at iteration 100 :  5.49274893967604e-14
cost at iteration 101 :  5.142299341319673e-14
cost at iteration 102 :  4.818706323822081e-14
cost at iteration 103 :  4.5191766532533105e-14
cost at iteration 104 :  4.24155839846094e-14
cost at iteration 105 :  3.9840711958843525e-14
cost at iteration 106 :  3.7445459175591916e-14
cost at iteration 107 :  3.522018518447113e-14
cost at iteration 108 :  3.3142952164439624e-14
cost at iteration 109 :  3.1210587469709204e-14
cost at iteration 110 :  2.940091441080398e-14
cost at iteration 111 :  2.771581952228771e-14
cost at iteration 112 :  2.61329456982612e-14
cost at iteration 113 :  2.465809684917647e-14
cost at iteration 114 :  2.326882024196241e-14
cost at iteration 115 :  2.1973927974535282e-14
cost at iteration 116 :  2.0750963539515396e-14
cost at iteration 117 :  1.961103437513113e-14
cost at iteration 118 :  1.8531764512889715e-14
cost at iteration 119 :  1.7526007672328436e-14
cost at iteration 120 :  1.657153470377385e-14
cost at iteration 121 :  1.568253362246902e-14
cost at iteration 122 :  1.4836963345957273e-14
cost at iteration 123 :  1.4050050486482587e-14
cost at iteration 124 :  1.3299954409550846e-14
cost at iteration 125 :  1.2602744567303449e-14
cost at iteration 126 :  1.1936763657242363e-14
cost at iteration 127 :  1.1318811579019632e-14
cost at iteration 128 :  1.072736939855704e-14
cost at iteration 129 :  1.0179907205394057e-14
cost at iteration 130 :  9.654968186252952e-15
cost at iteration 131 :  9.170601791713069e-15
cost at iteration 132 :  8.705283672875018e-15
cost at iteration 133 :  8.277358316187091e-15
cost at iteration 134 :  7.865086433789656e-15
cost at iteration 135 :  7.486597714807718e-15
cost at iteration 136 :  7.120161201993475e-15
cost at iteration 137 :  6.783380539341893e-15
cost at iteration 138 :  6.4554213613274076e-15
cost at iteration 139 :  6.153307032715954e-15
cost at iteration 140 :  5.857846171605797e-15
cost at iteration 141 :  5.585255421360014e-15
cost at iteration 142 :  5.318087733639911e-15
cost at iteration 143 :  5.0715029721533015e-15
cost at iteration 144 :  4.829601959465964e-15
cost at iteration 145 :  4.60642035050274e-15
cost at iteration 146 :  4.3873779720308446e-15
cost at iteration 147 :  4.185460324563698e-15
cost at iteration 148 :  3.987201654020076e-15
cost at iteration 149 :  3.804668869943904e-15
cost at iteration 150 :  3.625332712987106e-15
cost at iteration 151 :  3.4604830808710208e-15
cost at iteration 152 :  3.298373431603231e-15
cost at iteration 153 :  3.1496484517213518e-15
cost at iteration 154 :  3.003212523388029e-15
cost at iteration 155 :  2.8691805522983385e-15
cost at iteration 156 :  2.7369958749252393e-15
cost at iteration 157 :  2.6163416569510592e-15
cost at iteration 158 :  2.497105756609314e-15
cost at iteration 159 :  2.388621461381891e-15
cost at iteration 160 :  2.281141947864655e-15
cost at iteration 161 :  2.1837183644674698e-15
cost at iteration 162 :  2.0869029976199324e-15
cost at iteration 163 :  1.9995208356621336e-15
cost at iteration 164 :  1.9123679177196125e-15
cost at iteration 165 :  1.834089754534065e-15
cost at iteration 166 :  1.755679522617587e-15
cost at iteration 167 :  1.6856430604041145e-15
cost at iteration 168 :  1.6151306583341845e-15
cost at iteration 169 :  1.5525435351693323e-15
cost at iteration 170 :  1.489153516494799e-15
cost at iteration 171 :  1.4332889384971723e-15
cost at iteration 172 :  1.37631025286734e-15
cost at iteration 173 :  1.326501712394544e-15
cost at iteration 174 :  1.2752815739136015e-15
cost at iteration 175 :  1.230915176674395e-15
cost at iteration 176 :  1.1848513720004993e-15
cost at iteration 177 :  1.145356899951777e-15
cost at iteration 178 :  1.1038909947113941e-15
cost at iteration 179 :  1.068736099827871e-15
cost at iteration 180 :  1.031351380732268e-15
cost at iteration 181 :  1.000042412518301e-15
cost at iteration 182 :  9.662668218431575e-16
cost at iteration 183 :  9.383539293358188e-16
cost at iteration 184 :  9.07763429374051e-16
cost at iteration 185 :  8.828441551689815e-16
cost at iteration 186 :  8.550625974563028e-16
cost at iteration 187 :  8.327812584676045e-16
cost at iteration 188 :  8.074770468329984e-16
cost at iteration 189 :  7.875212308794483e-16
cost at iteration 190 :  7.644029236513191e-16
cost at iteration 191 :  7.464991155504614e-16
cost at iteration 192 :  7.253112095667482e-16
cost at iteration 193 :  7.092204830477113e-16
cost at iteration 194 :  6.897395570509903e-16
cost at iteration 195 :  6.752535365586823e-16
cost at iteration 196 :  6.572846420380502e-16
cost at iteration 197 :  6.442217674173144e-16
cost at iteration 198 :  6.275950288153354e-16
cost at iteration 199 :  6.157971486907068e-16
cost at iteration 200 :  6.003646065295487e-16
cost at iteration 201 :  5.896939147617833e-16
cost at iteration 202 :  5.753266529055541e-16
cost at iteration 203 :  5.656629648525032e-16
cost at iteration 204 :  5.522485432841758e-16
cost at iteration 205 :  5.434868970557214e-16
cost at iteration 206 :  5.309270903593028e-16
cost at iteration 207 :  5.229756520217333e-16
cost at iteration 208 :  5.111844788210232e-16
cost at iteration 209 :  5.039627265672815e-16
cost at iteration 210 :  4.928647464639906e-16
cost at iteration 211 :  4.863019062236491e-16
cost at iteration 212 :  4.758307566548698e-16
cost at iteration 213 :  4.69864460582065e-16
cost at iteration 214 :  4.599616049685518e-16
cost at iteration 215 :  4.545367447047628e-16
cost at iteration 216 :  4.451504041589872e-16
cost at iteration 217 :  4.402181523985649e-16
cost at iteration 218 :  4.313023952938707e-16
cost at iteration 219 :  4.2681937154120003e-16
cost at iteration 220 :  4.18333337841836e-16
cost at iteration 221 :  4.142608969441484e-16
cost at iteration 222 :  4.0616813697836937e-16
cost at iteration 223 :  4.0247176176108833e-16
cost at iteration 224 :  3.947396718474931e-16
cost at iteration 225 :  3.913884537896246e-16
cost at iteration 226 :  3.839877936637445e-16
cost at iteration 227 :  3.8095398793175445e-16
cost at iteration 228 :  3.7385846719914517e-16
cost at iteration 229 :  3.7111711046764604e-16
cost at iteration 230 :  3.6430303330924563e-16
cost at iteration 231 :  3.6183161462893858e-16
cost at iteration 232 :  3.552775737090254e-16
cost at iteration 233 :  3.53055750250636e-16
cost at iteration 234 :  3.467423622466467e-16
cost at iteration 235 :  3.4475171307783245e-16
cost at iteration 236 :  3.3866138949137253e-16
cost at iteration 237 :  3.36885201660068e-16
cost at iteration 238 :  3.310019496078094e-16
cost at iteration 239 :  3.294250317391147e-16
cost at iteration 240 :  3.2373428028973057e-16
cost at iteration 241 :  3.223427996808998e-16
cost at iteration 242 :  3.1683124802504406e-16
cost at iteration 243 :  3.1561258786948706e-16
cost at iteration 244 :  3.102680722082403e-16
cost at iteration 245 :  3.0921070611575404e-16
cost at iteration 246 :  3.0402208264853494e-16
cost at iteration 247 :  3.0311546407413413e-16
cost at iteration 248 :  2.980725058779456e-16
cost at iteration 249 :  2.973069704412481e-16
cost at iteration 250 :  2.924002763735764e-16
cost at iteration 251 :  2.917669553579092e-16
cost at iteration 252 :  2.8698786939843626e-16
cost at iteration 253 :  2.8647861297476477e-16
cost at iteration 254 :  2.8181915265626143e-16
cost at iteration 255 :  2.814264615905192e-16
cost at iteration 256 :  2.7687925436563357e-16
cost at iteration 257 :  2.765962191469185e-16
cost at iteration 258 :  2.721544457017867e-16
cost at iteration 259 :  2.719746921789176e-16
cost at iteration 260 :  2.6763203584253904e-16
cost at iteration 261 :  2.6754967658283687e-16
cost at iteration 262 :  2.633002780974808e-16
cost at iteration 263 :  2.6330986878848207e-16
cost at iteration 264 :  2.5914828580476315e-16
cost at iteration 265 :  2.5924478611010846e-16
cost at iteration 266 :  2.5516595685422155e-16
cost at iteration 267 :  2.5534469521196527e-16
cost at iteration 268 :  2.5134390584369694e-16
cost at iteration 269 :  2.5160054776114603e-16
cost at iteration 270 :  2.476734030026047e-16
cost at iteration 271 :  2.480039224580081e-16
cost at iteration 272 :  2.4414631912543074e-16
cost at iteration 273 :  2.445469727352708e-16
cost at iteration 274 :  2.4075507585161325e-16
cost at iteration 275 :  2.412223795040018e-16
cost at iteration 276 :  2.374926007091588e-16
cost at iteration 277 :  2.3802330839977447e-16
cost at iteration 278 :  2.3435228640930995e-16
cost at iteration 279 :  2.349433710476206e-16
cost at iteration 280 :  2.313279539403841e-16
cost at iteration 281 :  2.3197658992103472e-16
cost at iteration 282 :  2.2841381906186576e-16
cost at iteration 283 :  2.2911736641966854e-16
cost at iteration 284 :  2.2560446184583965e-16
cost at iteration 285 :  2.263604518335287e-16
cost at iteration 286 :  2.2289479895331227e-16
cost at iteration 287 :  2.2370092089920973e-16
cost at iteration 288 :  2.2028005836816057e-16
cost at iteration 289 :  2.211341476867625e-16
cost at iteration 290 :  2.177557563424833e-16
cost at iteration 291 :  2.1865578358484542e-16
cost at iteration 292 :  2.1531767633438008e-16
cost at iteration 293 :  2.1626173717744342e-16
cost at iteration 294 :  2.129618497429882e-16
cost at iteration 295 :  2.1394815582775739e-16
cost at iteration 296 :  2.106845382669325e-16
cost at iteration 297 :  2.117114088049377e-16
cost at iteration 298 :  2.084822177307495e-16
cost at iteration 299 :  2.0954807180667577e-16
cost at iteration 300 :  2.0635156324052146e-16
cost at iteration 301 :  2.074549127463097e-16
cost at iteration 302 :  2.0428943554432462e-16
cost at iteration 303 :  2.054288786867309e-16
cost at iteration 304 :  2.02292868486198e-16
cost at iteration 305 :  2.0346708381560452e-16
cost at iteration 306 :  2.003590574536323e-16
cost at iteration 307 :  2.0156679836722095e-16
cost at iteration 308 :  1.9848534872881043e-16
cost at iteration 309 :  1.9972543840580599e-16
cost at iteration 310 :  1.9666922966294682e-16
cost at iteration 311 :  1.9794055639382435e-16
cost at iteration 312 :  1.9490831960090889e-16
cost at iteration 313 :  1.9620983247620176e-16
cost at iteration 314 :  1.9320036149074642e-16
cost at iteration 315 :  1.9453106641831628e-16
cost at iteration 316 :  1.915432141189064e-16
cost at iteration 317 :  1.929021701416612e-16
cost at iteration 318 :  1.8993484491780614e-16
cost at iteration 319 :  1.91321160806339e-16
cost at iteration 320 :  1.8837332329740127e-16
cost at iteration 321 :  1.897861543945748e-16
cost at iteration 322 :  1.8685681445707627e-16
cost at iteration 323 :  1.882953597535833e-16
cost at iteration 324 :  1.8538357363818973e-16
cost at iteration 325 :  1.868470730601307e-16
cost at iteration 326 :  1.8395194078132165e-16
cost at iteration 327 :  1.8543967267257712e-16
cost at iteration 328 :  1.8256033555558716e-16
cost at iteration 329 :  1.840716143392266e-16
cost at iteration 330 :  1.8120725273024697e-16
cost at iteration 331 :  1.8274142673477357e-16
cost at iteration 332 :  1.7989125786168902e-16
cost at iteration 333 :  1.8144770729901766e-16
cost at iteration 334 :  1.7861098327105632e-16
cost at iteration 335 :  1.8018911835440922e-16
cost at iteration 336 :  1.7736512429008652e-16
cost at iteration 337 :  1.7896438348094528e-16
cost at iteration 338 :  1.7615243575469994e-16
cost at iteration 339 :  1.7777228412889254e-16
cost at iteration 340 :  1.7497172872751006e-16
cost at iteration 341 :  1.7661165645140957e-16
cost at iteration 342 :  1.7382186743219116e-16
cost at iteration 343 :  1.7548138834067222e-16
cost at iteration 344 :  1.7270176638394794e-16
cost at iteration 345 :  1.7438041665255903e-16
cost at iteration 346 :  1.716103877017322e-16
cost at iteration 347 :  1.7330772460607335e-16
cost at iteration 348 :  1.705467385889892e-16
cost at iteration 349 :  1.7226233934491907e-16
cost at iteration 350 :  1.6950986897084905e-16
cost at iteration 351 :  1.7124332964960203e-16
cost at iteration 352 :  1.6849886927655137e-16
cost at iteration 353 :  1.7024980378942255e-16
cost at iteration 354 :  1.6751286835698694e-16
cost at iteration 355 :  1.6928090750454317e-16
cost at iteration 356 :  1.6655103152777893e-16
cost at iteration 357 :  1.6833582210904976e-16
cost at iteration 358 :  1.6561255872933702e-16
cost at iteration 359 :  1.6741376270676612e-16
cost at iteration 360 :  1.6469668279581655e-16
cost at iteration 361 :  1.6651397651204292e-16
cost at iteration 362 :  1.6380266782560876e-16
cost at iteration 363 :  1.6563574126849188e-16
cost at iteration 364 :  1.6292980764649788e-16
cost at iteration 365 :  1.6477836375909592e-16
cost at iteration 366 :  1.6207742436926169e-16
cost at iteration 367 :  1.6394117840163404e-16
cost at iteration 368 :  1.612448670237781e-16
cost at iteration 369 :  1.6312354592379231e-16
cost at iteration 370 :  1.6043151027230589e-16
cost at iteration 371 :  1.6232485211282463e-16
cost at iteration 372 :  1.5963675319490105e-16
cost at iteration 373 :  1.6154450663488603e-16
cost at iteration 374 :  1.5886001814236088e-16
cost at iteration 375 :  1.607819419196419e-16
cost at iteration 376 :  1.581007496523423e-16
cost at iteration 377 :  1.600366121059598e-16
cost at iteration 378 :  1.573584134247284e-16
cost at iteration 379 :  1.5930799204487625e-16
cost at iteration 380 :  1.5663249535246758e-16
cost at iteration 381 :  1.5859557635625164e-16
cost at iteration 382 :  1.5592250060449067e-16
cost at iteration 383 :  1.578988785358092e-16
cost at iteration 384 :  1.5522795275746197e-16
cost at iteration 385 :  1.5721743010943196e-16
cost at iteration 386 :  1.545483929733887e-16
cost at iteration 387 :  1.5655077983190013e-16
cost at iteration 388 :  1.5388337922034422e-16
cost at iteration 389 :  1.5589849292733725e-16
cost at iteration 390 :  1.5323248553364327e-16
cost at iteration 391 :  1.5526015036890363e-16
cost at iteration 392 :  1.5259530131514328e-16
cost at iteration 393 :  1.5463534819539692e-16
cost at iteration 394 :  1.519714306683414e-16
cost at iteration 395 :  1.5402369686257138e-16
cost at iteration 396 :  1.5136049176720607e-16
cost at iteration 397 :  1.5342482062719942e-16
cost at iteration 398 :  1.507621162567934e-16
cost at iteration 399 :  1.5283835696191118e-16
cost at iteration 400 :  1.5017594868376105e-16
cost at iteration 401 :  1.522639559991077e-16
cost at iteration 402 :  1.4960164595511616e-16
cost at iteration 403 :  1.5170128000223407e-16
cost at iteration 404 :  1.490388768235791e-16
cost at iteration 405 :  1.511500028629215e-16
cost at iteration 406 :  1.4848732139803188e-16
cost at iteration 407 :  1.5060980962249925e-16
cost at iteration 408 :  1.4794667067769754e-16
cost at iteration 409 :  1.5008039601653875e-16
cost at iteration 410 :  1.4741662610867683e-16
cost at iteration 411 :  1.4956146804116271e-16
cost at iteration 412 :  1.4689689916166778e-16
cost at iteration 413 :  1.4905274153992265e-16
cost at iteration 414 :  1.4638721092964152e-16
cost at iteration 415 :  1.4855394181009474e-16
cost at iteration 416 :  1.4588729174445549e-16
cost at iteration 417 :  1.4806480322741804e-16
cost at iteration 418 :  1.4539688081132964e-16
cost at iteration 419 :  1.4758506888820118e-16
cost at iteration 420 :  1.4491572586027806e-16
cost at iteration 421 :  1.4711449026791168e-16
cost at iteration 422 :  1.4444358281352863e-16
cost at iteration 423 :  1.466528268954105e-16
cost at iteration 424 :  1.4398021546816736e-16
cost at iteration 425 :  1.461998460419411e-16
cost at iteration 426 :  1.4352539519314843e-16
cost at iteration 427 :  1.4575532242416232e-16
cost at iteration 428 :  1.4307890063993644e-16
cost at iteration 429 :  1.4531903792045772e-16
cost at iteration 430 :  1.4264051746609958e-16
cost at iteration 431 :  1.448907812998836e-16
cost at iteration 432 :  1.422100380711507e-16
cost at iteration 433 :  1.4447034796307567e-16
cost at iteration 434 :  1.4178726134406617e-16
cost at iteration 435 :  1.4405753969450002e-16
cost at iteration 436 :  1.4137199242182229e-16
cost at iteration 437 :  1.4365216442554282e-16
cost at iteration 438 :  1.4096404245845823e-16
cost at iteration 439 :  1.4325403600781014e-16
cost at iteration 440 :  1.4056322840410944e-16
cost at iteration 441 :  1.4286297399620154e-16
cost at iteration 442 :  1.4016937279350806e-16
cost at iteration 443 :  1.4247880344123527e-16
cost at iteration 444 :  1.3978230354352747e-16
cost at iteration 445 :  1.4210135469018721e-16
cost at iteration 446 :  1.3940185375926494e-16
cost at iteration 447 :  1.4173046319662653e-16
cost at iteration 448 :  1.3902786154831572e-16
cost at iteration 449 :  1.413659693379161e-16
cost at iteration 450 :  1.3866016984278686e-16
cost at iteration 451 :  1.4100771824031117e-16
cost at iteration 452 :  1.3829862622871232e-16
cost at iteration 453 :  1.4065555961131503e-16
cost at iteration 454 :  1.3794308278250947e-16
cost at iteration 455 :  1.4030934757888363e-16
cost at iteration 456 :  1.3759339591412937e-16
cost at iteration 457 :  1.3996894053725365e-16
cost at iteration 458 :  1.372494262166191e-16
cost at iteration 459 :  1.396342009989731e-16
cost at iteration 460 :  1.3691103832175165e-16
cost at iteration 461 :  1.3930499545295854e-16
cost at iteration 462 :  1.3657810076149127e-16
cost at iteration 463 :  1.3898119422820164e-16
cost at iteration 464 :  1.3625048583497612e-16
cost at iteration 465 :  1.3866267136293565e-16
cost at iteration 466 :  1.3592806948080087e-16
cost at iteration 467 :  1.3834930447898601e-16
cost at iteration 468 :  1.3561073115434817e-16
cost at iteration 469 :  1.3804097466106014e-16
cost at iteration 470 :  1.3529835370992833e-16
cost at iteration 471 :  1.3773756634076635e-16
cost at iteration 472 :  1.349908232875301e-16
cost at iteration 473 :  1.3743896718516934e-16
cost at iteration 474 :  1.3468802920395347e-16
cost at iteration 475 :  1.3714506798963718e-16
cost at iteration 476 :  1.3438986384816206e-16
cost at iteration 477 :  1.3685576257482293e-16
cost at iteration 478 :  1.340962225806319e-16
cost at iteration 479 :  1.3657094768758964e-16
cost at iteration 480 :  1.3380700363653734e-16
cost at iteration 481 :  1.3629052290570662e-16
cost at iteration 482 :  1.335221080326269e-16
cost at iteration 483 :  1.3601439054614782e-16
cost at iteration 484 :  1.3324143947758831e-16
cost at iteration 485 :  1.357424555768486e-16
cost at iteration 486 :  1.329649042857834e-16
cost at iteration 487 :  1.3547462553175412e-16
cost at iteration 488 :  1.3269241129419542e-16
cost at iteration 489 :  1.3521081042904474e-16
cost at iteration 490 :  1.3242387178245578e-16
cost at iteration 491 :  1.349509226923719e-16
cost at iteration 492 :  1.321591993958086e-16
cost at iteration 493 :  1.3469487707500356e-16
cost at iteration 494 :  1.318983100709203e-16
cost at iteration 495 :  1.3444259058675092e-16
cost at iteration 496 :  1.3164112196436877e-16
cost at iteration 497 :  1.3419398242353657e-16
cost at iteration 498 :  1.3138755538373685e-16
cost at iteration 499 :  1.33948973899536e-16
cost at iteration 500 :  1.3113753272119213e-16
cost at iteration 501 :  1.3370748838175338e-16
cost at iteration 502 :  1.3089097838942666e-16
cost at iteration 503 :  1.3346945122694313e-16
cost at iteration 504 :  1.306478187599296e-16
cost at iteration 505 :  1.3323478972077395e-16
cost at iteration 506 :  1.3040798210338768e-16
cost at iteration 507 :  1.330034330191658e-16
cost at iteration 508 :  1.3017139853223004e-16
cost at iteration 509 :  1.3277531209168492e-16
cost at iteration 510 :  1.2993799994518185e-16
cost at iteration 511 :  1.3255035966692186e-16
cost at iteration 512 :  1.2970771997374511e-16
cost at iteration 513 :  1.3232851017978625e-16
cost at iteration 514 :  1.2948049393054262e-16
cost at iteration 515 :  1.3210969972062944e-16
cost at iteration 516 :  1.2925625875944803e-16
cost at iteration 517 :  1.3189386598612122e-16
cost at iteration 518 :  1.290349529874296e-16
cost at iteration 519 :  1.3168094823182291e-16
cost at iteration 520 :  1.2881651667803647e-16
cost at iteration 521 :  1.3147088722637322e-16
cost at iteration 522 :  1.286008913864787e-16
cost at iteration 523 :  1.3126362520724488e-16
cost at iteration 524 :  1.2838802011620766e-16
cost at iteration 525 :  1.310591058379922e-16
cost at iteration 526 :  1.2817784727698272e-16
cost at iteration 527 :  1.3085727416693645e-16
cost at iteration 528 :  1.2797031864432607e-16
cost at iteration 529 :  1.3065807658725124e-16
cost at iteration 530 :  1.2776538132033747e-16
cost at iteration 531 :  1.3046146079836233e-16
cost at iteration 532 :  1.275629836957966e-16
cost at iteration 533 :  1.3026737576864075e-16
cost at iteration 534 :  1.2736307541354184e-16
cost at iteration 535 :  1.3007577169932687e-16
cost at iteration 536 :  1.2716560733303227e-16
cost at iteration 537 :  1.2988659998963976e-16
cost at iteration 538 :  1.2697053149606043e-16
cost at iteration 539 :  1.296998132030165e-16
cost at iteration 540 :  1.2677780109360725e-16
cost at iteration 541 :  1.2951536503448535e-16
cost at iteration 542 :  1.2658737043375712e-16
cost at iteration 543 :  1.2933321027905036e-16
cost at iteration 544 :  1.263991949106369e-16
cost at iteration 545 :  1.2915330480114482e-16
cost at iteration 546 :  1.2621323097436112e-16
cost at iteration 547 :  1.289756055050115e-16
cost at iteration 548 :  1.2602943610194526e-16
cost at iteration 549 :  1.2880007030608464e-16
cost at iteration 550 :  1.2584776876912253e-16
cost at iteration 551 :  1.2862665810325036e-16
cost at iteration 552 :  1.2566818842306723e-16
cost at iteration 553 :  1.2845532875197454e-16
cost at iteration 554 :  1.2549065545598273e-16
cost at iteration 555 :  1.2828604303832207e-16
cost at iteration 556 :  1.253151311794774e-16
cost at iteration 557 :  1.281187626537424e-16
cost at iteration 558 :  1.2514157779980502e-16
cost at iteration 559 :  1.2795345017066977e-16
cost at iteration 560 :  1.2496995839381993e-16
cost at iteration 561 :  1.2779006901888796e-16
cost at iteration 562 :  1.2480023688568032e-16
cost at iteration 563 :  1.276285834626022e-16
cost at iteration 564 :  1.246323780243079e-16
cost at iteration 565 :  1.2746895857823128e-16
cost at iteration 566 :  1.2446634736149463e-16
cost at iteration 567 :  1.2731116023288032e-16
cost at iteration 568 :  1.2430211123069375e-16
cost at iteration 569 :  1.2715515506348184e-16
cost at iteration 570 :  1.24139636726456e-16
cost at iteration 571 :  1.270009104565412e-16
cost at iteration 572 :  1.2397889168448994e-16
cost at iteration 573 :  1.2684839452852892e-16
cost at iteration 574 :  1.2381984466231338e-16
cost at iteration 575 :  1.2669757610683443e-16
cost at iteration 576 :  1.2366246492048602e-16
cost at iteration 577 :  1.2654842471131812e-16
cost at iteration 578 :  1.2350672240440974e-16
cost at iteration 579 :  1.264009105363968e-16
cost at iteration 580 :  1.2335258772666456e-16
cost at iteration 581 :  1.2625500443365685e-16
cost at iteration 582 :  1.2320003214986123e-16
cost at iteration 583 :  1.2611067789500826e-16
cost at iteration 584 :  1.2304902757001123e-16
cost at iteration 585 :  1.2596790303631015e-16
cost at iteration 586 :  1.228995465003705e-16
cost at iteration 587 :  1.258266525814797e-16
cost at iteration 588 :  1.2275156205576463e-16
cost at iteration 589 :  1.2568689984709218e-16
cost at iteration 590 :  1.2260504793737093e-16
cost at iteration 591 :  1.2554861872738436e-16
cost at iteration 592 :  1.2245997841792659e-16
cost at iteration 593 :  1.254117836797367e-16
cost at iteration 594 :  1.223163283273915e-16
cost at iteration 595 :  1.25276369710546e-16
cost at iteration 596 :  1.2217407303898194e-16
cost at iteration 597 :  1.2514235236152074e-16
cost at iteration 598 :  1.2203318845564876e-16
cost at iteration 599 :  1.2500970769635225e-16
[ ]: