简体   繁体   English

如何有效地去除冗余线性约束进行优化?

[英]How to efficiently remove redundant linear constraints for optimization?

My optimization problem involves thousands of linear constraints. 我的优化问题涉及数千个线性约束。 I want to reduce the complexity of my problem by finding redundant constraints, eg 3 * x + 4 * y < 10 would be redundant if I already have a constraint that is 4 * x + 5 * y < 10 (and x and y are >= 0 , which is the case for my problem). 我想通过找到冗余约束来减少我的问题的复杂性,例如3 * x + 4 * y < 10将是多余的,如果我已经有一个4 * x + 5 * y < 10的约束(并且xy>= 0 ,这是我的问题)。

So, I have a numpy array that holds all the coefficients, and it looks like this, for example: 所以,我有一个包含所有系数的numpy数组,它看起来像这样,例如:

[[0.1, 3.0, 4.8, 0.2],
 [1.0, 4.7, 5.3, 0.1],
 [2.2, 4.3, 5.2, 1.1]]

representing the constraints: 代表约束:

0.1 * w + 3.0 * x + 4.8 * y + 0.2 * z < 10
1.0 * w + 4.7 * x + 5.3 * y + 0.1 * z < 10
2.2 * w + 4.3 * x + 5.2 * y + 1.1 * z < 10

How do I efficiently find out which one are redundant? 如何有效地找出哪一个是多余的?

My common sense tells me to do a loop (pseudo-codeish): 我的常识告诉我做一个循环(伪代码):

for i, row1 in enumerate(array):
    for j, row2 in enumerate(array):
        if j > i:
            if all(row1 > row2):
                delete row

But this slow for thousands of constraints. 但这对于成千上万的限制来说很慢。 Any way to speed it up? 有什么方法可以加快速度吗?

You can think of each constraint as a hyperplane, intercepting each axis at (sum constraint constant) / (coefficient for that axis); 您可以将每个约束视为超平面,在(和约束常数)/(该轴的系数)处拦截每个轴; if the coefficient is 0, the hyperplane is parallel to that axis (== "intercepts at infinity"). 如果系数为0,则超平面与该轴平行(==“在无穷远处截取”)。

Trivially, if the axis-intercepts for one hyperplane are all equal to or greater than the corresponding intercepts for another, that hyperplane is redundant. 平凡地说,如果一个超平面的轴截距都等于或大于另一个超平面的相应截距,则该超平面是冗余的。

In order to cull as many constraints as early as possible, you want to start by comparing against ones whose hyperplane is (a) as close to the origin as possible and (b) parallel to as few axes as possible, as it can only cull other hyperplanes also parallel to that axis. 为了尽可能早地剔除多个约束,你想要首先比较超平面(a)尽可能接近原点并且(b)平行于尽可能少的轴,因为它只能剔除其他超平面也与该轴平行。 [A hyperplane not parallel to a given axis may be able to cull one parallel to that axis, but the inverse is never true.] [不平行于给定轴的超平面可能能够剔除与该轴平行的一个,但反之则永远不会成立。]

I suggest you sort the list by (number of axis-parallel axes) then (sum of non-infinite axis intercepts). 我建议你按(轴平行轴的数量)然后(非无限轴截距的总和)对列表进行排序。

I think for speed up this problem you can use backtracking for ex you can check out coefficients in arrays one by one ! 我认为为了加快这个问题你可以使用backtracking ,你可以逐个检查数组中的系数! if you find an index that is less than other index you can stop checking and delete the row ! 如果您发现索引小于其他索引,则可以停止检查并删除该行!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM