-
Notifications
You must be signed in to change notification settings - Fork 340
/
vehicle.h
76 lines (59 loc) · 1.87 KB
/
vehicle.h
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
66
67
68
69
70
71
72
73
74
75
76
#ifndef VEHICLE_H
#define VEHICLE_H
/*
This file is part of VROOM.
Copyright (c) 2015-2021, Julien Coupey.
All rights reserved (see LICENSE).
*/
#include <string>
#include <unordered_map>
#include "structures/typedefs.h"
#include "structures/vroom/amount.h"
#include "structures/vroom/break.h"
#include "structures/vroom/cost_wrapper.h"
#include "structures/vroom/input/vehicle_step.h"
#include "structures/vroom/location.h"
#include "structures/vroom/time_window.h"
namespace vroom {
struct Vehicle {
const Id id;
std::optional<Location> start;
std::optional<Location> end;
const std::string profile;
const Amount capacity;
const Skills skills;
const TimeWindow tw;
const std::vector<Break> breaks;
const std::string description;
CostWrapper cost_wrapper;
std::vector<VehicleStep> steps;
std::unordered_map<Id, Index> break_id_to_rank;
Vehicle(
Id id,
const std::optional<Location>& start,
const std::optional<Location>& end,
const std::string& profile = DEFAULT_PROFILE,
const Amount& capacity = Amount(0),
const Skills& skills = Skills(),
const TimeWindow& tw = TimeWindow(),
const std::vector<Break>& breaks = std::vector<Break>(),
const std::string& description = "",
double speed_factor = 1.,
const std::vector<VehicleStep>& input_steps = std::vector<VehicleStep>());
bool has_start() const;
bool has_end() const;
bool has_same_locations(const Vehicle& other) const;
bool has_same_profile(const Vehicle& other) const;
Cost duration(Index i, Index j) const {
return static_cast<Cost>(
cost_wrapper.durations_factor *
static_cast<double>((*(cost_wrapper.durations_matrix))[i][j]));
}
Cost cost(Index i, Index j) const {
return static_cast<Cost>(
cost_wrapper.durations_factor *
static_cast<double>((*(cost_wrapper.durations_matrix))[i][j]));
}
};
} // namespace vroom
#endif