-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
154 lines (104 loc) · 4.3 KB
/
main.cpp
File metadata and controls
154 lines (104 loc) · 4.3 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
/*
tspSAT-GPU: Simulating an efficient solution to SAT with Tissue P systems on CUDA
This simulator is part of the final degree project entitled:
"Aceleración de simulaciones de sistemas celulares en soluciones del problema SAT
usando GPUs" ("Acceleration of cellular systems simulations on solutions to SAT
problem using GPUs")
Jesús Pérez-Carrasco, June 2012, Dpt. Comput. Sci. & A.I. (University of Seville)
tspSAT-GPU is a subproject of PMCGPU (Parallel simulators for Membrane
Computing on the GPU)
Copyright (c) 2012 Jesús Pérez-Carrasco (University of Seville)
Miguel Á. Martínez-del-Amor (RGNC, University of Seville)
This file is part of tspSAT-GPU.
tspSAT-GPU is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
tspSAT-GPU is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with tspSAT-GPU. If not, see <http://www.gnu.org/licenses/>. */
#include "SATcnf.h"
#include "GPU_solver.h"
#include "Sequential_hybrid_solver.h"
#include "Sequential_solver_a.h"
#include "Sequential_solver_b.h"
#include "Sequential_solver_c.h"
#include "Sequential_solver_d.h"
#include <string>
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
SATcnf scnf;
int mode = 5;
//int sequential_solver=0;
string input_file;
bool solution;
char soltype = '\0';
while((soltype = getopt(argc,argv,"m:f:s:h:?"))!=-1)
{
switch(soltype)
{
case 'f':
input_file = optarg;
break;
case 'm':
mode = atoi(optarg);
break;
case 'h':
case '?':
cout << "Copyright (C) 2012 J. Pérez-Carrasco, M.A. Martínez-del-Amor" << endl <<
"This program comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions" << endl << endl;
cout << "The parameters should be the following ones:" <<
"-f (input file) " <<
"-m (sequential: 0,1,2(recom.),3; hybrid 4(deprec.); parallel 5) " <<
"-h (this help);"
<< endl;
cout << "TSPCUDASAT Version 1.0" << endl;
return 0;
}
}
cout << "Reading file..." << endl;
if(!scnf.parse(input_file.c_str()))
return -1;
cout << "without any problem reading the file" << endl;
cout << "Information of the problem" << endl;
Object* obj = scnf.getcnf(); // Obtenemos el problema SAT en forma normal conjuntiva
cout << "Instance size: N =" << scnf.getN() << "M =" << scnf.getM() << endl;
//Representamos la codificacion de todos los objetos que son entrada del problema SAT
cout << "objects:" ;
for(int i=0; i<scnf.getT();i++)
{
cout << get_variable(obj[i]) << get_mult(obj[i]) << get_i(obj[i]) << "," << get_j(obj[i]) << "" ;
cout << endl;
}
switch (mode)
{
case 0:
solution = Sequential_solver_a(scnf.getN(),scnf.getM(),scnf.getT(), scnf.getcnf());
break;
case 1:
solution = Sequential_solver_b(scnf.getN(),scnf.getM(),scnf.getT(), scnf.getcnf());
break;
case 2:
solution = Sequential_solver_c(scnf.getN(),scnf.getM(),scnf.getT(), scnf.getcnf());
break;
case 3:
solution = Sequential_solver_d(scnf.getN(),scnf.getM(),scnf.getT(), scnf.getcnf());
break;
case 4:
solution = Sequential_hybrid_solver(scnf.getN(),scnf.getM(),scnf.getT(), scnf.getcnf());
break;
case 5:
solution = GPU_solver(scnf.getN(),scnf.getM(),scnf.getT(), scnf.getcnf());
break;
default:
cout << "Wrong type. Use 'h' or '?' for help" << endl;
return 0;
}
cout << "The Tissue P System response is:" << solution << endl;
return 0;
}