-
Notifications
You must be signed in to change notification settings - Fork 0
/
constraints.cpp
58 lines (47 loc) · 1.65 KB
/
constraints.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
#include "constraints.h"
//****************************************Both constraints
bool CSavings(int from, int to, double ttime){
int fromRoute = path[from].route;
int toRoute = path[to].route;
if(routeDemand[fromRoute] + routeDemand[toRoute] > Q)
return true;
if(ttime > MRT)
return true;
return false;
}
//****************************************Demand stays, so the only constraint is the path length
bool CInSwap(int from, double score){
if(routeTime[path[from].route] - score > MRT)
return true;
return false;
}
//****************************************
bool CBetweenSwap(int from, int to){
if((routeDemand[path[from].route] - d[from] + d[to] > Q) || (routeDemand[path[to].route] + d[from] - d[to]> Q))
return true;
if(routeTime[path[from].route]
- (dist[path[from].prev][from] + dist[from][path[from].next])
+ (dist[path[from].prev][to] + dist[to][path[from].next])
> MRT ||
routeTime[path[to].route]
- (dist[path[to].prev][to] + dist[to][path[to].next])
+ ( dist[path[to].prev][from] + dist[from][path[to].next])
> MRT)
return true;
return false;
}
//****************************************
bool CDeleteAndInsert(int from, int to){
if(routeDemand[path[to].route] + d[from] > Q)
return true;
if(routeTime[path[to].route] + DT - dist[to][path[to].next] + dist[to][from] + dist[from][path[to].next] > MRT)
return true;
return false;
}
//****************************************CHECK CONSTRAINT
bool CReverseEdge(int from, int to){
if(routeTime[path[from].route] - dist[path[from].prev][from] + dist[from][path[to].next]
- dist[to][path[to].next] + dist[path[from].prev][to] > MRT)
return true;
return false;
}