When solving your SVM problem, you'll be optimizing a Lagrangian subject to KKT conditions. Specifically, something like:
$$L(x)=f(x)-\sum_k \lambda_k c_k(x),$$
where your constraint satisfies $c_k(x)\geq 0$ and $\lambda_k\geq 0$. The optimum is achieved when the gradient of the above lagrangian is equal to 0 and $\lambda_i\geq 0$ and $\lambda_i c_i(x)=0$ for all $i$. Specifically, when $\lambda_i\neq 0$, the constraint is said to active, whereas if $\lambda_i=0$, then you can freely move out of the constraint region while preserving the optimum. This is why we demand $\lambda_i>0$.
The CVXOPT software solves quadratic programs of the form
$$
\begin{array}{rl}
\min\ & \frac{1}{2}x^TPx+q^Tx \\
\text{s.t.}\ & Gx\leq h \\
& Ax=b
\end{array}
$$
The problem you wish to solve is
$$
\begin{array}{rl}
\max\ & \sum_i\alpha_i-\frac{1}{2}\big\|\sum_i\alpha_iy_ix_i\big\|^2 \\
\text{s.t.} & -\alpha_i\leq0\text{ for all }i \\
& \alpha_i\leq{C}\text{ for all }i \\
& \sum_iy_i\alpha_i=0
\end{array}
$$
I'm assuming here $x_i\in\mathbb{R}^d$ are vectors and $y_i\in\mathbb{R}$ are scalars for $i=1,\dots,n$.
Objective Function
Let's look at the expression
$$\bigg\|\sum_i\alpha_iy_ix_i\bigg\|^2.$$
Let's define the vector $z_i=y_ix_i$ for all $i=1,\dots,n$. Define the matrix $Z\in\mathbb{R}^{d\times{n}}$ to be the matrix whose $i^\text{th}$ column is $z_i$. Then the expression above can be written as
$$
\|Z\alpha\|^2=\alpha^TZ^TZ\alpha
$$
where $\alpha\in\mathbb{R}^n$ is the vector of $\alpha_i$ variables, and we are using the two norm.
Hence our objective function is
$$\max\ \sum_i\alpha_i-\frac{1}{2}\bigg\|\sum_i\alpha_iy_ix_i\bigg\|^2=\max\ -\frac{1}{2}\alpha^TZ^TZ\alpha+\mathbf{1}^T\alpha=\min\ \frac{1}{2}\alpha^TZ^TZ\alpha-\mathbf{1}^T\alpha$$
where $\mathbf{1}$ is the vector of all ones. This is exactly the form required by CVXOPT: take $P=Z^TZ$ and $q=-\mathbf{1}$.
Inequality Constraints
The constraints $-\alpha_i\leq0$ can be written as
$$
-I\alpha\leq\mathbf{0}
$$
where $I$ is the $n\times{n}$ identity matrix, and $\mathbf{0}$ is the zero vector. Similarly, the constraints $\alpha_i\leq{C}$ can be written in matrix form as
$$
I\alpha\leq C\mathbf{1}.
$$
If we stack these two matrix systems on top of each other, then our inequality constraints can be summarized as
$$
\begin{bmatrix}-I\\I\end{bmatrix}\alpha\leq\begin{bmatrix}\mathbf{0}\\C\mathbf{1}\end{bmatrix}.
$$
This is the form required by CVXOPT: take
$$
G=\begin{bmatrix}-I\\I\end{bmatrix},\ h=\begin{bmatrix}\mathbf{0}\\C\mathbf{1}\end{bmatrix}.
$$
Equality Constraints
I think you can take it from here.
Once you have all these matrices and vectors created, just pass them to solvers.qp()
and you should be good to go.
Best Answer
Your formulation is right for linear separable case. For cases that no hyper-planes can separate training data perfectly, slack variables are compulsory.
Indeed we can get the offset from any of the support vectors based on complementary slackness. For practical concern, we usually take the average on all support vectors for better numerical stability, e.g. $$ \theta_0 = \frac{1}{N_{\mathcal{S}}}\sum_{t \in \mathcal{S}} \left( y^{(t)} - \sum_{t'=1}^{n}\alpha_t y^{(t')}x^{(t')^\intercal}x^{(t)} \right) $$