-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.cpp
67 lines (48 loc) · 1.78 KB
/
main.cpp
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
#include "headers/Interpreter.h"
#include "headers/BranchBound.h"
#include "headers/CuttingPlane.h"
#include "headers/Exception.h"
#include <time.h>
using namespace std;
int main(int argc, char* argv[]) {
BranchBound *bb = NULL;
CuttingPlane *cp = NULL;
Interpreter *interpreter = NULL;
clock_t time[2];
try {
if(argc < 2) {
throw(new Exception("Digite o nome do arquivo de entrada!"));
}
interpreter = new Interpreter(argv[1]);
time[0] = clock();
bb = new BranchBound(interpreter->getProblem(), interpreter->getMode());
time[1] = clock();
double totalTime = (time[1] - time[0]) * 1000.00 / CLOCKS_PER_SEC;
cout << "----------Branch and Bound---------" << endl;
if (bb->hasSolution()) {
cout << "Valor otimizado: " << bb->getOptimum() << endl;
cout << "Solucao: [" << bb->getSolution().transpose() << "]"<< endl;
cout << "Tempo: " << totalTime << "ms" << endl;
} else {
cout << "Solucao nao encontrada" << endl;
}
time[0] = clock();
cp = new CuttingPlane(interpreter->getProblem(), interpreter->getMode());
time[1] = clock();
totalTime = (time[1] - time[0]) * 1000.00 / CLOCKS_PER_SEC;
cout << "----------Planos de Corte---------" << endl;
if (cp->hasSolution()) {
cout << "Valor otimizado: " << cp->getOptimum() << endl;
cout << "Solucao: [" << cp->getSolution().transpose() << "]"<< endl;
cout << "Tempo: " << totalTime << "ms" << endl;
} else {
cout << "Solucao nao encontrada" << endl;
}
} catch (Exception *ex) {
ex->print();
}
delete bb;
delete cp;
delete interpreter;
return 0;
}