[Math] Gradient descent and penalty method

gradient descentnumerical optimizationoptimization

I am seeking a minimum of a function under an inequality constraint. How can I set stop condition? The problem is that $\nabla f_p$ never goes to zero. The function:

$$f(x_1, x_2)=\left(x_1 – 1\right)^2 + 2\left(x_2 – 2\right)^2$$

The constraint

$$g(x_1,x_2)=x_1^2 + x_2^2-1\leq 0$$

Objective function (with penalty method):

$$f_p(x_1,x_2)=\left(x_1 – 1\right)^2 + 2\left(x_2 – 2\right)^2+\mu\left(\max\left\{ x_1^2 + x_2^2-1, 0\right\}\right)^2$$

Its gradient (outside valid domain):
$$\nabla f_p=\left(2\left(x_1 -1\right)+4\mu x_1^3\right)\widehat{x_1}
+ \left(4\left(x_2 – 2\right) + 4\mu x_2^3\right) \widehat{x_2}$$

Its gradient (inside valid domain):
$$\nabla f_p=2\left(x_1 -1\right)\widehat{x_1}
+4\left(x_2 – 2\right) \widehat{x_2}$$

It appears that $|\nabla f_p|$ oscillates around a value greater than one so testing $|\nabla f_p|$ does not work, or are the conditional derivatives wrong?

Best Answer

You calculated the gradient wrong (outside valid domain). Check your derivative of the penalty function. The partial derivative of

$$\max(x_1^2+x_2^2-1,0)^2$$

wrt $x_1$ is not

$$4 x_1^3.$$

Rather, it should be

$$4 x_1 (x_1^2+x_2^2-1)$$

(when outside the valid domain).

Related Question