Skip to content

Commit

Permalink
Merge pull request #106 from SebMilardo/upstream-v1.14.0
Browse files Browse the repository at this point in the history
Upstream v1.14.0
  • Loading branch information
jonathf authored Jul 8, 2024
2 parents da2c48d + 4449941 commit 825f15e
Show file tree
Hide file tree
Showing 28 changed files with 170 additions and 107 deletions.
11 changes: 7 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,19 @@ jobs:

- name: Build wheels
if: matrix.platform != 'macos-arm'
uses: pypa/[email protected].1
uses: pypa/[email protected].2
env:
MACOSX_DEPLOYMENT_TARGET: 13.0
CIBW_ARCHS_LINUX: x86_64 aarch64

CC: gcc-13
CXX: g++-13

- name: Build wheels
if: matrix.platform == 'macos-arm'
uses: pypa/[email protected].1
uses: pypa/[email protected].2
env:
MACOSX_DEPLOYMENT_TARGET: 14.0
CC: gcc-13
CXX: g++-13

- name: Verify clean directory
run: git diff --exit-code
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ format:
@echo format python code with black
@python -m black src/vroom
@echo format c++ code with clang-format
@find src -type f -name '*.cpp' | xargs -I{} clang-format-10 -i -style=file {}
@find src -type f -name '*.cpp' | xargs -I{} clang-format-14 -i -style=file {}
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ Installation of the pre-compiled releases should be as simple as:
The current minimal requirements are as follows:

* Python at least version 3.9.
* Intel MacOS (or Rosetta2) at least version 13.0.
* Intel MacOS (or Rosetta2) at least version 14.0.
* Apple Silicon MacOS at least version 14.0.
* Windows on AMD64.
* Linux on x86_64 and Aarch64 given glibc at least version 2.28.
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,5 @@ apk add openssl-dev
[tool.cibuildwheel.macos]

before-all = """
brew install [email protected]
brew install --ignore-dependencies asio
"""
2 changes: 2 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
include_dirs.append(f"{prefix}/include")
extra_link_args.insert(0, f"-L{prefix}/lib")
extra_link_args.insert(0, f"-L{prefix}/opt/[email protected]/lib")
extra_link_args.append(f"-Wl,-ld_classic")

# try conan dependency resolution
conanfile = tuple(Path(__file__).parent.resolve().rglob("conanbuildinfo.json"))
Expand All @@ -76,6 +77,7 @@
libraries=libraries,
extra_compile_args=extra_compile_args,
extra_link_args=extra_link_args,
cxx_std=20
),
]

Expand Down
15 changes: 11 additions & 4 deletions src/_vroom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "algorithms/heuristics/heuristics.cpp"
#include "algorithms/local_search/local_search.cpp"
#include "algorithms/local_search/operator.cpp"
#include "algorithms/local_search/top_insertions.cpp"
#include "algorithms/validation/check.h"

// #include "routing/libosrm_wrapper.cpp"
Expand All @@ -41,13 +42,15 @@
#include "structures/typedefs.h"

#include "structures/generic/edge.cpp"
#include "structures/generic/matrix.cpp"
#include "structures/generic/undirected_graph.cpp"

#include "structures/vroom/cost_wrapper.cpp"
#include "structures/vroom/raw_route.cpp"
#include "structures/vroom/solution_state.cpp"
#include "structures/vroom/tw_route.cpp"

#include "structures/vroom/bbox.cpp"
#include "structures/vroom/solution/computing_times.cpp"
#include "structures/vroom/solution/violations.cpp"

Expand All @@ -57,16 +60,18 @@
#include "problems/cvrp/operators/intra_exchange.cpp"
#include "problems/cvrp/operators/intra_mixed_exchange.cpp"
#include "problems/cvrp/operators/intra_or_opt.cpp"
#include "problems/cvrp/operators/intra_two_opt.cpp"
#include "problems/cvrp/operators/intra_relocate.cpp"
#include "problems/cvrp/operators/intra_two_opt.cpp"
#include "problems/cvrp/operators/mixed_exchange.cpp"
#include "problems/cvrp/operators/or_opt.cpp"
#include "problems/cvrp/operators/pd_shift.cpp"
#include "problems/cvrp/operators/priority_replace.cpp"
#include "problems/cvrp/operators/relocate.cpp"
#include "problems/cvrp/operators/reverse_two_opt.cpp"
#include "problems/cvrp/operators/route_exchange.cpp"
#include "problems/cvrp/operators/route_split.cpp"
#include "problems/cvrp/operators/swap_star.cpp"
#include "problems/cvrp/operators/tsp_fix.cpp"
#include "problems/cvrp/operators/two_opt.cpp"
#include "problems/cvrp/operators/unassigned_exchange.cpp"
#include "problems/vrp.cpp"
Expand All @@ -76,16 +81,18 @@
#include "problems/vrptw/operators/intra_exchange.cpp"
#include "problems/vrptw/operators/intra_mixed_exchange.cpp"
#include "problems/vrptw/operators/intra_or_opt.cpp"
#include "problems/vrptw/operators/intra_two_opt.cpp"
#include "problems/vrptw/operators/intra_relocate.cpp"
#include "problems/vrptw/operators/intra_two_opt.cpp"
#include "problems/vrptw/operators/mixed_exchange.cpp"
#include "problems/vrptw/operators/or_opt.cpp"
#include "problems/vrptw/operators/pd_shift.cpp"
#include "problems/vrptw/operators/priority_replace.cpp"
#include "problems/vrptw/operators/relocate.cpp"
#include "problems/vrptw/operators/reverse_two_opt.cpp"
#include "problems/vrptw/operators/route_exchange.cpp"
#include "problems/vrptw/operators/route_split.cpp"
#include "problems/vrptw/operators/swap_star.cpp"
#include "problems/vrptw/operators/tsp_fix.cpp"
#include "problems/vrptw/operators/two_opt.cpp"
#include "problems/vrptw/operators/unassigned_exchange.cpp"
#include "problems/vrptw/vrptw.cpp"
Expand All @@ -94,7 +101,7 @@
#include "problems/tsp/heuristics/local_search.cpp"
#include "problems/tsp/tsp.cpp"

#include "utils/helpers.h"
#include "utils/helpers.cpp"
#include "utils/version.cpp"

