-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
80 lines (72 loc) · 1.96 KB
/
Copy pathmain.cpp
File metadata and controls
80 lines (72 loc) · 1.96 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
#include "TWOLevelFL.h"
#include <iostream>
#include <vector>
#include <list>
#include <map>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <iomanip>
#include <chrono>
#include <ctime>
#include <thread>
using namespace std;
int main(int argc, char const *argv[])
{
double value;
long N, M1, M2;
cin >> N >> M1 >> M2;
double *facilityCost1 = new double[M1];
double *facilityCost2 = new double[M2];
double **connectionCost1 = new double*[N];
double **connectionCost2 = new double*[M1];
for (long m1 = 0; m1 < M1; m1++)
{
cin >> value;
facilityCost1[m1] = value;
}
for (long m2 = 0; m2 < M2; m2++)
{
cin >> value;
facilityCost2[m2] = value;
}
for (long n = 0; n < N; n++)
{
connectionCost1[n] = new double[M1];
for (long m1 = 0; m1 < M1; m1++)
{
cin >> value;
connectionCost1[n][m1] = value;
}
}
for (long m1 = 0; m1 < M1; m1++)
{
connectionCost2[m1] = new double[M2];
for (long m2 = 0; m2 < M2; m2++)
{
cin >> value;
connectionCost2[m1][m2] = value;
}
}
TWOLevelFL *tFL = new TWOLevelFL(N, M1, M2);
tFL->setFacilityCost1(facilityCost1);
tFL->setFacilityCost2(facilityCost2);
tFL->setConnectionCost1(connectionCost1);
tFL->setConnectionCost2(connectionCost2);
tFL->initFeasibleSol();
//cout << "Before Local Search" << endl;
//tFL->printDetails();
//cout << "Cost is : "<< tFL->computeCost(tFL->facilityAssignL1, tFL->facilityAssignL2, tFL->isFacOpenL1);
std::clock_t c_start = std::clock();
tFL->localSearch();
std::clock_t c_end = std::clock();
//cout << "After Local Search" << endl;
//tFL->printDetails();
//cout << "Cost is : "<< tFL->computeCost(tFL->facilityAssignL1, tFL->facilityAssignL2, tFL->isFacOpenL1) << endl;
cout<< N<<" "<<M1<<" "<<M2<<" : "<< std::setprecision(5)<<tFL->computeCost(tFL->facilityAssignL1, tFL->facilityAssignL2, tFL->isFacOpenL1)<<" : "<<1000.0 * (c_end-c_start) / CLOCKS_PER_SEC << " ms\n";
return 0;
}