【问题标题】:Optimizing a cost function subject to second order cone constraints using cvxpy使用 cvxpy 优化受二阶锥约束的成本函数
【发布时间】:2018-07-18 10:59:05
【问题描述】:

我的表单有问题:


X^_JW:


和 delta_R_LV:

地点:

-所有大写的delta和epsilon都是常量

-R_WV 是一个 3,3 旋转矩阵,有 1000 个样本

-R^_LV 是一个 3,3 不变的旋转矩阵

-I是一个3,3旋转矩阵

-Delta_R_LV 是我们希望求解的 3,3 矩阵

-X_JLI 是一个有 1000 个样本的 3,1 向量

-T_LV 是我们希望求解的 3,1 向量

-T_VW 是一个有 1000 个样本的 3,1 向量

-X*_JW 是一个有 1000 个样本的 3,1 向量

我无法理解如何将具有 1000 个样本的 3,3 矩阵拟合成可以进行优化的 2d 形式。我的想法是在最后一个维度上展平,以便得到维度为 1000,9 的矩阵,但我不明白这些矩阵如何在 3,1 向量上运行。

我了解这些示例如何适用于 dim (N,1) 的样本向量,以及如何通过示例将此类内容转换为矩阵:

objective = cp.Minimize(cp.sum_squares(A*x - b))
constraints = [0 <= x, x <= 1]
prob = cp.Problem(objective, constraints)

# The optimal objective value is returned by `prob.solve()`.
result = prob.solve()
# The optimal value for x is stored in `x.value`.
print(x.value)
# The optimal Lagrange multiplier for a constraint is stored in
# `constraint.dual_value`.
print(constraints[0].dual_value)


x = cp.Variable((1275,3))
objective = cp.Minimize(cvx.sum_squares(A*x - b))
constraints = [0 <= x, x <= 1]
prob = cvx.Problem(objective, constraints)

此链接中还有另一个可能更接近我的问题的示例:

http://nbviewer.jupyter.org/github/cvxgrp/cvx_short_course/blob/master/intro/control.ipynb

【问题讨论】:

    标签: python numpy optimization cvxpy


    【解决方案1】:

    您可以尝试对RX 使用numpy 矩阵列表。对于 X (1x3)R (3x3) 和向量 Y (1x3) 的 2 个样本的约束 Sum(R*X) = Y 的更简单示例。这看起来像:

    R = [np.matrix([[1/3, 2/3, 0], [3/4, 1/4, 0 ], [0, 5/6, 1/6]]),
         np.matrix([[0, 2/3, 1/3], [3/4, 1/4, 0 ], [0, 1/6, 5/6]])]
    Y = np.matrix([1, 1, 1])
    
    for i in range(Y.shape[1]):
        constraint += [sum([R[j]*X[t].T for t in range(len(X)) for j in range(len(R))])[i] == Y[0, i]]
    

    【讨论】:

    • 您能详细说明一下吗?我明白你在做什么,但不明白 sum(R*X) 在约束中的位置
    • 我指的是X^_JW 等式约束。我的示例没有复制约束,它只是一个关于如何为模型创建约束的想法。
    • 啊,是的,我现在明白了。我会试一试。
    • 一切顺利。我将不得不仔细研究您的公式,以提出正确的约束。稍后会试一试。编辑了我的答案以便更清楚。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-21
    • 1970-01-01
    • 2019-07-06
    • 2019-08-27
    相关资源
    最近更新 更多