manbet体育手机客户端


lpmethod_c ++。CPP


/ *版权所有2019,Gurobi优狗万app足彩化,LLC * // *通过方法参数的不同值解决模型;显示哪个值给出最短的解决时间。* / #include“gurobi_c ++。h”使用命名空间std;int main(int argc,char * argv []){if(argc <2){cout <<“用法:lpmethod_c ++ filename”<<端口;返回1;}尝试{//读取型号grbenv ent = grbenv();grbmodel m = grbmodel(env,argv [1]);//用不同的方法int bestmethod = -1解决模型;双倍besttime = m.get(grb_doubleparam_timelimit);for(int i = 0; i <= 2; ++ i){m.reset(); m.set(GRB_IntParam_Method, i); m.optimize(); if (m.get(GRB_IntAttr_Status) == GRB_OPTIMAL) { bestTime = m.get(GRB_DoubleAttr_Runtime); bestMethod = i; // Reduce the TimeLimit parameter to save time // with other methods m.set(GRB_DoubleParam_TimeLimit, bestTime); } } // Report which method was fastest if (bestMethod == -1) { cout << "Unable to solve this model" << endl; } else { cout << "Solved in " << bestTime << " seconds with Method: " << bestMethod << endl; } } catch(GRBException e) { cout << "Error code = " << e.getErrorCode() << endl; cout << e.getMessage() << endl; } catch(...) { cout << "Exception during optimization" << endl; } return 0; }