tune_c ++。CPP


tune_c ++。CPP


/ *版权所有2021,Gurobi优狗万app足彩化,LLC * // *此示例从文件中读取模型并调整它。然后它将最佳参数设置写入文件并使用这些参数来解决模型。* / #include“gurobi_c ++。h”#include 使用命名空间std;int main(int argc,char * argv []){if(argc <2){cout <<“用法:tune_c ++ filename”<<端口;返回1;grbenv * env = 0;尝试{env = new grbenv();//从文件grbmodel model = grbmodel读取模型(* env,argv [1]);//将Tuneresults参数设置为1 model.set(grb_intparam_tuneresults,1);//调整模型模型.Tune(); // Get the number of tuning results int resultcount = model.get(GRB_IntAttr_TuneResultCount); if (resultcount > 0) { // Load the tuned parameters into the model's environment model.getTuneResult(0); // Write tuned parameters to a file model.write("tune.prm"); // Solve the model using the tuned parameters model.optimize(); } } catch(GRBException e) { cout << "Error code = " << e.getErrorCode() << endl; cout << e.getMessage() << endl; } catch (...) { cout << "Error during tuning" << endl; } delete env; return 0; }