# 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)$

## 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.13042435973102356
Newton iteration  1
err =  4.0704987454624573e-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.1522441308147555e-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 =  3.324234029836267e-16
Cost at new design 9.793297083297814e-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.13042435973102356
Newton iteration  1
err =  4.0704987454624573e-16
cost at iteration 0 :  5.1522441308147555e-09
cost at iteration 1 :  4.942040315052278e-09
cost at iteration 2 :  4.585081411492749e-09
cost at iteration 3 :  4.249440980557088e-09
cost at iteration 4 :  3.934230926246943e-09
cost at iteration 5 :  3.6385762619912925e-09
cost at iteration 6 :  3.361616050334072e-09
cost at iteration 7 :  3.102504336079485e-09
cost at iteration 8 :  2.860411070592973e-09
cost at iteration 9 :  2.634523024596652e-09
cost at iteration 10 :  2.4240446863394626e-09
cost at iteration 11 :  2.2281991414270802e-09
cost at iteration 12 :  2.0462289298150803e-09
cost at iteration 13 :  1.8773968744302314e-09
cost at iteration 14 :  1.7209868744933646e-09
cost at iteration 15 :  1.5763046547393887e-09
cost at iteration 16 :  1.4426784591830553e-09
cost at iteration 17 :  1.3194596746124638e-09
cost at iteration 18 :  1.2060233642634605e-09
cost at iteration 19 :  1.1017686856714439e-09
cost at iteration 20 :  1.0061191578834543e-09
cost at iteration 21 :  9.185227311982651e-10
cost at iteration 22 :  8.384515962699072e-10
cost at iteration 23 :  7.654016473209055e-10
cost at iteration 24 :  6.98891484596865e-10
cost at iteration 25 :  6.384608021036902e-10
cost at iteration 26 :  5.836679565498962e-10
cost at iteration 27 :  5.340864528118764e-10
cost at iteration 28 :  4.893000172852368e-10
cost at iteration 29 :  4.488958881947117e-10
cost at iteration 30 :  4.124560013597088e-10
cost at iteration 31 :  3.7954606800853286e-10
cost at iteration 32 :  3.4970353858155983e-10
cost at iteration 33 :  3.2242796268383904e-10
cost at iteration 34 :  2.9718256556606e-10
cost at iteration 35 :  2.734241271728055e-10
cost at iteration 36 :  2.506818430417794e-10
cost at iteration 37 :  2.28679059850509e-10
cost at iteration 38 :  2.0741713926515877e-10
cost at iteration 39 :  1.8711167400729791e-10
cost at iteration 40 :  1.680162412540865e-10
cost at iteration 41 :  1.5029552102882875e-10
cost at iteration 42 :  1.340064930638265e-10
cost at iteration 43 :  1.1913067682907598e-10
cost at iteration 44 :  1.0560796580779414e-10
cost at iteration 45 :  9.335887914179758e-11
cost at iteration 46 :  8.22969572994248e-11
cost at iteration 47 :  7.233508979947751e-11
cost at iteration 48 :  6.338852880933334e-11
cost at iteration 49 :  5.53762094979999e-11
cost at iteration 50 :  4.82212488522358e-11
cost at iteration 51 :  4.185106579754666e-11
cost at iteration 52 :  3.619733722937543e-11
cost at iteration 53 :  3.119588920801158e-11
cost at iteration 54 :  2.678656684957824e-11
cost at iteration 55 :  2.291310069569329e-11
cost at iteration 56 :  1.9522975967307512e-11
cost at iteration 57 :  1.656730628871614e-11
cost at iteration 58 :  1.4000711487116362e-11
cost at iteration 59 :  1.1781198254498674e-11
cost at iteration 60 :  9.87004210805941e-12
cost at iteration 61 :  8.231668931389e-12
cost at iteration 62 :  6.833534355412065e-12
cost at iteration 63 :  5.64599930897544e-12
cost at iteration 64 :  4.642200293031124e-12
cost at iteration 65 :  3.797913225656164e-12
cost at iteration 66 :  3.0914102768865944e-12
cost at iteration 67 :  2.503309498290815e-12
cost at iteration 68 :  2.016418297346919e-12
cost at iteration 69 :  1.6155712171403534e-12
cost at iteration 70 :  1.2874668505017852e-12
cost at iteration 71 :  1.0204996243541797e-12
cost at iteration 72 :  8.046147876389755e-13
cost at iteration 73 :  6.311812110340034e-13
cost at iteration 74 :  4.939544800296666e-13
cost at iteration 75 :  4.0068156886062855e-13
cost at iteration 76 :  3.65300383421556e-13
cost at iteration 77 :  3.3591385801562887e-13
cost at iteration 78 :  3.062976684044402e-13
cost at iteration 79 :  2.8129617337769307e-13
cost at iteration 80 :  2.5728405048093445e-13
cost at iteration 81 :  2.362657561132334e-13
cost at iteration 82 :  2.1660637995736202e-13
cost at iteration 83 :  1.9906231018148354e-13
cost at iteration 84 :  1.8288448216064352e-13
cost at iteration 85 :  1.6829526219687265e-13
cost at iteration 86 :  1.5494397755103007e-13
cost at iteration 87 :  1.4283255478379146e-13
cost at iteration 88 :  1.3179108045422343e-13
cost at iteration 89 :  1.2173889032417064e-13
cost at iteration 90 :  1.1258824992204541e-13
cost at iteration 91 :  1.0423608402022756e-13
cost at iteration 92 :  9.663182516084941e-14
cost at iteration 93 :  8.96755589783191e-14
cost at iteration 94 :  8.333335686066066e-14
cost at iteration 95 :  7.751849539998827e-14
cost at iteration 96 :  7.220441042890742e-14
cost at iteration 97 :  6.73205578560302e-14
cost at iteration 98 :  6.284358609985726e-14
cost at iteration 99 :  5.871892237252128e-14
cost at iteration 100 :  5.492455469452983e-14
cost at iteration 101 :  5.142028107635929e-14
cost at iteration 102 :  4.818455248561201e-14
cost at iteration 103 :  4.5189437529973166e-14
cost at iteration 104 :  4.241342108997084e-14
cost at iteration 105 :  3.983869846516846e-14
cost at iteration 106 :  3.744358327478284e-14
cost at iteration 107 :  3.5218432886914074e-14
cost at iteration 108 :  3.3141314540618856e-14
cost at iteration 109 :  3.120905277601754e-14
cost at iteration 110 :  2.939947589189696e-14
cost at iteration 111 :  2.771446723076036e-14
cost at iteration 112 :  2.613167453405824e-14
cost at iteration 113 :  2.465689826481796e-14
cost at iteration 114 :  2.326769041097305e-14
cost at iteration 115 :  2.197285941221573e-14
cost at iteration 116 :  2.0749953410892237e-14
cost at iteration 117 :  1.9610075973836794e-14
cost at iteration 118 :  1.853085578284382e-14
cost at iteration 119 :  1.7525142443143474e-14
cost at iteration 120 :  1.6570711529586235e-14
cost at iteration 121 :  1.568174665860795e-14
cost at iteration 122 :  1.4836211608940675e-14
cost at iteration 123 :  1.4049328275397407e-14
cost at iteration 124 :  1.3299261056819762e-14
cost at iteration 125 :  1.2602074379784911e-14
cost at iteration 126 :  1.1936116138248133e-14
cost at iteration 127 :  1.1318181041132647e-14
cost at iteration 128 :  1.0726755457336137e-14
cost at iteration 129 :  1.0179304599928019e-14
cost at iteration 130 :  9.654376997901812e-15
cost at iteration 131 :  9.170018667701146e-15
cost at iteration 132 :  8.704710437094774e-15
cost at iteration 133 :  8.276796248835644e-15
cost at iteration 134 :  7.864540257975245e-15
cost at iteration 135 :  7.486074003802557e-15
cost at iteration 136 :  7.119664696708004e-15
cost at iteration 137 :  6.78291824817428e-15
cost at iteration 138 :  6.454993431194067e-15
cost at iteration 139 :  6.15291702010279e-15
cost at iteration 140 :  5.8574900295012794e-15
cost at iteration 141 :  5.584934033760093e-15
cost at iteration 142 :  5.317795675617128e-15
cost at iteration 143 :  5.071240108179732e-15
cost at iteration 144 :  4.829363160533138e-15
cost at iteration 145 :  4.606205259523818e-15
cost at iteration 146 :  4.387182269110182e-15
cost at iteration 147 :  4.185283672718555e-15
cost at iteration 148 :  3.987040569452517e-15
cost at iteration 149 :  3.804523080700889e-15
cost at iteration 150 :  3.6251994569961265e-15
cost at iteration 151 :  3.460362144917457e-15
cost at iteration 152 :  3.298262640293121e-15
cost at iteration 153 :  3.149547637443426e-15
cost at iteration 154 :  3.0031199766745677e-15
cost at iteration 155 :  2.8690961422974544e-15
cost at iteration 156 :  2.7369182586943723e-15
cost at iteration 157 :  2.616270737469264e-15
cost at iteration 158 :  2.497040478180959e-15
cost at iteration 159 :  2.388561762745765e-15
cost at iteration 160 :  2.2810869980400667e-15
cost at iteration 161 :  2.1836681423482596e-15
cost at iteration 162 :  2.0868568472785363e-15
cost at iteration 163 :  1.9994787789604128e-15
cost at iteration 164 :  1.9123294329330702e-15
cost at iteration 165 :  1.834054901604474e-15
cost at iteration 166 :  1.7556478781906566e-15
cost at iteration 167 :  1.6856147025265802e-15
cost at iteration 168 :  1.6151052291995563e-15
cost at iteration 169 :  1.5525210904570656e-15
cost at iteration 170 :  1.4891337367408323e-15
cost at iteration 171 :  1.4332717986494952e-15
cost at iteration 172 :  1.37629546015595e-15
cost at iteration 173 :  1.3264891018618428e-15
cost at iteration 174 :  1.2752708987309847e-15
cost at iteration 175 :  1.2309061020678648e-15
cost at iteration 176 :  1.1848437540710317e-15
cost at iteration 177 :  1.1453502559390838e-15
cost at iteration 178 :  1.1038853545565575e-15
cost at iteration 179 :  1.0687308929304514e-15
cost at iteration 180 :  1.0313468448138048e-15
cost at iteration 181 :  1.0000379463890692e-15
cost at iteration 182 :  9.662628394202962e-16
cost at iteration 183 :  9.383498296746708e-16
cost at iteration 184 :  9.077597309064978e-16
cost at iteration 185 :  8.828402700594628e-16
cost at iteration 186 :  8.550590810497157e-16
cost at iteration 187 :  8.327775441968924e-16
cost at iteration 188 :  8.074736845929568e-16
cost at iteration 189 :  7.875176816587727e-16
cost at iteration 190 :  7.643997124117561e-16
cost at iteration 191 :  7.464957336894437e-16
cost at iteration 192 :  7.253081512737613e-16
cost at iteration 193 :  7.092172695389486e-16
cost at iteration 194 :  6.897366523593919e-16
cost at iteration 195 :  6.752504891565593e-16
cost at iteration 196 :  6.572818888320469e-16
cost at iteration 197 :  6.442188809985445e-16
cost at iteration 198 :  6.275924224659099e-16
cost at iteration 199 :  6.157944161556602e-16
cost at iteration 200 :  6.003621406579862e-16
cost at iteration 201 :  5.896913279018997e-16
cost at iteration 202 :  5.753243201461014e-16
cost at iteration 203 :  5.656605150120454e-16
cost at iteration 204 :  5.522463358707659e-16
cost at iteration 205 :  5.43484575575646e-16
cost at iteration 206 :  5.309250005182942e-16
cost at iteration 207 :  5.229734505097292e-16
cost at iteration 208 :  5.1118249900936e-16
cost at iteration 209 :  5.039606370465264e-16
cost at iteration 210 :  4.928628695005046e-16
cost at iteration 211 :  4.862999212033647e-16
cost at iteration 212 :  4.758289757832961e-16
cost at iteration 213 :  4.698625730802824e-16
cost at iteration 214 :  4.599599138788833e-16
cost at iteration 215 :  4.545349482432591e-16
cost at iteration 216 :  4.451487969845449e-16
cost at iteration 217 :  4.4021644098242216e-16
cost at iteration 218 :  4.3130086659481423e-16
cost at iteration 219 :  4.268177396306313e-16
cost at iteration 220 :  4.1833188258166415e-16
cost at iteration 221 :  4.1425933942308923e-16
cost at iteration 222 :  4.0616675049737857e-16
cost at iteration 223 :  4.024702739052052e-16
cost at iteration 224 :  3.947383498354651e-16
cost at iteration 225 :  3.9138703123521456e-16
cost at iteration 226 :  3.8398653213318884e-16
cost at iteration 227 :  3.8095262664630817e-16
cost at iteration 228 :  3.7385726245981535e-16
cost at iteration 229 :  3.7111580672240523e-16
cost at iteration 230 :  3.643018819442394e-16
cost at iteration 231 :  3.6183036497358976e-16
cost at iteration 232 :  3.5527647255261813e-16
cost at iteration 233 :  3.5305455149009396e-16
cost at iteration 234 :  3.4674130836389435e-16
cost at iteration 235 :  3.4475056225100915e-16
cost at iteration 236 :  3.386603801593201e-16
cost at iteration 237 :  3.368840960205125e-16
cost at iteration 238 :  3.310009822983503e-16
cost at iteration 239 :  3.2942396873734895e-16
cost at iteration 240 :  3.2373335265384397e-16
cost at iteration 241 :  3.2234177694832305e-16
cost at iteration 242 :  3.1683035787844537e-16
cost at iteration 243 :  3.156116032036908e-16
cost at iteration 244 :  3.102672175181963e-16
cost at iteration 245 :  3.092097574671298e-16
cost at iteration 246 :  3.0402126152185796e-16
cost at iteration 247 :  3.0311454953364065e-16
cost at iteration 248 :  2.98071716549958e-16
cost at iteration 249 :  2.973060882292454e-16
cost at iteration 250 :  2.9239951719803067e-16
cost at iteration 251 :  2.917661038139505e-16
cost at iteration 252 :  2.869871388382902e-16
cost at iteration 253 :  2.8647779054824845e-16
cost at iteration 254 :  2.818184492752166e-16
cost at iteration 255 :  2.814256668321471e-16
cost at iteration 256 :  2.768785768203762e-16
cost at iteration 257 :  2.765954507008836e-16
cost at iteration 258 :  2.721537927348923e-16
cost at iteration 259 :  2.7197394877573327e-16
cost at iteration 260 :  2.676314062759584e-16
cost at iteration 261 :  2.6754895703277393e-16
cost at iteration 262 :  2.632996708265408e-16
cost at iteration 263 :  2.633091719755459e-16
cost at iteration 264 :  2.5914769979271925e-16
cost at iteration 265 :  2.5924411098653485e-16
cost at iteration 266 :  2.5516539112719684e-16
cost at iteration 267 :  2.5534404079316078e-16
cost at iteration 268 :  2.5134335948608196e-16
cost at iteration 269 :  2.515999131210479e-16
cost at iteration 270 :  2.4767287515281026e-16
cost at iteration 271 :  2.4800330672481073e-16
cost at iteration 272 :  2.4414580897198846e-16
cost at iteration 273 :  2.445463750875315e-16
cost at iteration 274 :  2.4075458262960687e-16
cost at iteration 275 :  2.412217991670442e-16
cost at iteration 276 :  2.374921236969247e-16
cost at iteration 277 :  2.380227446423787e-16
cost at iteration 278 :  2.3435182492541085e-16
cost at iteration 279 :  2.3494282317899956e-16
cost at iteration 280 :  2.3132750734083007e-16
cost at iteration 281 :  2.3197605728803603e-16
cost at iteration 282 :  2.284133867375514e-16
cost at iteration 283 :  2.291168484042084e-16
cost at iteration 284 :  2.2560404322018077e-16
cost at iteration 285 :  2.263599478502289e-16
cost at iteration 286 :  2.228943934800668e-16
cost at iteration 287 :  2.237004303932124e-16
cost at iteration 288 :  2.2027966552942974e-16
cost at iteration 289 :  2.2113367013171972e-16
cost at iteration 290 :  2.1775537564686114e-16
cost at iteration 291 :  2.1865531848107955e-16
cost at iteration 292 :  2.1531730731523781e-16
cost at iteration 293 :  2.1626128405021682e-16
cost at iteration 294 :  2.1296149195690214e-16
cost at iteration 295 :  2.139477142257072e-16
cost at iteration 296 :  2.1068419129221938e-16
cost at iteration 297 :  2.117109782986099e-16
cost at iteration 298 :  2.0848188116612584e-16
cost at iteration 299 :  2.0954765198717378e-16
cost at iteration 300 :  2.063512367038359e-16
cost at iteration 301 :  2.0745450322404898e-16
cost at iteration 302 :  2.0428911867141796e-16
cost at iteration 303 :  2.0542847909027137e-16
cost at iteration 304 :  2.0229256092981951e-16
cost at iteration 305 :  2.034666937905862e-16
cost at iteration 306 :  2.0035875888244022e-16
cost at iteration 307 :  2.015664175753511e-16
cost at iteration 308 :  1.9848505882646305e-16
cost at iteration 309 :  1.997250665239624e-16
cost at iteration 310 :  1.9666894812722194e-16
cost at iteration 311 :  1.9794019311316547e-16
cost at iteration 312 :  1.949080461429148e-16
cost at iteration 313 :  1.962094775013757e-16
cost at iteration 314 :  1.932000958341753e-16
cost at iteration 315 :  1.9453071946672813e-16
cost at iteration 316 :  1.9154295599934158e-16
cost at iteration 317 :  1.9290183094276262e-16
cost at iteration 318 :  1.8993459408207257e-16
cost at iteration 319 :  1.9132082910099377e-16
cost at iteration 320 :  1.883730795029661e-16
cost at iteration 321 :  1.897858299344466e-16
cost at iteration 322 :  1.868565774714778e-16
cost at iteration 323 :  1.8829504230056786e-16
cost at iteration 324 :  1.8538334323852052e-16
cost at iteration 325 :  1.8684676238584217e-16
cost at iteration 326 :  1.8395171675372991e-16
cost at iteration 327 :  1.8543936855784308e-16
cost at iteration 328 :  1.8256011769481041e-16
cost at iteration 329 :  1.8407131657362938e-16
cost at iteration 330 :  1.8120704083919253e-16
cost at iteration 331 :  1.8274113511621135e-16
cost at iteration 332 :  1.798910517510243e-16
cost at iteration 333 :  1.814474216333109e-16
cost at iteration 334 :  1.7861078275881374e-16
cost at iteration 335 :  1.801888384549011e-16
cost at iteration 336 :  1.7736492920132925e-16
cost at iteration 337 :  1.789641091681614e-16
cost at iteration 338 :  1.761522459211742e-16
cost at iteration 339 :  1.777720152301857e-16
cost at iteration 340 :  1.7497154398732223e-16
cost at iteration 341 :  1.766113928006509e-16
cost at iteration 342 :  1.7382168762953076e-16
cost at iteration 343 :  1.7548112977795181e-16
cost at iteration 344 :  1.727015913687864e-16
cost at iteration 345 :  1.7438016302390102e-16
cost at iteration 346 :  1.7161021732957018e-16
cost at iteration 347 :  1.7330747576316865e-16
cost at iteration 348 :  1.7054657272061235e-16
cost at iteration 349 :  1.7226209514487796e-16
cost at iteration 350 :  1.69509707472073e-16
cost at iteration 351 :  1.7124308995470428e-16
cost at iteration 352 :  1.684987120180224e-16
cost at iteration 353 :  1.7024956846691392e-16
cost at iteration 354 :  1.6751271521395553e-16
cost at iteration 355 :  1.6928067642639353e-16
cost at iteration 356 :  1.6655088237990697e-16
cost at iteration 357 :  1.6833559515178e-16
cost at iteration 358 :  1.6561241346051078e-16
cost at iteration 359 :  1.674135397512333e-16
cost at iteration 360 :  1.6469654129396482e-16
cost at iteration 361 :  1.6651375744326705e-16
cost at iteration 362 :  1.6380252998253021e-16
cost at iteration 363 :  1.6563552597548834e-16
cost at iteration 364 :  1.6292967335771335e-16
cost at iteration 365 :  1.6477815213470691e-16
cost at iteration 366 :  1.6207729353384842e-16
cost at iteration 367 :  1.6394097034237163e-16
cost at iteration 368 :  1.612447395442301e-16
cost at iteration 369 :  1.631233413296908e-16
cost at iteration 370 :  1.6043138605439338e-16
cost at iteration 371 :  1.6232465088729893e-16
cost at iteration 372 :  1.596366321475475e-16
cost at iteration 373 :  1.6154430868459998e-16
cost at iteration 374 :  1.5885990017750238e-16
cost at iteration 375 :  1.607817471543781e-16
cost at iteration 376 :  1.5810063468482638e-16
cost at iteration 377 :  1.6003642043849754e-16
cost at iteration 378 :  1.5735830137218863e-16
cost at iteration 379 :  1.5930780339087578e-16
cost at iteration 380 :  1.566323861352233e-16
cost at iteration 381 :  1.5859539063414304e-16
cost at iteration 382 :  1.5592239414543917e-16
cost at iteration 383 :  1.5789869566668107e-16
cost at iteration 384 :  1.552278489819782e-16
cost at iteration 385 :  1.5721725001693935e-16
cost at iteration 386 :  1.5454829180924083e-16
cost at iteration 387 :  1.5655060244215908e-16
cost at iteration 388 :  1.5388328059759238e-16
cost at iteration 389 :  1.5589831816883933e-16
cost at iteration 390 :  1.5323238938456414e-16
cost at iteration 391 :  1.552599781724214e-16
cost at iteration 392 :  1.5259520757414228e-16
cost at iteration 393 :  1.5463517849389945e-16
cost at iteration 394 :  1.5197133927187082e-16
cost at iteration 395 :  1.540235295911477e-16
cost at iteration 396 :  1.5136040265370206e-16
cost at iteration 397 :  1.5342465572298036e-16
cost at iteration 398 :  1.5076202936659122e-16
cost at iteration 399 :  1.5283819436398784e-16
cost at iteration 400 :  1.501758639590338e-16
cost at iteration 401 :  1.5226379564846594e-16
cost at iteration 402 :  1.496015633398081e-16
cost at iteration 403 :  1.51701121841688e-16
cost at iteration 404 :  1.4903879626334215e-16
cost at iteration 405 :  1.5114984683704122e-16
cost at iteration 406 :  1.484872428401621e-16
cost at iteration 407 :  1.50609655677554e-16
cost at iteration 408 :  1.479465940710833e-16
cost at iteration 409 :  1.5008024410043262e-16
cost at iteration 410 :  1.4741655140373833e-16
cost at iteration 411 :  1.4956131810338005e-16
cost at iteration 412 :  1.4689682631030046e-16
cost at iteration 413 :  1.49052593531466e-16
cost at iteration 414 :  1.463871398851732e-16
cost at iteration 415 :  1.4855379568344384e-16
cost at iteration 416 :  1.4588722246159393e-16
cost at iteration 417 :  1.4806465893646826e-16
cost at iteration 418 :  1.453968132461128e-16
cost at iteration 419 :  1.4758492638821159e-16
cost at iteration 420 :  1.4491565997002522e-16
cost at iteration 421 :  1.471143495154688e-16
cost at iteration 422 :  1.4444351855680604e-16
cost at iteration 423 :  1.4665268784837782e-16
cost at iteration 424 :  1.439801528047497e-16
cost at iteration 425 :  1.461997086594138e-16
cost at iteration 426 :  1.4352533408395794e-16
cost at iteration 427 :  1.4575518666641941e-16
cost at iteration 428 :  1.43078841047021e-16
cost at iteration 429 :  1.4531890374893594e-16
cost at iteration 430 :  1.426404593525915e-16
cost at iteration 431 :  1.4489064867713416e-16
cost at iteration 432 :  1.422099814012349e-16
cost at iteration 433 :  1.4447021685271393e-16
cost at iteration 434 :  1.4178720608293355e-16
cost at iteration 435 :  1.4405741006118885e-16
cost at iteration 436 :  1.4137193853564876e-16
cost at iteration 437 :  1.4365203623494452e-16
cost at iteration 438 :  1.4096398991436927e-16
cost at iteration 439 :  1.4325390922655888e-16
cost at iteration 440 :  1.4056317717014275e-16
cost at iteration 441 :  1.4286284859186704e-16
cost at iteration 442 :  1.4016932283859603e-16
cost at iteration 443 :  1.4247867938229727e-16
cost at iteration 444 :  1.39782254837456e-16
cost at iteration 445 :  1.4210123194600303e-16
cost at iteration 446 :  1.39401806272653e-16
cost at iteration 447 :  1.4173034173739946e-16
cost at iteration 448 :  1.3902781525259088e-16
cost at iteration 449 :  1.4136584913467572e-16
cost at iteration 450 :  1.3866012471015376e-16
cost at iteration 451 :  1.4100759926488208e-16
cost at iteration 452 :  1.3829858223212996e-16
cost at iteration 453 :  1.4065544183628654e-16
cost at iteration 454 :  1.379430398956676e-16
cost at iteration 455 :  1.4030923097759735e-16
cost at iteration 456 :  1.3759335411142855e-16
cost at iteration 457 :  1.3996882508376524e-16
cost at iteration 458 :  1.3724938547314112e-16
cost at iteration 459 :  1.396340866680421e-16
cost at iteration 460 :  1.3691099861324947e-16
cost at iteration 461 :  1.3930488222001882e-16
cost at iteration 462 :  1.3657806206435908e-16
cost at iteration 463 :  1.3898108206933945e-16
cost at iteration 464 :  1.3625044812623098e-16
cost at iteration 465 :  1.3866256025487857e-16
cost at iteration 466 :  1.3592803273806583e-16
cost at iteration 467 :  1.3834919439907018e-16
cost at iteration 468 :  1.3561069535583205e-16
cost at iteration 469 :  1.3804086558721742e-16
cost at iteration 470 :  1.3529831883441212e-16
cost at iteration 471 :  1.3773745825151326e-16
cost at iteration 472 :  1.349907893143412e-16
cost at iteration 473 :  1.3743886005957414e-16
cost at iteration 474 :  1.3468799611295811e-16
cost at iteration 475 :  1.3714496180731373e-16
cost at iteration 476 :  1.3438983161974717e-16
cost at iteration 477 :  1.368556573159135e-16
cost at iteration 478 :  1.3409619119567746e-16
cost at iteration 479 :  1.3657084333274377e-16
cost at iteration 480 :  1.3380697307642436e-16
cost at iteration 481 :  1.3629041943606675e-16
cost at iteration 482 :  1.3352207827920704e-16
cost at iteration 483 :  1.360142879433397e-16
cost at iteration 484 :  1.3324141051316693e-16
cost at iteration 485 :  1.3574235382296146e-16
cost at iteration 486 :  1.32964876093118e-16
cost at iteration 487 :  1.3547452460933528e-16
cost at iteration 488 :  1.3269238385647673e-16
cost at iteration 489 :  1.3521071032106831e-16
cost at iteration 490 :  1.3242384508328945e-16
cost at iteration 491 :  1.3495082338224614e-16
cost at iteration 492 :  1.3215917341921636e-16
cost at iteration 493 :  1.3469477854654858e-16
cost at iteration 494 :  1.3189828480131914e-16
cost at iteration 495 :  1.3444249282418435e-16
cost at iteration 496 :  1.3164109738655638e-16
cost at iteration 497 :  1.3419388541146818e-16
cost at iteration 498 :  1.3138753148289097e-16
cost at iteration 499 :  1.3394887762295119e-16
cost at iteration 500 :  1.311375094828469e-16
cost at iteration 501 :  1.3370739282600748e-16
cost at iteration 502 :  1.308909557994759e-16
cost at iteration 503 :  1.3346935637774172e-16
cost at iteration 504 :  1.3064779680460892e-16
cost at iteration 505 :  1.3323469556417568e-16
cost at iteration 506 :  1.3040796076926218e-16
cost at iteration 507 :  1.3300333954156525e-16
cost at iteration 508 :  1.3017137780619612e-16
cost at iteration 509 :  1.3277521927980072e-16
cost at iteration 510 :  1.2993797981444341e-16
cost at iteration 511 :  1.325502675077905e-16
cost at iteration 512 :  1.2970770042581722e-16
cost at iteration 513 :  1.3232841866075613e-16
cost at iteration 514 :  1.2948047495323963e-16
cost at iteration 515 :  1.321096088293448e-16
cost at iteration 516 :  1.292562403408696e-16
cost at iteration 517 :  1.3189377571052225e-16
cost at iteration 518 :  1.2903493511595764e-16
cost at iteration 519 :  1.3168085856013067e-16
cost at iteration 520 :  1.2881649934233086e-16
cost at iteration 521 :  1.3147079814708823e-16
cost at iteration 522 :  1.2860087457546496e-16
cost at iteration 523 :  1.3126353670913193e-16
cost at iteration 524 :  1.2838800381906696e-16
cost at iteration 525 :  1.310590179100785e-16
cost at iteration 526 :  1.2817783148315362e-16
cost at iteration 527 :  1.308571867985072e-16
cost at iteration 528 :  1.279703033434887e-16
cost at iteration 529 :  1.3065798976783486e-16
cost at iteration 530 :  1.2776536650240864e-16
cost at iteration 531 :  1.3046137451772954e-16
cost at iteration 532 :  1.2756296935093684e-16
cost at iteration 533 :  1.3026729001679533e-16
cost at iteration 534 :  1.2736306153212519e-16
cost at iteration 535 :  1.3007568646650132e-16
cost at iteration 536 :  1.2716559390565812e-16
cost at iteration 537 :  1.298865152662846e-16
cost at iteration 538 :  1.269705185135456e-16
cost at iteration 539 :  1.2969972897980185e-16
cost at iteration 540 :  1.2677778854697862e-16
cost at iteration 541 :  1.295152813022913e-16
cost at iteration 542 :  1.265873583142391e-16
cost at iteration 543 :  1.293331270289632e-16
cost at iteration 544 :  1.2639918320965438e-16
cost at iteration 545 :  1.2915322202444667e-16
cost at iteration 546 :  1.2621321968353474e-16
cost at iteration 547 :  1.2897552319318193e-16
cost at iteration 548 :  1.260294252130802e-16
cost at iteration 549 :  1.2879998845079134e-16
cost at iteration 550 :  1.2584775827421358e-16
cost at iteration 551 :  1.2862657669634315e-16
cost at iteration 552 :  1.2566817831428189e-16
cost at iteration 553 :  1.2845524778548855e-16
cost at iteration 554 :  1.2549064572565989e-16
cost at iteration 555 :  1.2828596250445807e-16
cost at iteration 556 :  1.2531512182013645e-16
cost at iteration 557 :  1.2811868254488038e-16
cost at iteration 558 :  1.2514156880412188e-16
cost at iteration 559 :  1.2795337047935456e-16
cost at iteration 560 :  1.249699497546324e-16
cost at iteration 561 :  1.277899897378248e-16
cost at iteration 562 :  1.248002285959897e-16
cost at iteration 563 :  1.27628504584653e-16
cost at iteration 564 :  1.2463237007726156e-16
cost at iteration 565 :  1.2746888009641368e-16
cost at iteration 566 :  1.2446633975038954e-16
cost at iteration 567 :  1.2731108214036235e-16
cost at iteration 568 :  1.243021039489777e-16
cost at iteration 569 :  1.2715507735357815e-16
cost at iteration 570 :  1.241396297677179e-16
cost at iteration 571 :  1.2700083312270995e-16
cost at iteration 572 :  1.2397888504245376e-16
cost at iteration 573 :  1.268483175643654e-16
cost at iteration 574 :  1.2381983833084119e-16
cost at iteration 575 :  1.2669749950607084e-16
cost at iteration 576 :  1.2366245889357253e-16
cost at iteration 577 :  1.2654834846782054e-16
cost at iteration 578 :  1.235067166761774e-16
cost at iteration 579 :  1.2640083464415768e-16
cost at iteration 580 :  1.233525822913594e-16
cost at iteration 581 :  1.2625492888679904e-16
cost at iteration 582 :  1.232000270018561e-16
cost at iteration 583 :  1.2611060268777688e-16
cost at iteration 584 :  1.2304902270379337e-16
cost at iteration 585 :  1.2596782816306493e-16
cost at iteration 586 :  1.228995419105487e-16
cost at iteration 587 :  1.2582657803670747e-16
cost at iteration 588 :  1.2275155773705824e-16
cost at iteration 589 :  1.2568682562538482e-16
cost at iteration 590 :  1.2260504388461134e-16
cost at iteration 591 :  1.2554854482345178e-16
cost at iteration 592 :  1.2245997462605804e-16
cost at iteration 593 :  1.2541171008839935e-16
cost at iteration 594 :  1.2231632479145752e-16
cost at iteration 595 :  1.2527629642672564e-16
cost at iteration 596 :  1.2217406975413528e-16
cost at iteration 597 :  1.251422793802465e-16
cost at iteration 598 :  1.220331854171384e-16
cost at iteration 599 :  1.250096350127561e-16

[ ]: