Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
- Remove `LOG_LS_OPERATORS` (#1263)
- Update README to clarify high-level purpose and usage of the project (#1264)
- Remove unused breaks_travel_margin members from TWRoute and associated code (#1295)
- Inline small struct methods in `structures` (#1304)

#### CI

Expand Down
34 changes: 0 additions & 34 deletions src/structures/generic/edge.cpp

This file was deleted.

17 changes: 14 additions & 3 deletions src/structures/generic/edge.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ template <class T> class Edge {
T _weight;

public:
Edge(Index first_vertex, Index second_vertex, T weight);
Edge(Index first_vertex, Index second_vertex, T weight)
: _first_vertex(std::min(first_vertex, second_vertex)),
_second_vertex(std::max(first_vertex, second_vertex)),
_weight(weight) {
}

Index get_first_vertex() const {
return _first_vertex;
Expand All @@ -32,9 +36,16 @@ template <class T> class Edge {
return _second_vertex;
};

bool operator<(const Edge& rhs) const;
bool operator<(const Edge& rhs) const {
return (this->_first_vertex < rhs._first_vertex) ||
((this->_first_vertex == rhs._first_vertex) &&
(this->_second_vertex < rhs._second_vertex));
}

bool operator==(const Edge& rhs) const;
bool operator==(const Edge& rhs) const {
return (this->_first_vertex == rhs._first_vertex) &&
(this->_second_vertex == rhs._second_vertex);
}

T get_weight() const {
return _weight;
Expand Down
27 changes: 0 additions & 27 deletions src/structures/vroom/bbox.cpp

This file was deleted.

15 changes: 12 additions & 3 deletions src/structures/vroom/bbox.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,18 @@ class BBox {
std::numeric_limits<Coordinate>::min()};

public:
void extend(Coordinates c);

bool intersects(const BBox& other) const;
void extend(Coordinates c) {
min.lon = std::min(min.lon, c.lon);
min.lat = std::min(min.lat, c.lat);

max.lon = std::max(max.lon, c.lon);
max.lat = std::max(max.lat, c.lat);
}

bool intersects(const BBox& other) const {
return other.min.lon <= max.lon && other.min.lat <= max.lat &&
min.lon <= other.max.lon && min.lat <= other.max.lat;
}
};

} // namespace vroom
Expand Down
17 changes: 0 additions & 17 deletions src/structures/vroom/break.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,4 @@ Break::Break(Id id,
utils::check_tws(tws, id, "break");
}

bool Break::is_valid_start(Duration time) const {
bool valid = false;

for (const auto& tw : tws) {
if (tw.contains(time)) {
valid = true;
break;
}
}

return valid;
}

bool Break::is_valid_for_load(const Amount& load) const {
return !max_load.has_value() || load <= max_load.value();
}

} // namespace vroom
15 changes: 12 additions & 3 deletions src/structures/vroom/break.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,18 @@ struct Break {
std::string description = "",
std::optional<Amount> max_load = std::optional<Amount>());

bool is_valid_start(Duration time) const;

bool is_valid_for_load(const Amount& load) const;
bool is_valid_start(Duration time) const {
for (const auto& tw : tws) {
if (tw.contains(time)) {
return true;
}
}
return false;
}

bool is_valid_for_load(const Amount& load) const {
return !max_load.has_value() || load <= max_load.value();
}
};

} // namespace vroom
Expand Down
61 changes: 0 additions & 61 deletions src/structures/vroom/location.cpp

This file was deleted.

47 changes: 37 additions & 10 deletions src/structures/vroom/location.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,33 +25,60 @@ class Location {
bool _user_index;

public:
explicit Location(Index index);
explicit Location(Index index)
: _index(index), _coords(std::nullopt), _user_index(true) {
}

Location(Index index, const Coordinates& coords);
Location(Index index, const Coordinates& coords)
: _index(index), _coords(OptionalCoordinates(coords)), _user_index(true) {
}

explicit Location(const Coordinates& coords);
explicit Location(const Coordinates& coords)
: _coords(OptionalCoordinates(coords)), _user_index(false) {
}

void set_index(Index index);
void set_index(Index index) {
assert(!_user_index);
_index = index;
}

bool has_coordinates() const;
bool has_coordinates() const {
return _coords.has_value();
}

Index index() const {
return _index;
}

Coordinates coordinates() const;
Coordinates coordinates() const {
assert(this->has_coordinates());
return _coords.value();
}

Coordinate lon() const;
Coordinate lon() const {
assert(this->has_coordinates());
return _coords.value().lon;
}

Coordinate lat() const;
Coordinate lat() const {
assert(this->has_coordinates());
return _coords.value().lat;
}

bool user_index() const;
bool user_index() const {
return _user_index;
}

// Locations are considered identical if they have the same
// user-provided index or if they both have coordinates and those
// are equal. The last part is required for situations with no
// explicit index provided in input.
bool operator==(const Location& other) const;
bool operator==(const Location& other) const {
return (this->user_index() && other.user_index() &&
(this->index() == other.index())) ||
(this->has_coordinates() && other.has_coordinates() &&
(this->lon() == other.lon()) && (this->lat() == other.lat()));
}
};

} // namespace vroom
Expand Down
16 changes: 0 additions & 16 deletions src/structures/vroom/solution/computing_times.cpp

This file was deleted.

2 changes: 1 addition & 1 deletion src/structures/vroom/solution/computing_times.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ struct ComputingTimes {
UserDuration solving{0};
UserDuration routing{0};

ComputingTimes();
ComputingTimes() = default;
};

} // namespace vroom
Expand Down
26 changes: 0 additions & 26 deletions src/structures/vroom/solution/summary.cpp

This file was deleted.

12 changes: 9 additions & 3 deletions src/structures/vroom/solution/summary.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,15 @@ struct Summary {

Violations violations{0, 0};

Summary();

Summary(unsigned routes, unsigned unassigned, const Amount& zero_amount);
Summary() : routes(0), unassigned(0) {
}

Summary(unsigned routes, unsigned unassigned, const Amount& zero_amount)
: routes(routes),
unassigned(unassigned),
delivery(zero_amount),
pickup(zero_amount) {
}
};

} // namespace vroom
Expand Down
Loading