Last change
on this file since 8512 was
8512,
checked in by spimming, 12 years ago
|
#1894: tweaking of max edge speeds and heuristic cost function
|
File size:
2.2 KB
|
Line | |
---|
1 |
|
---|
2 | namespace HeuristicLab.Problems.RoutePlanning.Graph {
|
---|
3 | public class Edge<Vertex> : IEdge<Vertex> {
|
---|
4 | private readonly Vertex source;
|
---|
5 | public Vertex Source {
|
---|
6 | get { return this.source; }
|
---|
7 | }
|
---|
8 |
|
---|
9 | private readonly Vertex target;
|
---|
10 | public Vertex Target {
|
---|
11 | get { return this.target; }
|
---|
12 | }
|
---|
13 |
|
---|
14 | private short category;
|
---|
15 | public short Category {
|
---|
16 | get { return category; }
|
---|
17 | set { category = value; }
|
---|
18 | }
|
---|
19 |
|
---|
20 | private float weight;
|
---|
21 | public float Weight {
|
---|
22 | get { return weight; }
|
---|
23 | set { weight = value; }
|
---|
24 | }
|
---|
25 |
|
---|
26 | public Edge(Vertex source, Vertex target)
|
---|
27 | : this(source, target, 0) {
|
---|
28 |
|
---|
29 | }
|
---|
30 |
|
---|
31 | public Edge(Vertex source, Vertex target, short category) {
|
---|
32 | this.source = source;
|
---|
33 | this.target = target;
|
---|
34 | this.category = category;
|
---|
35 | }
|
---|
36 |
|
---|
37 | public override string ToString() {
|
---|
38 | return string.Format("{0}->{1}", this.Source, this.Target);
|
---|
39 | }
|
---|
40 |
|
---|
41 | public override bool Equals(object obj) {
|
---|
42 | if (obj is Edge<Vertex>) {
|
---|
43 | Edge<Vertex> e = (obj as Edge<Vertex>);
|
---|
44 | return (this.source.Equals(e.source)) && (this.target.Equals(e.target));
|
---|
45 | }
|
---|
46 | return false;
|
---|
47 | }
|
---|
48 |
|
---|
49 | public override int GetHashCode() {
|
---|
50 | return source.GetHashCode() ^ target.GetHashCode();
|
---|
51 | }
|
---|
52 |
|
---|
53 | public int GetMaxSpeed() {
|
---|
54 | int speed = 0;
|
---|
55 |
|
---|
56 | //TODO:
|
---|
57 | switch (category) {
|
---|
58 | case 23:
|
---|
59 | case 17:
|
---|
60 | case 18:
|
---|
61 | case 22:
|
---|
62 | case 21:
|
---|
63 | case 24:
|
---|
64 | case 16:
|
---|
65 | case 20:
|
---|
66 | case 15:
|
---|
67 | case 12:
|
---|
68 | case 0:
|
---|
69 | speed = 1;
|
---|
70 | break;
|
---|
71 |
|
---|
72 | case 11:
|
---|
73 | case 14:
|
---|
74 | speed = 15;
|
---|
75 | break;
|
---|
76 |
|
---|
77 | case 19:
|
---|
78 | speed = 30;
|
---|
79 | break;
|
---|
80 |
|
---|
81 | case 9:
|
---|
82 | case 10:
|
---|
83 | case 7:
|
---|
84 | case 8:
|
---|
85 | speed = 80;
|
---|
86 | break;
|
---|
87 |
|
---|
88 | case 13:
|
---|
89 | speed = 50;
|
---|
90 | break;
|
---|
91 |
|
---|
92 | case 3:
|
---|
93 | case 4:
|
---|
94 | case 5:
|
---|
95 | case 6:
|
---|
96 | speed = 100;
|
---|
97 | break;
|
---|
98 |
|
---|
99 | case 1:
|
---|
100 | case 2:
|
---|
101 | speed = 130;
|
---|
102 | break;
|
---|
103 |
|
---|
104 | default:
|
---|
105 | speed = 1;
|
---|
106 | break;
|
---|
107 | }
|
---|
108 | return speed;
|
---|
109 | }
|
---|
110 | }
|
---|
111 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.