本文整理汇总了C++中Net::readFile方法的典型用法代码示例。如果您正苦于以下问题:C++ Net::readFile方法的具体用法?C++ Net::readFile怎么用?C++ Net::readFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Net
的用法示例。
在下文中一共展示了Net::readFile方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main (int argc, const char * argv[])
{
// if (argc != 4) {
// cerr << "Wrong number of arguments.\n";
// exit(1);
// }
PowerModelType pmt = ACPOL;
// PowerModelType pmt = SOCP_OTS;
// PowerModelType pmt = ACRECT;
SolverType st = ipopt;
// SolverType st = gurobi;
string filename = "../data/nesta_case3_lmbd.m";
if (argc >=2) {
string filename = argv[1];
if(!strcmp(argv[2],"ACPOL")) pmt = ACPOL;
else if(!strcmp(argv[2],"ACRECT")) pmt = ACRECT;
//else if(!strcmp(argv[2],"QC")) pmt = QC;
else if(!strcmp(argv[2],"OTS")) pmt = OTS;
else if(!strcmp(argv[2],"SOCP")) pmt = SOCP;
else if(!strcmp(argv[2],"DC")) pmt = DC;
//else if(!strcmp(argv[2],"QC_OTS")) pmt = QC_OTS;
else if(!strcmp(argv[2],"SOCP_OTS")) pmt = SOCP_OTS;
else{
cerr << "Unknown model type.\n";
exit(1);
}
if(!strcmp(argv[3],"ipopt")) st = ipopt;
else if(!strcmp(argv[3],"gurobi")) st = gurobi;
else{
cerr << "Unknown solver type.\n";
exit(1);
}
}
cout << "############################## POWERTOOLS ##############################\n\n";
Net net;
net.readFile(filename);
// net.readFile("data/nesta/nesta_case2383wp_mp.m");
// net.readFile("data/nesta/nesta_case300_ieee.m");
// net.readFile("../../data/nesta/nesta_case9241_pegase.m");
// net.readFile("../../data/nesta/nesta_case2383wp_mp.m");
// net.readFile("../data/nesta/" + filename);
// PowerModel power_model(pmt,&net);
PowerModel power_model(pmt,&net,st);
power_model.min_cost();
power_model.solve();
cout << "\nTo run PowerTools with a different power flow model, enter:\nPowerTools filename ACPOL/ACRECT/SOCP/DC/OTS/SOCP_OTS ipopt/gurobi\n";
return 0;
}
示例2: main
int main (int argc, const char * argv[])
{
// if (argc != 4) {
// cerr << "Wrong number of arguments.\n";
// exit(1);
// }
// PowerModelType pmt = ACPOL;
// PowerModelType pmt = SOCP;
// Start Timers
double wall0 = get_wall_time();
double cpu0 = get_cpu_time();
PowerModelType pmt = SDP;
// PowerModelType pmt = QC;
// PowerModelType pmt = QC_SDP;
// PowerModelType pmt = SOCP_OTS;
// PowerModelType pmt = ACRECT;
SolverType st = ipopt;
// SolverType st = gurobi;
// string filename = "../../data/nesta_case5_pjm__sad.m";
// string filename = "../../data/nesta_case3_lmbd.m";
string filename = "../../data/nesta_case118_ieee.m";
// string filename = "../../data/nesta_case29_edin__sad.m";
// string filename = "../../data/nesta_case24_ieee_rts.m";
// string filename = "../../data/nesta_case24_ieee_rts__api.m";
// string filename = "../../data/nesta_case30_ieee.m";
// string filename = "../../data/nesta_case57_ieee.m";
// string filename = "../../data/nesta_case30_as__sad.m";
// string filename = "../../data/nesta_case24_ieee_rts__sad.m";
// string filename = "../../data/nesta_case2224_edin.m";
// string filename = "../../data/nesta_case14_ieee.m";
// string filename = "../../data/nesta_case162_ieee_dtc.m";
// string filename = "../../data/nesta_case5_pjm.m";
if (argc >=2) {
filename = argv[1];
if(!strcmp(argv[2],"ACPOL")) pmt = ACPOL;
else if(!strcmp(argv[2],"ACRECT")) pmt = ACRECT;
else if(!strcmp(argv[2],"QC")) pmt = QC;
else if(!strcmp(argv[2],"QC_SDP")) pmt = QC_SDP;
else if(!strcmp(argv[2],"OTS")) pmt = OTS;
else if(!strcmp(argv[2],"SOCP")) pmt = SOCP;
else if(!strcmp(argv[2],"SDP")) pmt = SDP;
else if(!strcmp(argv[2],"DC")) pmt = DC;
//else if(!strcmp(argv[2],"QC_OTS")) pmt = QC_OTS;
else if(!strcmp(argv[2],"SOCP_OTS")) pmt = SOCP_OTS;
else{
cerr << "Unknown model type.\n";
exit(1);
}
if(!strcmp(argv[3],"ipopt")) st = ipopt;
else if(!strcmp(argv[3],"gurobi")) st = gurobi;
else{
cerr << "Unknown solver type.\n";
exit(1);
}
}
cout << "############################## POWERTOOLS ##############################\n\n";
Net net;
if(net.readFile(filename)==-1)
return -1;
// net.readFile("data/nesta/nesta_case2383wp_mp.m");
// net.readFile("data/nesta/nesta_case300_ieee.m");
// net.readFile("../../data/nesta/nesta_case9241_pegase.m");
// net.readFile("../../data/nesta/nesta_case2383wp_mp.m");
// net.readFile("../data/nesta/" + filename);
// PowerModel power_model(pmt,&net);
cout << "\nTo run PowerTools with a different input/power flow model, enter:\nPowerTools filename ACPOL/ACRECT/SOCP/QC/QC_SDP/SDPDC/OTS/SOCP_OTS ipopt/gurobi\n\n";
PowerModel power_model(pmt,&net,st);
// power_model.propagate_bounds();
power_model.build();
power_model.min_cost();
int status = power_model.solve();
// Stop timers
double wall1 = get_wall_time();
double cpu1 = get_cpu_time();
cout << "ALL_DATA, " << net._name << ", " << net.nodes.size() << ", " << net.arcs.size() << ", " << power_model._model->_opt<< ", " << status << ", " << wall1 - wall0<< ", -inf\n";
return 0;
}