我正在学习Bender的分解方法,我想在一个小实例中使用它。我从CPLEX中的“bendersatsp.py”示例开始。当我用我的问题运行这个例子时,我收到以下错误。你能告诉我这是什么问题以及如何解决这个问题吗?在下面您可以看到延迟约束函数中的修改。我在主问题“z_ {ik}”和“u_ {k}”中有两个决策变量,它们将作为常量包含在workerLp中。
class BendersLazyConsCallback(LazyConstraintCallback):
def __call__(self):
print("shoma")
v = self.v
u = self.u
z = self.z
print ("u:", u)
print ("z:", z)
workerLP = self.workerLP
boxty = len(u)
#scenarios=self.scenarios2
ite=len(z)
print ("ite:", ite)
print ("boxty:", boxty)
# Get the current x solution
sol1 = []
sol2 = []
sol3 = []
print("okkkk")
for k in range(1, boxty+1):
sol1.append([])
sol1[k-1]= [self.get_values(u[k-1])];
print ("sol1:", sol1[k-1])
for i in range(1, ite+1):
sol2.append([])
sol2[i-1]= self.get_values(z[i-1]);
print ("sol2:", sol2[i-1])
for i in range(1, ite+1):
sol3.append([])
sol3[i-1]= self.get_values(v[i-1]);
#print ("sol3:", sol3[i-1])
# Benders' cut separation
if workerLP.separate(sol3,sol1,sol2,v,u,z):
self.add(cut = workerLP.cutLhs, sense = "G", rhs = workerLP.cutRhs)
CPLEX错误1006:回调期间出错。
benders(sys.argv [1] [0],datafile)
cpx.solve()
_proc.mipopt(self._env._e,self._lp)
check_status(env,status)
提出callback_exception
TypeError:+:'int'和'list'
的不支持的操作数类型