这个问题
第三方建模框架,例如Pyomo和纸浆是Python中使用Gurobi的常用方法。这些框架不公开底层的Gurobi模型或环境对象发送给用户。因此,解决后可能无法妥善处置Gurobi环境。在使用Gurobi令牌服务器时,这种行为的一个副作用是令牌没有被正确释放。
解决方案
有两种方法可以解决这个问题:
- 使用Gurobi的原生Python API而不是第三方建模框架。这将使您能够完全访问Gurobi的所有特性,包括环境/令牌管理。它通常也更有效地构建模型。
- 优化完成后,通过实例删除建模框架使用的主要对象▽操作符。然后,通过调用Gurobi's来处理默认的Gurobi环境disposeDefaultEnv ()函数。这将释放相应的令牌。
进一步的信息