tune_cs.cs


tune_cs.cs


/* Copyright 2021, 狗万app足彩Gurobi Optimization, LLC */ /*这个例子从一个文件中读取一个模型并调优它。然后,它将最佳参数设置写入文件,并使用这些参数解决模型。* /使用系统;使用Gurobi;class tune_cs {static void Main(string[] args) {if (args. class);长度< 1){Console.Out。WriteLine(“用法:tune_cs文件名”);返回;} try {GRBEnv env = new GRBEnv();//从文件中读取GRBModel model = new GRBModel(env, args[0]);//设置TuneResults参数为1; // Tune the model model.Tune(); // Get the number of tuning results int resultcount = model.TuneResultCount; if (resultcount > 0) { // Load the tuned parameters into the model's environment model.GetTuneResult(0); // Write the tuned parameters to a file model.Write("tune.prm"); // Solve the model using the tuned parameters model.Optimize(); } // Dispose of model and environment model.Dispose(); env.Dispose(); } catch (GRBException e) { Console.WriteLine("Error code: " + e.ErrorCode + ". " + e.Message); } } }