Repository navigation
Expand file tree
/
Copy pathnode.hpp
More file actions
65 lines (52 loc) · 1.6 KB
/
Copy pathnode.hpp
File metadata and controls
65 lines (52 loc) · 1.6 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
#include <boost/heap/fibonacci_heap.hpp>
#include <boost/any.hpp>
#include <utility>
using namespace std;
using namespace boost::heap;
struct Node_h {
unsigned int city; // city or state
pair<double,double> g;
pair<double,double> h;
double f; // f = g+h
int depth;
vector<int> succs;
Node_h* father;
boost::any handler_open;
int hola;
//boost::container::vector<unsigned short> sol;
Node_h(int i,pair<double,double> j, pair<double,double> h_, double k, int d ,vector<int> s,Node_h* l)
: city(i),g(j),h(h_),f(k),depth(d),succs(s),father(l){}
~Node_h(){}
};
struct Solution {
double g1;
double g2;
Node_h* final;
Solution(double i, double j, Node_h* k): g1(i), g2(j), final(k){}
~Solution(){}
};
struct compare_states {
bool operator()(const Node_h* s1, const Node_h* s2) const {
//return n1.id > n2.id;
return s1->f > s2->f ;
}
};
struct Edge {
double cost;
int to_city;
Edge(double c, int i) : cost(c),to_city(i){};
};
template <typename T>
vector<size_t> sort_indexes(const vector<T> &v) {
// initialize original index locations
vector<size_t> idx(v.size());
iota(idx.begin(), idx.end(), 0);
// sort indexes based on comparing values in v
sort(idx.begin(), idx.end(),
[&v](size_t i1, size_t i2) {return v[i1] < v[i2];});
return idx;
}
typedef fibonacci_heap<Node_h*,compare<compare_states> >::handle_type open_handle;
fibonacci_heap<Node_h*, boost::heap::compare<compare_states> > open;
boost::unordered_map<Node_h*, open_handle> open_map;
boost::container::vector<Node_h*> closed;