[英]PuLP: Minimizing the standard deviation of decision variables
In an optimization problem developed in PuLP i use the following objective function:在 PuLP 开发的优化问题中,我使用以下目标 function:
objective = p.lpSum(vec[r] for r in range(0,len(vec)))
All variables are non-negative integers, hence the sum over the vector gives the total number of units for my problem.所有变量都是非负整数,因此向量的总和给出了我的问题的单元总数。 Now i am struggling with the fact, that PuLP only gives one of many solutions and i would like to narrow down the solution space to results that favors the solution set with the smallest standard deviation of the decision variables.
现在我正在为这样一个事实而苦苦挣扎,即 PuLP 只给出了众多解决方案中的一个,我想将解决方案空间缩小到有利于决策变量标准差最小的解决方案集的结果。 Eg say
vec
is a vector with elements 6
and 12
.例如,假设
vec
是一个包含元素6
和12
的向量。 Then 7/11, 8/10, 9/9 are equally feasible solutions and i would like PuLP to arrive at 9/9.那么 7/11、8/10、9/9 都是同样可行的解决方案,我希望 PuLP 在 9/9 到达。 Then the objective
那么目标
objective = p.lpSum(vec[r]*vec[r] for r in range(0,len(vec)))
would obviously create a cost function, that would help the case, but alas, it is non-linear and PuLP throws an error.显然会产生成本 function,这将有助于解决这个问题,但遗憾的是,它是非线性的并且 PuLP 会抛出错误。 Anyone who can point me to a potential solution?
谁能指出我可能的解决方案?
Instead of minimizing the standard deviation (which is inherently non-linear), you could minimize the range or bandwidth.您可以最小化范围或带宽,而不是最小化标准偏差(本质上是非线性的)。 Along the lines of:
沿着:
minimize maxv-minv
maxv >= vec[r] for all r
minv <= vec[r] for all r
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.