我們將Gurobi WCF解決方案作爲Windows服務託管。GUROBI:在雲端/普通模式之間切換
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));
}
在用戶界面中,我們提供了轉到雲端並由'useCloud'標誌處理的選項。但問題是我們必須每次重新啓動服務以在雲/非雲選項之間切換。即使在正確設置環境變量之後,服務也無法透明地在雲/非雲之間切換。
添加於01日 - 12月2015年
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(空)或GRBEnv(NULL,computeServer,端口,密碼,優先級,超時)版本取決於用戶選擇使用雲或本地服務器。但是我們仍然無法在計算服務器和本地服務器之間透明地切換。這歸結爲Gurobi從GRB_LICENSE_FILE環境變量中獲取許可證文件。有沒有計劃提供一種將GRB_LICENSE_FILE傳遞給Gurobi解算器的不同方式?
我們的解決方法: 我們的方法是在使用雲時使用GRB_LICENSE_FILE = gurobi.lic.cloud。如果它是非雲GRB_LICENSE_FILE = gurobi.lic。我們可能需要使用一個通用的gurobi.lic文件並用計算服務器或常規服務器覆蓋。