<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Computation of cutting planes
Step1:  $\DeclareMathOperator{\domain}{dom}
\newcommand{\transpose}{\text{T}}
\newcommand{\vec}[1]{\begin{pmatrix}#1\end{pmatrix}}$
Example
To test the computation of cutting planes we consider the unconstrained convex optimization problem
\begin{align}
    &\text{minimize} \quad f_\text{obj}(x_0, x_1) = (x_0 - 5)^2 + (x_1 - 5)^2,
\end{align}
and also the same problem with inequality constraints convex. That is, the problem
\begin{align}
    &\text{minimize} \quad f_\text{obj}(x_0, x_1) = (x_0 - 5)^2 + (x_1 - 5)^2 \
    &\phantom{\text{minimize}} \quad f_0(x_0, x_1) = 
    a_0^\transpose x - b_0 = \vec{1\0}^\transpose \vec{x_0\x_1} - 20 = x_0 - 20 \leq 0\
    &\phantom{\text{minimize}} \quad f_1(x_0, x_1) =
    a_1^\transpose x - b_1 = \vec{-1\0}^\transpose \vec{x_0\x_1} = -x_0 \leq 0\
    &\phantom{\text{minimize}} \quad f_2(x_0, x_1) =
    a_2^\transpose x - b_2 = \vec{0\1}^\transpose \vec{x_0\x_1} - 20 = x_1 - 20 \leq 0 \
    &\phantom{\text{minimize}} \quad f_3(x_0, x_1) = 
    a_3^\transpose x - b_3 = \vec{0\-1}^\transpose \vec{x_0\x_1} = -x_1 \leq 0.
\end{align}
In both cases it is clear that the solution is $x^\star = (x_1^\star, x_2^\star) = (5, 5)$. 
The ACCPM requires the gradients of the objective function and constraint functions, which are 
\begin{align}
    &\nabla f_\text{obj}(x_0, x_1) = \vec{2(x_0 - 5)\2(x_1 - 5)}, \
    &\nabla f_0(x_0, x_1) = \vec{1\0}, \quad \nabla f_1(x_0, x_1) = \vec{-1\0}, \
    &\nabla f_2(x_0, x_1) = \vec{0\1}, \quad \nabla f_3(x_0, x_1) = \vec{0\-1}.
\end{align}
We implement these functions as follows
Step2:  Here we analytically compute the initial few iterations for the unconstrained problem. The ACCPM requires that the initial polygon $\mathcal{P}_0$ (here I've abused terminology and by the initial polygon $\mathcal{P}_0$ I actually mean the system of linear inequalities $Ax \leq b$) contain at least some of the points we are interested in. For the purposes of this example we take
\begin{align}
    A = \vec{a_0^\transpose\a_1^\transpose\a_2^\transpose\a_3^\transpose}, b = \vec{20\0\20\0}.
\end{align}
Now, we start with $k=0$.
Now, $x^{(0)}{ac}$ is the solution of the minimization problem 
\begin{equation}
    \min_{\domain \phi} \phi(x) = - \sum_{i=0}^{3}{\log{(b_i - a_i^\transpose x)}}.
\end{equation}
So, we solve the problem
\begin{align}
    &\phantom{iff}\nabla \phi(x) = \sum_{i=0}^{3
    } \frac{1}{b_i - a_i^\transpose x}a_i = 0 \
    &\iff \frac{1}{20-x_0}\begin{bmatrix}1\0\end{bmatrix} + \frac{1}{x_0}\begin{bmatrix}-1\0\end{bmatrix} + \frac{1}{20-x_1}\begin{bmatrix}0\1\end{bmatrix} + \frac{1}{x_1}\begin{bmatrix}0\-1\end{bmatrix} = 0 \
    &\iff \frac{1}{20-x_0} - \frac{1}{x_0} = 0, \frac{1}{20-x_1} - \frac{1}{x_1} = 0 \
    &\iff x_0 = \frac{20}{2} = 10, x_1 = \frac{20}{2} = 10,
\end{align}
and conclude $x^{(0)}{ac} = (10, 10)$. We then query the oracle at $x^{(0)}{ac}$. (Here, $f\text{best} = f_\text{obj}(10, 10) = 50$ since this is the $0$-th iteration.) As there are no inequality constraints we have
\begin{align}
    &a_4 = \nabla f_\text{obj}(10, 10) = \vec{10\10}, \
    &b_4 = \nabla f_\text{obj}(10, 10)^\transpose \vec{10\10} = \vec{10\10}^\transpose \vec{10\10} = 200,
\end{align}
which we normalize to get
\begin{align}
    &a_4 =  \frac{1}{\sqrt{100^2 + 100^2}} \nabla f_\text{obj}(10, 10) 
         = \vec{\frac{1}{\sqrt{2}} \ \frac{1}{\sqrt{2}} } \approx \vec{0.7071 \ 0.7071}, \
    &b_4 = \frac{1}{\sqrt{100^2 + 100^2}} \nabla f_\text{obj}(10, 10)^\transpose \vec{10\10} = \vec{10\10}^\transpose \vec{10\10} = \frac{20}{\sqrt{2}} = 10\sqrt{2} \approx 14.1421,
\end{align}
and therefore update
\begin{align}
    A = \vec{a_0^\transpose\a_1^\transpose\a_2^\transpose\a_3^\transpose\ \frac{1}{\sqrt{2}} \;\; \frac{1}{\sqrt{2}}}, b = \vec{20\0\20\0\10\sqrt{2}}, k = 1.
\end{align}
Now, $x^{(1)}{ac}$ is the solution of the minimization problem 
\begin{equation}
    \min_{\domain \phi} \phi(x) = - \sum_{i=0}^{4}{\log{(b_i - a_i^\transpose x)}}.
\end{equation}
So, we solve the problem
\begin{align}
    &\phantom{iff}\nabla \phi(x) = \sum_{i=0}^{4
    } \frac{1}{b_i - a_i^\transpose x}a_i = 0 \
    &\iff \frac{1}{20-x_0}\vec{1\0} + \frac{1}{x_0}\vec{-1\0} + \frac{1}{20-x_1}\vec{0\1} + \frac{1}{x_1}\vec{0\-1} + \frac{\sqrt{2}}{20-x_0-x_1} \vec{\frac{1}{\sqrt{2}}\\frac{1}{\sqrt{2}}} = 0\
    &\iff \frac{1}{20-x_0} - \frac{1}{x_0} + \frac{1}{20 - x_0- x_1}= 0, \frac{1}{20-x_1} - \frac{1}{x_1} + \frac{1}{20 - x_0- x_1} = 0 \
    &\iff x_0 = x_1 = 2(5 \pm \sqrt{5}) \approx 14.4721 \text{ or } 5.52786,
\end{align}
and take $x^{(1)}{ac} = (2(5-\sqrt{5}), 2(5-\sqrt{5})) \approx (5.52786, 5.52786)$. We then query the
oracle at $x^{(1)}{ac}$. Here 
$f\text{obj}(x^{(1)}{ac}) = f\text{obj}(2(5-\sqrt{5}), 2(5-\sqrt{5})) = 90 - 40\sqrt{5} \approx 0.557281 \leq f_\text{best} = 50$ so we update 
$f_\text{best} = 90 - 40\sqrt{5} \approx 0.557281$ and therefore put (and normalize)
\begin{align}
    &a_5 = \frac{1}{\sqrt{2(10-4\sqrt{5})^2}} \nabla f_\text{obj}(x^{(1)}{ac}) = 
           \frac{1}{\sqrt{2(10-4\sqrt{5})^2}} \nabla f\text{obj}\vec{2(5-\sqrt{5}) \ 2(5-\sqrt{5})} =
           \frac{1}{\sqrt{2(10-4\sqrt{5})^2}} \vec{10-4\sqrt{5}\10-4\sqrt{5}}
           = \vec{\frac{1}{\sqrt{2}}\\frac{1}{\sqrt{2}}}\approx \vec{0.7071 \ 0.7071}, \
    &b_5 = \frac{1}{\sqrt{2(10-4\sqrt{5})^2}} \nabla f_\text{obj}(x^{(1)}_{ac})^\transpose \vec{2(5-\sqrt{5}) \ 2(5-\sqrt{5})} = 
           \frac{1}{\sqrt{2}} \vec{1\1}^\transpose \vec{2(5-\sqrt{5}) \ 2(5-\sqrt{5})} = 2\sqrt{2} (5 - \sqrt{5})
           \approx 7.8176,
\end{align}
updating $A$ and $b$ also. Iteration $k = 1$ is concluded by incrementing $k$. 
We see that this computation will only get more complicated. Therefore, in our implementation we test the computed analytic center by simply computing the norm of the gradient of the log barrier at the analytic center and see if it sufficiently small.
We first test the unconstrained version of the problem.
Step3:  Next we test a trivial version of the inequality constrained problem where the inequality constraints and linear inequality constraints are the same
Step4:  Next we test a version of the inequality constrained problem where the initial polygon lies within the feasible region given by the inequality constraints.
Step5:  We now test a version of the inequality constrained problem where the initial polyhedron contains the feasible region but also regions that are infeasible.
Step6:  We test a version of the inequality constrained problem where the initial polyhedron is moderately large.
Step7:  Finally we test a version of the inequality constrained problem where the initial polyhedron is very large. We observe that the algorithm does not converge. 
It is possible more iterations, or pruning of the redundant inequalities, would allow for convergence, but in practice, it is unlikely this situation will arise.
<ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
import accpm
%load_ext autoreload
%autoreload 1
%aimport accpm
Explanation: Computation of cutting planes: example 1
The set-up
End of explanation
def funcobj(x):
    return (x[0]-5)**2 + (x[1]-5)**2
    
def func0(x):
    return x[0] - 20
def func1(x):
    return -x[0]
    
def func2(x):
    return x[1] - 20
    
def func3(x):
    return -x[1]
def grad_funcobj(x):
    return np.array([2*(x[0] - 5), 2*(x[1] - 5)])
def grad_func0(x):
    return np.array([1, 0])
def grad_func1(x):
    return np.array([-1, 0])
def grad_func2(x):
    return np.array([0, 1])
    
def grad_func3(x):
    return np.array([0, -1])
Explanation: $\DeclareMathOperator{\domain}{dom}
\newcommand{\transpose}{\text{T}}
\newcommand{\vec}[1]{\begin{pmatrix}#1\end{pmatrix}}$
Example
To test the computation of cutting planes we consider the unconstrained convex optimization problem
\begin{align}
    &\text{minimize} \quad f_\text{obj}(x_0, x_1) = (x_0 - 5)^2 + (x_1 - 5)^2,
\end{align}
and also the same problem with inequality constraints convex. That is, the problem
\begin{align}
    &\text{minimize} \quad f_\text{obj}(x_0, x_1) = (x_0 - 5)^2 + (x_1 - 5)^2 \
    &\phantom{\text{minimize}} \quad f_0(x_0, x_1) = 
    a_0^\transpose x - b_0 = \vec{1\0}^\transpose \vec{x_0\x_1} - 20 = x_0 - 20 \leq 0\
    &\phantom{\text{minimize}} \quad f_1(x_0, x_1) =
    a_1^\transpose x - b_1 = \vec{-1\0}^\transpose \vec{x_0\x_1} = -x_0 \leq 0\
    &\phantom{\text{minimize}} \quad f_2(x_0, x_1) =
    a_2^\transpose x - b_2 = \vec{0\1}^\transpose \vec{x_0\x_1} - 20 = x_1 - 20 \leq 0 \
    &\phantom{\text{minimize}} \quad f_3(x_0, x_1) = 
    a_3^\transpose x - b_3 = \vec{0\-1}^\transpose \vec{x_0\x_1} = -x_1 \leq 0.
\end{align}
In both cases it is clear that the solution is $x^\star = (x_1^\star, x_2^\star) = (5, 5)$. 
The ACCPM requires the gradients of the objective function and constraint functions, which are 
\begin{align}
    &\nabla f_\text{obj}(x_0, x_1) = \vec{2(x_0 - 5)\2(x_1 - 5)}, \
    &\nabla f_0(x_0, x_1) = \vec{1\0}, \quad \nabla f_1(x_0, x_1) = \vec{-1\0}, \
    &\nabla f_2(x_0, x_1) = \vec{0\1}, \quad \nabla f_3(x_0, x_1) = \vec{0\-1}.
\end{align}
We implement these functions as follows:
End of explanation
A = np.array([[1, 0],[-1,0],[0,1],[0,-1]])
b = np.array([20, 0, 20, 0])
accpm.accpm(A, b, funcobj, grad_funcobj, alpha=0.01, beta=0.7, 
            start=1, tol=10e-3, maxiter = 200, testing=1)
Explanation: Here we analytically compute the initial few iterations for the unconstrained problem. The ACCPM requires that the initial polygon $\mathcal{P}_0$ (here I've abused terminology and by the initial polygon $\mathcal{P}_0$ I actually mean the system of linear inequalities $Ax \leq b$) contain at least some of the points we are interested in. For the purposes of this example we take
\begin{align}
    A = \vec{a_0^\transpose\a_1^\transpose\a_2^\transpose\a_3^\transpose}, b = \vec{20\0\20\0}.
\end{align}
Now, we start with $k=0$.
Now, $x^{(0)}{ac}$ is the solution of the minimization problem 
\begin{equation}
    \min_{\domain \phi} \phi(x) = - \sum_{i=0}^{3}{\log{(b_i - a_i^\transpose x)}}.
\end{equation}
So, we solve the problem
\begin{align}
    &\phantom{iff}\nabla \phi(x) = \sum_{i=0}^{3
    } \frac{1}{b_i - a_i^\transpose x}a_i = 0 \
    &\iff \frac{1}{20-x_0}\begin{bmatrix}1\0\end{bmatrix} + \frac{1}{x_0}\begin{bmatrix}-1\0\end{bmatrix} + \frac{1}{20-x_1}\begin{bmatrix}0\1\end{bmatrix} + \frac{1}{x_1}\begin{bmatrix}0\-1\end{bmatrix} = 0 \
    &\iff \frac{1}{20-x_0} - \frac{1}{x_0} = 0, \frac{1}{20-x_1} - \frac{1}{x_1} = 0 \
    &\iff x_0 = \frac{20}{2} = 10, x_1 = \frac{20}{2} = 10,
\end{align}
and conclude $x^{(0)}{ac} = (10, 10)$. We then query the oracle at $x^{(0)}{ac}$. (Here, $f\text{best} = f_\text{obj}(10, 10) = 50$ since this is the $0$-th iteration.) As there are no inequality constraints we have
\begin{align}
    &a_4 = \nabla f_\text{obj}(10, 10) = \vec{10\10}, \
    &b_4 = \nabla f_\text{obj}(10, 10)^\transpose \vec{10\10} = \vec{10\10}^\transpose \vec{10\10} = 200,
\end{align}
which we normalize to get
\begin{align}
    &a_4 =  \frac{1}{\sqrt{100^2 + 100^2}} \nabla f_\text{obj}(10, 10) 
         = \vec{\frac{1}{\sqrt{2}} \ \frac{1}{\sqrt{2}} } \approx \vec{0.7071 \ 0.7071}, \
    &b_4 = \frac{1}{\sqrt{100^2 + 100^2}} \nabla f_\text{obj}(10, 10)^\transpose \vec{10\10} = \vec{10\10}^\transpose \vec{10\10} = \frac{20}{\sqrt{2}} = 10\sqrt{2} \approx 14.1421,
\end{align}
and therefore update
\begin{align}
    A = \vec{a_0^\transpose\a_1^\transpose\a_2^\transpose\a_3^\transpose\ \frac{1}{\sqrt{2}} \;\; \frac{1}{\sqrt{2}}}, b = \vec{20\0\20\0\10\sqrt{2}}, k = 1.
\end{align}
Now, $x^{(1)}{ac}$ is the solution of the minimization problem 
\begin{equation}
    \min_{\domain \phi} \phi(x) = - \sum_{i=0}^{4}{\log{(b_i - a_i^\transpose x)}}.
\end{equation}
So, we solve the problem
\begin{align}
    &\phantom{iff}\nabla \phi(x) = \sum_{i=0}^{4
    } \frac{1}{b_i - a_i^\transpose x}a_i = 0 \
    &\iff \frac{1}{20-x_0}\vec{1\0} + \frac{1}{x_0}\vec{-1\0} + \frac{1}{20-x_1}\vec{0\1} + \frac{1}{x_1}\vec{0\-1} + \frac{\sqrt{2}}{20-x_0-x_1} \vec{\frac{1}{\sqrt{2}}\\frac{1}{\sqrt{2}}} = 0\
    &\iff \frac{1}{20-x_0} - \frac{1}{x_0} + \frac{1}{20 - x_0- x_1}= 0, \frac{1}{20-x_1} - \frac{1}{x_1} + \frac{1}{20 - x_0- x_1} = 0 \
    &\iff x_0 = x_1 = 2(5 \pm \sqrt{5}) \approx 14.4721 \text{ or } 5.52786,
\end{align}
and take $x^{(1)}{ac} = (2(5-\sqrt{5}), 2(5-\sqrt{5})) \approx (5.52786, 5.52786)$. We then query the
oracle at $x^{(1)}{ac}$. Here 
$f\text{obj}(x^{(1)}{ac}) = f\text{obj}(2(5-\sqrt{5}), 2(5-\sqrt{5})) = 90 - 40\sqrt{5} \approx 0.557281 \leq f_\text{best} = 50$ so we update 
$f_\text{best} = 90 - 40\sqrt{5} \approx 0.557281$ and therefore put (and normalize)
\begin{align}
    &a_5 = \frac{1}{\sqrt{2(10-4\sqrt{5})^2}} \nabla f_\text{obj}(x^{(1)}{ac}) = 
           \frac{1}{\sqrt{2(10-4\sqrt{5})^2}} \nabla f\text{obj}\vec{2(5-\sqrt{5}) \ 2(5-\sqrt{5})} =
           \frac{1}{\sqrt{2(10-4\sqrt{5})^2}} \vec{10-4\sqrt{5}\10-4\sqrt{5}}
           = \vec{\frac{1}{\sqrt{2}}\\frac{1}{\sqrt{2}}}\approx \vec{0.7071 \ 0.7071}, \
    &b_5 = \frac{1}{\sqrt{2(10-4\sqrt{5})^2}} \nabla f_\text{obj}(x^{(1)}_{ac})^\transpose \vec{2(5-\sqrt{5}) \ 2(5-\sqrt{5})} = 
           \frac{1}{\sqrt{2}} \vec{1\1}^\transpose \vec{2(5-\sqrt{5}) \ 2(5-\sqrt{5})} = 2\sqrt{2} (5 - \sqrt{5})
           \approx 7.8176,
\end{align}
updating $A$ and $b$ also. Iteration $k = 1$ is concluded by incrementing $k$. 
We see that this computation will only get more complicated. Therefore, in our implementation we test the computed analytic center by simply computing the norm of the gradient of the log barrier at the analytic center and see if it sufficiently small.
We first test the unconstrained version of the problem.
End of explanation
A = np.array([[1, 0],[-1,0],[0,1],[0,-1]])
b = np.array([20, 0, 20, 0])
accpm.accpm(A, b, funcobj, grad_funcobj,
           (func0, func1, func2, func3), (grad_func0, grad_func1, grad_func2, grad_func3),
            alpha=0.01, beta=0.7, start=1, tol=10e-3, maxiter=200, testing=True)
Explanation: Next we test a trivial version of the inequality constrained problem where the inequality constraints and linear inequality constraints are the same
End of explanation
A = np.array([[1, 0],[-1,0],[0,1],[0,-1]])
b = np.array([5, 0, 5, 0])
accpm.accpm(A, b, funcobj, grad_funcobj,
           (func0, func1, func2, func3), (grad_func0, grad_func1, grad_func2, grad_func3),
            alpha=0.01, beta=0.7, start=1, tol=10e-3, maxiter=200, testing=True)
Explanation: Next we test a version of the inequality constrained problem where the initial polygon lies within the feasible region given by the inequality constraints.
End of explanation
A = np.array([[1, 0],[-1,0],[0,1],[0,-1]])
b = np.array([30, 0, 30, 0])
accpm.accpm(A, b, funcobj, grad_funcobj,
           (func0, func1, func2, func3), (grad_func0, grad_func1, grad_func2, grad_func3),
            alpha=0.01, beta=0.7, start=1, tol=10e-3, maxiter=200, testing=True)
Explanation: We now test a version of the inequality constrained problem where the initial polyhedron contains the feasible region but also regions that are infeasible.
End of explanation
A = np.array([[1, 0],[-1,0],[0,1],[0,-1]])
b = np.array([100, 0, 100, 0])
accpm.accpm(A, b, funcobj, grad_funcobj,
           (func0, func1, func2, func3), (grad_func0, grad_func1, grad_func2, grad_func3),
            alpha=0.01, beta=0.7, start=1, tol=10e-3, maxiter=200, testing=True)
Explanation: We test a version of the inequality constrained problem where the initial polyhedron is moderately large.
End of explanation
A = np.array([[1, 0],[-1,0],[0,1],[0,-1]])
b = np.array([1000, 0, 1000, 0])
accpm.accpm(A, b, funcobj, grad_funcobj,
           (func0, func1, func2, func3), (grad_func0, grad_func1, grad_func2, grad_func3),
            alpha=0.01, beta=0.7, start=1, tol=10e-3, maxiter=200, testing=True)
A = np.array([[1, 0],[-1,0],[0,1],[0,-1]])
b = np.array([1000, 0, 1000, 0])
accpm.accpm(A, b, funcobj, grad_funcobj,
           (func0, func1, func2, func3), (grad_func0, grad_func1, grad_func2, grad_func3),
            alpha=0.01, beta=0.7, start=1, tol=10e-3, maxiter=500, testing=True)
Explanation: Finally we test a version of the inequality constrained problem where the initial polyhedron is very large. We observe that the algorithm does not converge. 
It is possible more iterations, or pruning of the redundant inequalities, would allow for convergence, but in practice, it is unlikely this situation will arise.
End of explanation
<END_TASK>