-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathfunc.cpp
119 lines (100 loc) · 2.89 KB
/
func.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
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
#include <cmath>
#include <cstdio>
#include "global_var.h"
#include "basic_util.h"
#include "show_status.h"
double SO_link_obj(double step){
double INT = 0.0, flow;
int i;
for(i=0; i<metadata.n_link; i++){
flow = links[i].flow + step*links[i].direction;
INT += flow * links[i].free_time
*(1 + links[i].b * pow(flow/links[i].capacity, links[i].power));
}
return INT;
}
double UE_link_obj(double step){
double INT = 0.0, flow;
int i;
for(i=0; i<metadata.n_link; i++){
flow = links[i].flow + step*links[i].direction;
INT += links[i].free_time*flow;
INT += links[i].free_time*links[i].b*flow/(links[i].power + 1)
*pow(flow/links[i].capacity, links[i].power);
}
return INT;
}
double UE_link_diff(double step){
double DIFF = 0.0, flow;
int i;
for(i=0; i<metadata.n_link; i++){
flow = links[i].flow + step*links[i].direction;
DIFF += links[i].direction*links[i].free_time
*(1.0 + links[i].b*pow(flow/links[i].capacity, links[i].power));
}
return DIFF;
}
double SUE_route_logit(double step){
double INT = 0.0, flow;
int p, r, l;
for(p=0; p<metadata.n_pair; p++){
for(r=0; r<pairs[p].n_route; r++){
flow = pairs[p].routes[r].flow + step*pairs[p].routes[r].direction;
INT += flow*log(flow);
}
}
INT /= metadata.theta;
set_direction(0.0);
route_to_link_direction();
for(l=0; l<metadata.n_link; l++){
flow = links[l].flow + step*links[l].direction;
INT += links[l].free_time*flow;
INT += links[l].free_time*links[l].b*flow/(links[l].power + 1)
* pow(flow/links[l].capacity, links[l].power);
}
return INT;
}
double SUE_SO_mixed(double step){
double INT = 0.0, flow;
int p, r, l;
// the first term of objective
for(p=0; p<metadata.n_pair; p++){
for(r=0; r<pairs[p].n_route; r++){
flow = pairs[p].routes[r].flow + step*pairs[p].routes[r].direction;
INT += flow*log(flow);
}
}
if(metadata.theta <= 0.0)
rep_error("Theta is zero.", "SUE_SO_mixed()");
INT /= metadata.theta;
// the second term of objective
set_direction(0.0);
route_to_link_direction();
path_to_link_direction();
for(l=0; l<metadata.n_link; l++){
flow = links[l].flow + step*links[l].direction;
INT += links[l].free_time*links[l].b*flow/(links[l].power + 1.0)
* pow(flow/links[l].capacity, links[l].power);
}
// the third term of objective
set_flow(0.0);
set_direction(0.0);
route_to_link_flow();
route_to_link_direction();
for(l=0; l<metadata.n_link; l++){
flow = links[l].flow + step*links[l].direction;
INT += links[l].free_time*flow;
}
// the fouth term of objective
set_flow(0.0);
set_direction(0.0);
path_to_link_flow();
path_to_link_direction();
for(l=0; l<metadata.n_link; l++){
flow = links[l].flow + step*links[l].direction;
INT += links[l].free_time*flow/(links[l].power + 1.0);
}
route_to_link_flow();
route_to_link_direction();
return INT;
}