浏览代码

Initial support for shell arguments

Jan Potocki 5 年前
父节点
当前提交
46112938f8
共有 1 个文件被更改,包括 24 次插入2 次删除
  1. 24
    2
      pea2plus.cpp

+ 24
- 2
pea2plus.cpp 查看文件

@@ -3,6 +3,7 @@
3 3
 #include <string>
4 4
 #include <vector>
5 5
 #include <cmath>
6
+#include <cstdlib>
6 7
 #include "Stopwatch.h"
7 8
 #include "ArrayGraph.h"
8 9
 #include "ListGraph.h"
@@ -22,7 +23,7 @@ const int measureSalesmanDistance = 400;
22 23
 // Wykorzystanie reprezentacji grafu w postaci list sasiedztwa...
23 24
 // ...zamiast (domyslnie) macierzy sasiedztwa
24 25
 // (wolniejsze obliczenia, mniejsze uzycie pamieci)
25
-const bool useListGraph = false;
26
+bool useListGraph = false;
26 27
 
27 28
 // Domyslna kadencja tabu search - wybor automatyczny
28 29
 unsigned tabuLength = 0;
@@ -36,11 +37,32 @@ unsigned tabuStopTime = 60;
36 37
 // Domyslna liczba watkow tabu search
37 38
 unsigned tabuThreadsNumber = 2;
38 39
 
39
-int main()
40
+int main(int argc, char *argv[])
40 41
 {
41 42
     Stopwatch clock;                // czasomierz
42 43
     Graph *graph = NULL;            // <- tu bedziemy zapisywac adresy przez caly program
43 44
 
45
+    if(argc > 1)
46
+    {
47
+        for(int i = 1; i < argc; i++)
48
+        {
49
+            if(strcmp(argv[i], "-l") == 0)
50
+            {
51
+                useListGraph = true;
52
+            }
53
+            else if(strcmp(argv[i], "-t") == 0)
54
+            {
55
+                i++;
56
+                int input = atoi(argv[i]);
57
+
58
+                if(input > 0)
59
+                    tabuThreadsNumber = input;
60
+                else
61
+                    cout << "+++ MELON MELON MELON +++ Nieprawidlowa liczba watkow +++" << endl << endl;
62
+            }
63
+        }
64
+    }
65
+
44 66
     cout << "PEA Projekt 2 Plus v2.0ALPHA" << endl;
45 67
     cout << "Jan Potocki 2017-2019" << endl;
46 68
     cout << "(beerware)" << endl;

正在加载...
取消
保存