MCPcopy Create free account
hub / github.com/OriginQ/QPanda-2 / main

Function main

Applications/NodeSort/NodeSort.cpp:29–144  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27 const std::string& filename);
28
29int main(int argc, char* argv[])
30{
31 string grid = "1-2";
32 float lambda = 0.2;
33 float lambda1 = 0.5;
34 float lambda2 = 0.5;
35 bool sir = false;
36 std::vector<int> sources;
37 float infectious_rate = 0.9;
38 float recovery_rate = 0.1;
39 int timestep = 5;
40 string filename = "result.json";
41
42 if (argc == 2 && !strcmp(argv[1], "--help")) {
43 cout << "--grid \"0-1;0-2\" (necessary. 0-1;0-2 represent the grid is 1-0-2)" << endl;
44 cout << "--lambda 0.2 (default = 0.2)" << endl;
45 cout << "--lambda1 0.5 (default = 0.5)" << endl;
46 cout << "--lambda2 0.5 (default = 0.5)" << endl;
47 cout << "--SIR" << endl;
48 cout << "--source \"0,1\" (default = 0)" << endl;
49 cout << "--infectious_rate 0.9 (default = 0.9)" << endl;
50 cout << "--recovery_rate 0.1 (default = 0.1)" << endl;
51 cout << "--timestep 5 ([5~10]default = 5)" << endl;
52 cout << "--filename result.json (default = result.json)" << endl;
53
54 return 0;
55 }
56
57 for (int i = 0; i < argc; ++i) {
58 cout << argv[i] << endl;
59 }
60
61 for (int i = 1; i < argc;) {
62 if (!strcmp(argv[i], "--grid")) {
63 grid = argv[i + 1];
64 i = i + 2;
65 }
66 else if (!strcmp(argv[i], "--lambda")) {
67 lambda = atof(argv[i + 1]);
68 i = i + 2;
69 }
70 else if (!strcmp(argv[i], "--lambda1")) {
71 lambda1 = atof(argv[i + 1]);
72 i = i + 2;
73 }
74 else if (!strcmp(argv[i], "--lambda2")) {
75 lambda2 = atof(argv[i + 1]);
76 i = i + 2;
77 }
78 else if (!strcmp(argv[i], "--SIR")) {
79 sir = true;
80 i = i + 1;
81 }
82 else if (!strcmp(argv[i], "--source")) {
83 auto str_source = QString(argv[i + 1]);
84 auto items = str_source.split(",", QString::SkipEmptyParts);
85 for (auto& i : items)
86 {

Callers

nothing calls this directly

Calls 8

QStringFunction · 0.85
genGraphFunction · 0.85
calcSIRFunction · 0.85
calcNodeSortFunction · 0.85
toIntMethod · 0.80
splitMethod · 0.45
push_backMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected