-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
executable file
·59 lines (52 loc) · 1.5 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*Lukas Kinder (s3686566), [email protected], Bachelor Project 2021 */
#include <stdio.h>
#include <stdlib.h>
#include "solver.h"
#include <time.h>
void printErrorMessage(){
printf("Please call with <theia -p EE-CO -f PATH -h HEURISTIC>\n");
exit(1);
}
char *parseArguments(int argc, char *argv[], bool * printTree, char * heuristic){
char *ret = NULL;
for (int i =1; i < argc; i++){
if (strcmp(argv[i], "-p") == 0){
if ( strcmp(argv[i+1], "EE-CO") != 0 ){
printf("ERROR: The only task implemented is EE-CO\n");
printErrorMessage();
}
i+=1;
}else if (strcmp(argv[i], "-f") == 0){
ret = argv[i+1];
i+=1;
}else if (strcmp(argv[i], "-v") == 0){
*printTree = true;
}else if (strcmp(argv[i], "-h") == 0){
if (strcmp(argv[i+1], "min") == 0){
*heuristic = 'm';
}else if (strcmp(argv[i+1], "sum") == 0){
*heuristic = 's';
}else if (strcmp(argv[i+1], "exp") == 0){
*heuristic = 'e';
}else if (strcmp(argv[i+1], "adp") == 0){
*heuristic = 'a';
}else {
printf("ERROR: Unknown heuristic\n");
printErrorMessage();
}
}
}
if (ret == NULL){
printErrorMessage();
}
return ret;
}
int main(int argc, char *argv[]) {
bool printTree = false;
char heuristic = 'a';
char * input_file = parseArguments(argc, argv,&printTree,&heuristic);
Graph graph = createGraph(input_file);
findComplete(graph, printTree, heuristic);
freeGraph(graph);
return 0;
}