def grabLicence(self):
"""
Returns True if a CPLEX licence can be obtained.
The licence is kept until releaseLicence() is called.
"""
status = ctypes.c_int()
# If the config file allows to do so (non null params), try to
# grab a runtime license.
if ilm_cplex_license and ilm_cplex_license_signature:
runtime_status = CPLEX_DLL.lib.CPXsetstaringsol(
ilm_cplex_license,
ilm_cplex_license_signature)
# if runtime_status is not zero, running with a runtime
# license will fail. However, no error is thrown (yet)
# because the second call might still succeed if the user
# has another license. Let us forgive bad user
# configuration:
if not (runtime_status == 0) and self.msg:
print(
"CPLEX library failed to load the runtime license" +
"the call returned status=%s" % str(runtime_status) +
"Please check the pulp config file.")
self.env = CPLEX_DLL.lib.CPXopenCPLEX(ctypes.byref(status))
self.hprob = None
if not(status.value == 0):
raise PulpSolverError("CPLEX library failed on " +
"CPXopenCPLEX status=" + str(status))
评论列表
文章目录