-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
145 lines (111 loc) · 4.97 KB
/
main.cpp
File metadata and controls
145 lines (111 loc) · 4.97 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
/*****************************************************************************
* @file main.cpp *
* @brief 主程序 *
* @details 使用时,需要先新建一个 Network 对象,并完成初始化 *
* 初始化后即可对 Network 对象调用 user_equilibrium_solver 中的函 *
* 函数求解 UE 下的流量分配结果 *
* @author Dong Yu *
* @email 213191838@seu.edu.cn *
* @version 0.5 *
* @date 2022/11/13 *
* *
*----------------------------------------------------------------------------*
* Change History : *
* <Date> | <Version> | <Author> | <Description> *
*----------------------------------------------------------------------------*
* 2022/10/28 | 0.1 | Dong Yu | Init from User-Equilibrium v0.9 *
*----------------------------------------------------------------------------*
* 2022/10/30 | 0.2 | Dong Yu | Test the Network class (T1) *
*----------------------------------------------------------------------------*
* 2022/10/31 | 0.3 | Dong Yu | Test Link Blocking method (T2) *
*----------------------------------------------------------------------------*
* 2022/10/31 | 0.4 | Dong Yu | Test ADMM FrameWork (T3) *
*----------------------------------------------------------------------------*
* 2022/11/13 | 0.5 | Dong Yu | Test equ Blocking method (T4) *
*----------------------------------------------------------------------------*
* *
*****************************************************************************/
#include "stdafx.h"
#include "message.h"
#include "read_file.h"
#include "network.h"
#include "utility.h"
#include "user_equilibrium_solver.h"
#include <windows.h>
#include <iostream>
using namespace std;
// 测试 Network 类
int test1() {
LARGE_INTEGER freq;
LARGE_INTEGER beginTime;
LARGE_INTEGER endTime;
QueryPerformanceFrequency(&freq);
QueryPerformanceCounter(&beginTime);
Network big_network = Network();
big_network.Init();
QueryPerformanceCounter(&endTime);
int timeOfMicroSecond = (double)(endTime.QuadPart - beginTime.QuadPart) * 1e6 / (double)freq.QuadPart;
StatusMessage("Time of MicroSecond: " + to_string(timeOfMicroSecond));
return 1;
}
// 测试 link blocking
int test2() {
LARGE_INTEGER freq;
LARGE_INTEGER beginTime;
LARGE_INTEGER endTime;
Network big_network = Network();
big_network.Init();
QueryPerformanceFrequency(&freq);
QueryPerformanceCounter(&beginTime);
vector<vector<int>> blockingResult = GetBlockingResult(big_network);
QueryPerformanceCounter(&endTime);
int timeOfMicroSecond = (double)(endTime.QuadPart - beginTime.QuadPart) * 1e6 / (double)freq.QuadPart;
StatusMessage("Time of MicroSecond: " + to_string(timeOfMicroSecond));
return 1;
}
extern LARGE_INTEGER freq;
extern LARGE_INTEGER beginTime;
extern LARGE_INTEGER endTime;
// 测试 ADMM算法
int test3() {
StartTimer();
Network network = Network();
network.Init("./data/SiouxFalls_net.tntp", "./data/SiouxFalls_trips.tntp");
ADMM(network);
QueryPerformanceCounter(&endTime);
int timeOfMicroSecond = (double)(endTime.QuadPart - beginTime.QuadPart) * 1e6 / (double)freq.QuadPart;
StatusMessage("Total time of MicroSecond: " + to_string(timeOfMicroSecond));
return 1;
}
// 测试 Link Blocking 算法
int test4() {
Network network = Network();
network.Init("./data/SiouxFalls_net.tntp", "./data/SiouxFalls_trips.tntp");
QueryPerformanceFrequency(&freq);
QueryPerformanceCounter(&beginTime);
// vector<vector<int>> blockingResult = GetBlockingResult(network);
// vector<vector<int>> blockingResult = GetBlockingResultDefault(network);
// vector<vector<int>> blockingResult = GetBlockingResultSimple(network);
// vector<vector<int>> blockingResult = GetBlockingResultFixed(network);
vector<vector<int>> blockingResult = GetBlockingResultFixedEqu(network);
QueryPerformanceCounter(&endTime);
int timeOfMicroSecond = (double)(endTime.QuadPart - beginTime.QuadPart) * 1e6 / (double)freq.QuadPart;
StatusMessage("Total time of MicroSecond: " + to_string(timeOfMicroSecond));
for (int k = 0; k < blockingResult.size(); k++) {
StatusMessageB("Block " + to_string(k + 1) + "", ": ");
for (int l = 0; l < blockingResult[k].size(); l++) {
if (l == blockingResult[k].size() - 1)
StatusMessageB(to_string(blockingResult[k][l]), "");
else
StatusMessageB(to_string(blockingResult[k][l]), ", ");
}
StatusMessageA(" ");
}
return 1;
}
int main() {
// test1();
// test2();
// test3();
test4();
}