【发布时间】:2015-11-30 08:10:08
【问题描述】:
我们将 Gurobi WCF 解决方案托管为 Windows 服务。
if (useCloud)
{
this.logInfo("Environment GRB_LICENSE_FILE: " + System.Environment.GetEnvironmentVariable("GRB_LICENSE_FILE"));
return new GurobiProblemBuilder(this, new testSolver.solver.gurobi.Net.EnvironmentNet(this.settings.cloudLic, this.settings.cloudPwd));
}
else
{
this.logInfo("Environment GRB_LICENSE_FILE: " + System.Environment.GetEnvironmentVariable("GRB_LICENSE_FILE"));
return new GurobiProblemBuilder(this, new testSolver.solver.gurobi.Net.EnvironmentNet(null));
}
在 UI 中,我们提供了转到云端的选项,并由“useCloud”标志处理。但问题是我们每次都必须重新启动服务才能在云/非云选项之间切换。即使正确设置了环境变量,服务也无法透明地在云/非云之间切换。
添加于 2015 年 12 月 1 日
public EnvironmentNet(string logFileOrNull)
{
environment = new GRBEnv(null);
}
public EnvironmentNet(string computeServer, string password)
{
// http://www.gurobi.com/documentation/6.0/refman/cs_grbenv2.html
int port = -1; // read from app.config
int priority = 0; // read from app.config
double timeout = -1; // read from app.config
environment = new GRBEnv(null, computeServer, port, password, priority, timeout);
}
实际上,我们的 GurobiProblemBuilder 调用 GRBEnv,然后调用 GRBEnv(null) 或 GRBEnv(null,computeServer,port,password,priority,timeout) 版本取决于用户选择使用云服务器还是本地服务器。但是我们仍然无法在计算服务器和本地服务器之间透明地切换。这归结为 Gurobi 从 GRB_LICENSE_FILE 环境变量中获取许可证文件。是否有计划提供一种不同的方式将 GRB_LICENSE_FILE 传递给 Gurobi 求解器?
我们的解决方法: 我们的方法是当它是云时使用 GRB_LICENSE_FILE = gurobi.lic.cloud。如果是非云 GRB_LICENSE_FILE = gurobi.lic。我们可能需要使用一个通用的 gurobi.lic 文件并用计算服务器或常规服务器覆盖。
【问题讨论】:
标签: c# .net wcf windows-services gurobi