我尝试使用Pulp和CoinMP.dll设置一个简单的环境来解决线性编程问题。我不能让它发挥作用。有人可以帮忙吗?
当我尝试在这里运行测试的第一件事是我有
Solver pulp.solvers.PULP_CBC_CMD不可用。求解 pulp.solvers.CPLEX_DLL不可用。 Solver pulp.solvers.CPLEX_CMD 不可用。 Solver pulp.solvers.CPLEX_PY不可用。
Solver pulp.solvers.COIN_CMD unavailable. Testing zero subtraction Testing continuous LP solution Testing maximize continuous LP solution Testing unbounded continuous LP solution Error in CoinMP it reports Optimal Testing Long Names Testing repeated Names Traceback (most recent call last): File "<stdin>", line 1, in <module> File "D:\Portable Python 2.7.5.1\app\lib\site-packages\pulp-1.5.4-py2.7.egg\pulp\pulp.py", line 2235, in pulpTestAll pulpTestSolver(s) File "D:\Portable Python 2.7.5.1\app\lib\site-packages\pulp-1.5.4-py2.7.egg\pulp\tests.py", line 560, in pulpTestSol r t(solver(msg=msg)) File "D:\Portable Python 2.7.5.1\app\lib\site-packages\pulp-1.5.4-py2.7.egg\pulp\tests.py", line 170, in pulpTest014 pulpTestCheck(prob, solver, [LpStatusOptimal], {x:4, y:-1, z:6, w:0}) File "D:\Portable Python 2.7.5.1\app\lib\site-packages\pulp-1.5.4-py2.7.egg\pulp\tests.py", line 17, in pulpTestChec prob.writeLP("debug.lp") File "D:\Portable Python 2.7.5.1\app\lib\site-packages\pulp-1.5.4-py2.7.egg\pulp\pulp.py", line 1502, in writeLP + str(repeated_names)) pulp.constants.PulpError: Repeated variable names in Lp format [('x', 2)]
答案 0 :(得分:0)
好的发现了这个问题。 PulpTest014抛出此异常。要修复它,COINMP_DLL应该放在包含抛出异常的所有求解器的数组中(因为COIN_CMD已经存在)
if solver.__class__ in [COIN_CMD, COINMP_DLL, PULP_CBC_CMD, CPLEX_CMD, CPLEX_PY,
GLPK_CMD, GUROBI_CMD]:
try:
pulpTestCheck(prob, solver, [LpStatusOptimal], {x:4, y:-1, z:6, w:0})
except PulpError:
#these solvers should raise an error'
pass
通过TestAll传递。