我在项目中使用PuLP,所有测试都在我的本地机器上传递。但所有涉及PuLP的测试在Travis CI 运行时都会失败。
这是一个失败的例子:
=================================== FAILURES ===================================
___________________________ test_scipy_sparse_matrix ___________________________
def test_scipy_sparse_matrix():
cluster_object = MaxPRegionsExact()
cluster_object.fit_from_scipy_sparse_matrix(adj, attr,
spatially_extensive_attr,
> threshold=threshold)
region/max_p_regions/tests/test_exact.py:23:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
region/max_p_regions/exact.py:153: in fit_from_scipy_sparse_matrix
prob.solve(solver)
../../../virtualenv/python3.4.6/lib/python3.4/site-packages/pulp/pulp.py:1664: in solve
status = solver.actualSolve(self, **kwargs)
../../../virtualenv/python3.4.6/lib/python3.4/site-packages/pulp/solvers.py:1362: in actualSolve
return self.solve_CBC(lp, **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <pulp.solvers.COIN_CMD object at 0x7ff3e76ba9b0>
lp = Max-p-Regions:
MINIMIZE
50.29999999999968*t_(0,_1) + 80.59999999999991*t_(0,_2) + 140.19999999999993*t_(0,_3) + 60.699... <= x_(8,_8,_5) <= 1 Integer
0 <= x_(8,_8,_6) <= 1 Integer
0 <= x_(8,_8,_7) <= 1 Integer
0 <= x_(8,_8,_8) <= 1 Integer
use_mps = True
def solve_CBC(self, lp, use_mps=True):
"""Solve a MIP problem using CBC"""
if not self.executable(self.path):
raise PulpSolverError("Pulp: cannot execute %s cwd: %s"%(self.path,
> os.getcwd()))
E pulp.solvers.PulpSolverError: Pulp: cannot execute cbc cwd: /home/travis/build/yogabonito/region
../../../virtualenv/python3.4.6/lib/python3.4/site-packages/pulp/solvers.py:1372: PulpSolverError
----------------------------- Captured stdout call -----------------------------
start solving with <pulp.solvers.COIN_CMD object at 0x7ff3e76ba9b0>
看起来Travis无法找到CBC CMD求解器,尽管根据PuLP-docs它是"included" / "bundled with pulp"。 (在我的本地机器上,我没有必要安装CBC CMD解算器。它是自动安装的PuLP。)
我的问题是:如何让Travis CI找到解算器?同样有趣的是:为什么我使用Travis CI出现问题?
答案 0 :(得分:0)
当您通过pip安装时,纸浆会自动安装一个版本的cbc。我怀疑travis环境不喜欢这种快捷安装方式。 通过ssh检查cbc可执行文件是否具有执行权限,如果你不能这样做的话。
1)在travis apt-get install coinor-cbc
2)使用&#39; COIN_CMD&#39;解决者来解决问题
斯图