> For the complete documentation index, see [llms.txt](https://windmising.gitbook.io/lihang-tongjixuexifangfa/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://windmising.gitbook.io/lihang-tongjixuexifangfa/2/5.md).

# 凸二次规划问题求解

要求解的带约束最优化问题为：

$$
\begin{aligned}
min\_{w,b} \quad \frac {1}{2}||w||^2 \\
s.t.  \quad y\_i(w \cdot x\_i + b)-1 \ge 0, i = 1,2,\cdots,N   && {1}
\end{aligned}
$$

将原始问题转换为对偶最优化问题（[推导过程](https://windmising.gitbook.io/lihang-tongjixuexifangfa/svm/6)）：

$$
\begin{aligned}
\min\_a \quad \frac{1}{2}\sum\_{i=1}^N\sum\_{j=1}^Na\_ia\_jy\_iy\_j(x\_i\cdot x\_j) - \sum\_{i=1}^na\_i   \\
s.t. \quad \sum\_{i=1}^Na\_iy\_i = 0 \\
\quad a\_i \ge 0, i = 1,2,\cdots, N && {2}
\end{aligned}
$$

通过公式（2）求解$$a\*$$（[推导过程](/lihang-tongjixuexifangfa/2/5.md)）

通过$$a\*$$求出$$w\*$$和$$b\*$$：

$$
\begin{aligned}
w\* = \sum\_{i=1}^Na\_i^*y\_ix\_i  \\
b* = y\_j - \sum\_{i=1}^Na\_i^\*y\_i(x\_i \cdot x\_j)  && {3}
\end{aligned}
$$

通过公式（3）得到：\
分离超平面：

$$
\sum\_{i=1}^Na\_i^*y\_i(x\cdot x\_i) + b^* = 0
$$

分类决策函数（[推导过程](/lihang-tongjixuexifangfa/2/5.md)）：

$$
f(x) = sign(\sum\_{i=1}^Na\_i^*y\_i(x\cdot x\_i) + b^*)
$$


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://windmising.gitbook.io/lihang-tongjixuexifangfa/2/5.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
