manbet体育手机客户端


lpmethod_cs.cs


/* Copyright 2019, 狗万app足彩Gurobi Optimization, LLC */ /*用不同的Method参数值求解模型;显示哪个值给出了最短的求解时间。* /使用系统;使用Gurobi;class lpmethod_cs {static void Main(string[] args) {if (args. class);长度< 1){Console.Out。WriteLine(“用法:lpmethod_cs文件名”);返回;} try{//读取模型GRBEnv env = new GRBEnv();/ /创建GRBModel = env, args, [0];//方法int bestMethod = -1; double bestTime = model.Parameters.TimeLimit; for (int i = 0; i <= 2; ++i) { model.Reset(); model.Parameters.Method = i; model.Optimize(); if (model.Status == GRB.Status.OPTIMAL) { bestTime = model.Runtime; bestMethod = i; // Reduce the TimeLimit parameter to save time // with other methods model.Parameters.TimeLimit = bestTime; } } // Report which method was fastest if (bestMethod == -1) { Console.WriteLine("Unable to solve this model"); } else { Console.WriteLine("Solved in " + bestTime + " seconds with Method: " + bestMethod); } // Dispose of model and env model.Dispose(); env.Dispose(); } catch (GRBException e) { Console.WriteLine("Error code: " + e.ErrorCode + ". " + e.Message); } } }