scipy 的线性约束中的问题。人口的所有要素都被拒绝了

Problem in linear constraints of scipy. All the elements of population is getting rejected

我正在使用scipy差异进化。我必须设置以下线性约束。 0

谁能指出哪里出了问题?我的 Scipy 版本是 1.5.4 和 python 3.7.

提前致谢..

您需要将约束设置为:

from scipy.optimize import LinearConstraint

A = np.array([[1.0, 1.0, 1.0, 1.0],
              [0.0, 1.0, 1.0, 0.0]])

lc = LinearConstraint(A, [0, 1], [1, 1])

keep_feasible 关键字将被忽略。为了使约束可行,每个参数的界限必须包含一个可行区域。例如,如果 x2x3 为正数,则 x1x4 之一必须能够访问负值。

在约束最小化中,objective 函数仅被评估 if the trial solution is not feasible

如果满足以下条件,则接受试用解决方案:

    Trial is accepted if:
    * it satisfies all constraints and provides a lower or equal objective
      function value, while both the compared solutions are feasible
    - or -
    * it is feasible while the original solution is infeasible,
    - or -
    * it is infeasible, but provides a lower or equal constraint violation
      for all constraint functions.