pgRouting  2.2
pgRouting extends the PostGIS / PostgreSQL geospatial database to provide geospatial routing functionality.
 All Classes Functions Variables Pages
vrppdtw/src/pdp.h
1 /*PGR
2 
3 Copyright (c) 2014 Manikata Kondeti
4 mani.iiit123@gmail.com
5 
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10 
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15 
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 
20 */
21 
22 #include<stdio.h>
23 #include<stdlib.h>
24 #include<math.h>
25 #include "postgres.h"
26 
27 #ifndef _PDP_H
28 #define _PDP_H
29 
30 
31 // Structures and variables which help us in storing the data
32 
33 typedef struct Depot{
34  int id;
35  int x;
36  int y;
37  int demand;
38  int Etime;
39  int Ltime;
40  int Stime;
41  int Pindex;
42  int Dindex;
43 }depot;
44 
45 
46 
47 typedef struct Customer{
48  int id;
49  int x;
50  int y;
51  int demand;
52  int Etime;
53  int Ltime;
54  int Stime;
55  int Pindex;
56  int Dindex;
57  double Ddist;
58  int P;
59  int D;
60 }customer;
61 
62 
63 typedef struct Pickup{
64  int id;
65  int Pid;
66  double Ddist;
67  int Did;
68  int checked;
69 }pickup;
70 
71 
72 
73 typedef struct Vehicle{
74  int capacity;
75  int used_vehicles;
76  int given_vehicles;
77  int speed;
78  int cost;
80 
81 
82 // A module which calculates distance
83 double CalculateDistance(int x1,int y1,int x2,int y2)
84 {
85  return sqrt(((x2-x1)*(x2-x1))+((y2-y1)*(y2-y1)));
86 }
87 
88 /*
89 // DEPOT: With id=0
90 depot ScanDepot(depot d)
91 {
92 
93 scanf("%d",&d.id);
94 scanf("%d",&d.x);
95 scanf("%d",&d.y);
96 scanf("%d",&d.demand);
97 scanf("%d",&d.Etime);
98 scanf("%d",&d.Ltime);
99 scanf("%d",&d.Stime);
100 scanf("%d",&d.Pindex);
101 scanf("%d",&d.Dindex);
102 return d;
103 }
104 
105 // CUSTOMER: WITH id>=1
106 customer ScanCustomer(int id,customer c,depot d)
107 {
108 c.id=id;
109 scanf("%d",&c.x);
110 scanf("%d",&c.y);
111 scanf("%d",&c.demand);
112 scanf("%d",&c.Etime);
113 scanf("%d",&c.Ltime);
114 scanf("%d",&c.Stime);
115 scanf("%d",&c.Pindex);
116 scanf("%d",&c.Dindex);
117 if(c.Pindex==0)
118 {
119 c.P=1;
120 c.D=0;
121 }
122 else if(c.Dindex==0)
123 {
124 c.D=1;
125 c.P=0;
126 }
127 c.Ddist=CalculateDistance(c.x,c.y,d.x,d.y);
128 return c;
129 }
130 
131 
132 //VEHICLE: First Line contains vehicle data
133 VehicleInfo ScanVehicle(VehicleInfo Vehicle)
134 {
135 scanf("%d",&Vehicle.given_vehicles);
136 scanf("%d",&Vehicle.capacity);
137 scanf("%d",&Vehicle.speed);
138 Vehicle.used_vehicles=0;
139 return Vehicle;
140 
141 }
142 
143 
144  */
145 
146 
147 // Part of code: It is used to save some variables and helps if we need to revisit previous state.
148 typedef struct statesave{
149  int twv;
150  int cv;
151  int dis;
152  // vector<int> path;
153  // vector<int> order;
154  int path[1000];
155  int order[1000];
156  int path_length;
157 }State;
158 
159 
160 typedef struct PathElement {
161  int seq;
162  int rid;
163  int nid;
164  int nseq;
165  int cost;
166 } path_element;
167 
168 
169 
170 #ifdef __cplusplus
171 extern "C"
172 #endif
173 int Solver(customer *c, int total_tuples, int vehicle_count, int capacity , char **msg, path_element **results, int *length_results);
174 
175 #ifdef __cplusplus
176 extern "C"
177 #endif
178 
179 
180 
181 #endif
182 
183 
184 
185 
186 
187 
188 
189 
190 
191 
Definition: pdp.hpp:44
Definition: pdp.hpp:57
Definition: pdp.hpp:31