和顺 / 衡律 返回所属 Agent
14.4

凸二次配置的确定性求解

原能力

实现规定的凸二次配置求解,核对解状态、约束残差及不可行原因。(合同附件 R7 14.4)

首选项目

CVXPY(Apache-2.0)。 CVXPY

匹配范围

quad_form、Problem 和求解器状态用于凸二次问题。

源码

CVXPY · def quad_form(

cvxpy/atoms/quad_form.py · 290–303 行。 在 GitHub 查看源码 · 许可证与声明

源码片段
def quad_form(x, P, assume_PSD: bool = False) -> Expression:
    """Alias for :math:`x^T P x`.

    Parameters
    ----------
    x : vector argument.
    P : matrix argument.
    assume_PSD : P is assumed to be PSD without checking.

    Notes
    -----
    When ``P`` is a ``Parameter`` declared PSD or NSD and the solver supports
    quadratic objectives, ``quad_form(x, P)`` can participate in a DPP solve,
    so repeated solves can reuse cached compilation data.
  • Copyright 2013 Steven Diamond, 2017 Robin Verschueren

CVXPY · class Problem

cvxpy/problems/problem.py · 135–148 行。 在 GitHub 查看源码 · 许可证与声明

源码片段
class Problem(u.Canonical):
    """A convex optimization problem.

    Problems are immutable, save for modification through the specification
    of :class:`~cvxpy.expressions.constants.parameters.Parameter`

    Arguments
    ---------
    objective : Minimize or Maximize
        The problem's objective.
    constraints : iterable
        The constraints on the problem variables.
    """
  • Copyright 2013 Steven Diamond, 2017 Akshay Agrawal
接口用法示意
objective = cp.Minimize(cp.quad_form(weights, covariance)); value = cp.Problem(objective, constraints).solve()

实现与验收要点

固定求解器、数据、确定性和原容差。