-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathvrp_data_problem.py
65 lines (54 loc) · 1.75 KB
/
vrp_data_problem.py
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
###########################
# Problem Data Definition #
###########################
class DataProblem():
"""Stores the data for the problem"""
def __init__(self, locations, num_vehicles, min_parcels, max_parcels, maximum_distance, transport_mode, distance_calculation):
"""Initializes the data for the problem"""
self._num_vehicles = num_vehicles
self._maximum_distance = maximum_distance
self._min_parcels = min_parcels
self._max_parcels = max_parcels
self._locations = locations
self._transport_mode = transport_mode
self._distance_calculation = distance_calculation
self._depot = 0
self._parcels = [loc[2] for loc in locations]
@property
def num_vehicles(self):
"""Gets number of vehicles"""
return self._num_vehicles
@property
def locations(self):
"""Gets locations"""
return self._locations
@property
def num_locations(self):
"""Gets number of locations"""
return len(self.locations)
@property
def depot(self):
"""Gets depot location index"""
return self._depot
@property
def parcels(self):
"""Gets parcels of each location"""
return self._parcels
@property
def min_parcels(self):
return self._min_parcels
@property
def max_parcels(self):
return self._max_parcels
@property
def maximum_distance(self):
return self._maximum_distance
@property
def transport_mode(self):
return self._transport_mode
@property
def distance_calculation(self):
return self._distance_calculation
# remove a point from locations list
def remove_location(self, index):
del self._locations[index]