RuntimeWarning:如果self.max_big_small_squared <big * small ** 2,则long_scalars中遇到溢出:

时间:2019-06-21 17:33:36

标签: cvxpy

我正在尝试使用cvxpy在相对较小的数据集上运行整数编程优化模型,并且在尝试解决该问题时遇到以下错误:

  

C:\ Users \ XXXX \ AppData \ Local \ Continuum \ Anaconda3-5.2.0 \ lib \ site-packages \ cvxpy \ problems \ problem.py:791:   RuntimeWarning:如果在long_scalars中遇到溢出   self.max_big_small_squared <大*小** 2:

我怀疑此错误即将到来,因为python将我的目标函数作为int32处理,而也许它应该是int64?像我在目标函数中一样,在获取布尔向量的总和时,似乎int32是默认数据类型。

import cvxpy as cv

#DEFINE THE SELECTION VARIABLE
selection = cv.Variable((113,33),boolean = True)

#DEFINE THE OBJECTIVE FUNCTION
num_columns_true = cv.sum(cv.max(selection, axis = 0))
  #think this is where the issue is coming from

#DEFINE THE CONSTRAINTS
one_true_per_row = cv.sum(selection, axis = 1) == 1
constraints = [one_true_per_row]

#DEFINE THE PROBLEM
problem = cv.Problem(cv.Minimize(num_columns_true), constraints = constraints)

#SOLVE THE PROBLEM
problem.solve(solver=cv.GLPK_MI, verbose = True)

0 个答案:

没有答案