-
Notifications
You must be signed in to change notification settings - Fork 13
/
scipp.cpp
53 lines (47 loc) · 2.1 KB
/
scipp.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
#include "scipp.h"
template<typename NodeType>
SCIPP<NodeType>::~SCIPP() {}
template<typename NodeType>
void SCIPP<NodeType>::splitBySoftConflicts(std::vector<std::pair<int, int>> &softConflictIntervals,
const NodeType & node, const NodeType & prevNode, std::pair<int, int> interval,
const ConflictAvoidanceTable &CAT) {
CAT.getSoftConflictIntervals(softConflictIntervals, node, prevNode, interval.first, interval.second, false);
}
template<typename NodeType>
void SCIPP<NodeType>::addStartNode(NodeType &node, const Map &map, const ConflictAvoidanceTable &CAT) {
this->updateEndTimeBySoftConflicts(node, CAT);
this->open.insert(map, node, ISearch<NodeType>::withTime);
}
template<typename NodeType>
void SCIPP<NodeType>::setHC(NodeType &neigh, const NodeType &cur,
const ConflictAvoidanceTable &CAT, bool isGoal) {
neigh.hc = cur.hc + cur.conflictsCount * (neigh.g - cur.g - 1) + neigh.conflictsCount;
if (isGoal) {
this->addFutureConflicts(neigh, CAT);
}
}
template<typename NodeType>
void SCIPP<NodeType>::createNeighborsByEdges(const NodeType &cur, NodeType &neigh,
std::list<NodeType> &successors, int agentId,
const ConstraintsSet &constraints, const ConflictAvoidanceTable &CAT)
{
int minConflicts = CN_INFINITY;
for (neigh.g = std::max(neigh.startTime, cur.g + 1); neigh.g <= neigh.endTime; ++neigh.g) {
if (constraints.hasEdgeConstraint(neigh.i, neigh.j, neigh.g, agentId, cur.i, cur.j)) {
continue;
}
int conflictsCount = CAT.getEdgeAgentsCount(neigh, cur);
if (conflictsCount < minConflicts) {
if (neigh.g <= cur.endTime + 1) {
neigh.conflictsCount += conflictsCount;
neigh.hc = cur.hc + cur.conflictsCount * (neigh.g - cur.g - 1) + neigh.conflictsCount;
neigh.F = neigh.g + neigh.H;
successors.push_back(neigh);
}
}
if (conflictsCount == 0) {
break;
}
}
}
template class SCIPP<SCIPPNode>;