namespace py = pybind11;
Expand Down Expand Up @@ -137,7 +144,7 @@ PYBIND11_MODULE(_vroom, m) {
.def(py::init<>())
.def(py::init([](const vroom::Duration lead_time,
const vroom::Duration delay,
const std::unordered_set<vroom::VIOLATION> types) {
std::unordered_set<vroom::VIOLATION> types) {
return new vroom::Violations(lead_time, delay, std::move(types));
}))
.def(py::self += py::self)
Expand Down
4 changes: 2 additions & 2 deletions src/bind/amount.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ void init_amount(py::module_ &m) {
py::format_descriptor<int64_t>::format(), 1,
{a.size()}, {sizeof(int64_t)});
})
.def("_lshift", [](const vroom::Amount &a,
const vroom::Amount &b) { return a << b; })
.def("_lshift",
[](const vroom::Amount &a, const vroom::Amount &b) { return a < b; })
.def("_le", [](const vroom::Amount &a,
const vroom::Amount &b) { return a <= b; })
.def("_push_back", &vroom::Amount::push_back)
Expand Down
9 changes: 5 additions & 4 deletions src/bind/break.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ void init_break(py::module_ &m) {

py::class_<vroom::Break>(m, "Break")
.def(py::init([](vroom::Break &b) { return b; }), py::arg("break"))
.def(py::init<vroom::Id, std::vector<vroom::TimeWindow> &,
vroom::Duration, std::string &, std::optional<vroom::Amount> &>(),
py::arg("id"), py::arg("time_windows"), py::arg("service"),
py::arg("description"), py::arg("max_load"))
.def(
py::init<vroom::Id, std::vector<vroom::TimeWindow> &, vroom::Duration,
std::string &, std::optional<vroom::Amount> &>(),
py::arg("id"), py::arg("time_windows"), py::arg("service"),
py::arg("description"), py::arg("max_load"))
.def("_is_valid_start", &vroom::Break::is_valid_start, py::arg("time"))
.def_readwrite("_id", &vroom::Break::id)
.def_readwrite("_time_windows", &vroom::Break::tws)
Expand Down
2 changes: 1 addition & 1 deletion src/bind/generic/matrix.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <pybind11/pybind11.h>

#include "structures/generic/matrix.cpp"
#include "structures/generic/matrix.h"

namespace py = pybind11;

Expand Down
6 changes: 6 additions & 0 deletions src/bind/input/input.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <fstream>
#include <map>

#include <pybind11/operators.h>

Expand Down Expand Up @@ -32,6 +33,11 @@ void init_input(py::module_ &m) {
vroom::Matrix<vroom::UserDuration> &m) {
self.set_durations_matrix(profile, std::move(m));
})
.def("_set_distances_matrix",
[](vroom::Input &self, const std::string &profile,
vroom::Matrix<vroom::UserDistance> &m) {
self.set_distances_matrix(profile, std::move(m));
})
.def("_set_costs_matrix",
[](vroom::Input &self, const std::string &profile,
vroom::Matrix<vroom::UserCost> &m) {
Expand Down
3 changes: 2 additions & 1 deletion src/bind/location.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
void init_location(py::module_ &m) {

py::class_<vroom::Coordinates>(m, "Coordinates")
.def(py::init<vroom::Coordinate, vroom::Coordinate>(), py::arg("lon"), py::arg("lat"));
.def(py::init<vroom::Coordinate, vroom::Coordinate>(), py::arg("lon"),
py::arg("lat"));

py::class_<vroom::Location>(m, "Location")
.def(py::init<vroom::Index>(), py::arg("index"))
Expand Down
28 changes: 15 additions & 13 deletions src/bind/solution/route.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,27 @@ void init_route(py::module_ &m) {

py::class_<vroom::Route>(m, "Route")
.def(py::init<>())
.def(py::init([](vroom::Id vehicle, std::vector<vroom::Step> &steps,
vroom::Cost cost, vroom::Duration setup,
vroom::Duration service, vroom::Duration duration,
vroom::Duration waiting_time, vroom::Priority priority,
const vroom::Amount &delivery,
const vroom::Amount &pickup, const std::string &profile,
const std::string &description,
const vroom::Violations &violations) {
return new vroom::Route(vehicle, std::move(steps), cost, setup, service,
duration, waiting_time, priority, delivery,
pickup, profile, description,
std::move(violations));
}))
.def(py::init(
[](vroom::Id vehicle, std::vector<vroom::Step> &steps,
vroom::UserCost cost, vroom::UserDuration duration,
vroom::UserDistance distance, vroom::UserDuration setup,
vroom::UserDuration service, vroom::UserDuration waiting_time,
vroom::Priority priority, const vroom::Amount &delivery,
const vroom::Amount &pickup, const std::string &profile,
const std::string &description, vroom::Violations &violations) {
return new vroom::Route(vehicle, std::move(steps), cost, duration,
distance, setup, service, waiting_time,
priority, delivery, pickup, profile,
description, std::move(violations));
}))

.def_readwrite("vehicle", &vroom::Route::vehicle)
.def_readonly("steps", &vroom::Route::steps)
.def_readwrite("cost", &vroom::Route::cost)
.def_readwrite("setup", &vroom::Route::setup)
.def_readwrite("service", &vroom::Route::service)
.def_readwrite("duration", &vroom::Route::duration)
.def_readwrite("distance", &vroom::Route::distance)
.def_readwrite("waiting_time", &vroom::Route::waiting_time)
.def_readwrite("priority", &vroom::Route::priority)
.def_readwrite("delivery", &vroom::Route::delivery)
Expand Down
31 changes: 16 additions & 15 deletions src/bind/solution/solution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,10 @@ void init_solution(py::module_ &m) {

py::class_<vroom::Solution>(m, "Solution")
.def(py::init([](vroom::Solution s) { return s; }))
.def(py::init<unsigned, std::string>())
.def(py::init([](unsigned code, unsigned amount_size,
.def(py::init([](const vroom::Amount &zero_amount,
std::vector<vroom::Route> &routes,
std::vector<vroom::Job> &unassigned) {
return new vroom::Solution(code, amount_size, std::move(routes),
return new vroom::Solution(zero_amount, std::move(routes),
std::move(unassigned));
}))
.def("_routes_numpy",
Expand Down Expand Up @@ -72,14 +71,18 @@ void init_solution(py::module_ &m) {
strncpy(ptr[idx].type, type.c_str(), 9);
strncpy(ptr[idx].description, step.description.c_str(), 40);

ptr[idx].longitude = step.location.has_coordinates()
? step.location.lon()
: NA_SUBSTITUTE;
ptr[idx].latitude = step.location.has_coordinates()
? step.location.lat()
: NA_SUBSTITUTE;
ptr[idx].location_index = step.location.user_index()
? step.location.index()
ptr[idx].longitude =
step.location.has_value() &&
step.location.value().has_coordinates()
? step.location.value().coordinates().lon
: NA_SUBSTITUTE;
ptr[idx].latitude =
step.location.has_value() &&
step.location.value().has_coordinates()
? step.location.value().coordinates().lat
: NA_SUBSTITUTE;
ptr[idx].location_index = step.location.has_value()
? step.location.value().index()
: NA_SUBSTITUTE;

ptr[idx].id = (step.step_type == vroom::STEP_TYPE::JOB or
Expand All @@ -103,16 +106,14 @@ void init_solution(py::module_ &m) {
[](vroom::Solution solution) {
py::scoped_ostream_redirect stream(
std::cout, py::module_::import("sys").attr("stdout"));
vroom::io::write_to_json(solution, false, "");
vroom::io::write_to_json(solution, "", false);
})
.def("_geometry_solution_json",
[](vroom::Solution solution) {
py::scoped_ostream_redirect stream(
std::cout, py::module_::import("sys").attr("stdout"));
vroom::io::write_to_json(solution, true, "");
vroom::io::write_to_json(solution, "", true);
})
.def_readwrite("code", &vroom::Solution::code)
.def_readwrite("error", &vroom::Solution::error)
.def_readonly("summary", &vroom::Solution::summary)
.def_readonly("_routes", &vroom::Solution::routes)
.def_readonly("unassigned", &vroom::Solution::unassigned);
Expand Down
2 changes: 1 addition & 1 deletion src/bind/solution/summary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ void init_summary(py::module_ &m) {

py::class_<vroom::Summary>(m, "Summary")
.def(py::init<>())
.def(py::init<unsigned, unsigned, unsigned>())
.def(py::init<unsigned, unsigned, const vroom::Amount &>())
.def_readwrite("cost", &vroom::Summary::cost)
.def_readonly("routes", &vroom::Summary::routes)
.def_readonly("unassigned", &vroom::Summary::unassigned)
Expand Down
6 changes: 4 additions & 2 deletions src/bind/time_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ void init_time_window(py::module_ &m) {
.def(py::init([]() { return new vroom::TimeWindow(); }))
.def(py::init([](vroom::Duration start, vroom::Duration end) {
return new vroom::TimeWindow(start, end);
}), py::arg("start"), py::arg("end"))
}),
py::arg("start"), py::arg("end"))
.def("_is_default", &vroom::TimeWindow::is_default)
.def(py::self < py::self)
.def_readwrite("_start", &vroom::TimeWindow::start)
.def_readwrite("_end", &vroom::TimeWindow::end)
.def_readonly_static("_DEFAULT_LENGTH", &vroom::TimeWindow::default_length);
.def_readonly_static("_DEFAULT_LENGTH",
&vroom::TimeWindow::default_length);
}
22 changes: 6 additions & 16 deletions src/bind/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,10 @@

void init_utils(py::module_ &m) {

m.def(
"scale_from_user_duration",
&vroom::utils::scale_from_user_duration,
py::arg("duration")
);
m.def(
"scale_to_user_duration",
&vroom::utils::scale_to_user_duration,
py::arg("duration")
);
m.def(
"scale_to_user_cost",
&vroom::utils::scale_to_user_cost,
py::arg("cost")
);

m.def("scale_from_user_duration", &vroom::utils::scale_from_user_duration,
py::arg("duration"));
m.def("scale_to_user_duration", &vroom::utils::scale_to_user_duration,
py::arg("duration"));
m.def("scale_to_user_cost", &vroom::utils::scale_to_user_cost,
py::arg("cost"));
}
Loading

0 comments on commit 825f15e

Please sign in to comment.