Skip to content

Commit

Permalink
disable linux arm
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathf committed Jun 26, 2024
1 parent ee090ca commit 3dc0458
Show file tree
Hide file tree
Showing 22 changed files with 153 additions and 106 deletions.
11 changes: 6 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,17 @@ jobs:
conan config set "storage.path=$env:GITHUB_WORKSPACE/conan_data"
conan install --build=openssl --install-folder conan_build .
- name: Set up QEMU
if: matrix.platform == 'linux'
uses: docker/setup-qemu-action@v3
with:
platforms: all
# - name: Set up QEMU
# if: matrix.platform == 'linux'
# uses: docker/setup-qemu-action@v3
# with:
# platforms: all

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

- name: Build wheels
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"));
}
42 changes: 19 additions & 23 deletions src/bind/vehicle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,40 +7,35 @@ namespace py = pybind11;
void init_vehicle(py::module_ &m) {

py::class_<vroom::VehicleCosts>(m, "VehicleCosts")
.def(py::init<vroom::UserCost, vroom::UserCost>(),
"VehicleCost constructor.",
py::arg("fixed") = 0, py::arg("per_hour") = 3600)
.def(py::init<vroom::UserCost, vroom::UserCost>(),
"VehicleCost constructor.", py::arg("fixed") = 0,
py::arg("per_hour") = 3600)
.def_readonly("_fixed", &vroom::VehicleCosts::fixed)
.def_readonly("_per_hour", &vroom::VehicleCosts::per_hour);

py::class_<vroom::CostWrapper>(m, "CostWrapper")
.def(py::init<double, vroom::Cost>(),
"CostWrapper constructor",
py::arg("speed_factor"), py::arg("per_hour"))
.def("set_durations_matrix", &vroom::CostWrapper::set_durations_matrix)
.def("set_costs_matrix", &vroom::CostWrapper::set_costs_matrix)
.def("_get_speed_factor", &vroom::CostWrapper::get_speed_factor)
.def("_get_per_hour", &vroom::CostWrapper::get_per_hour);
.def(py::init<double, vroom::Cost, vroom::Cost>(),
"CostWrapper constructor", py::arg("speed_factor"),
py::arg("per_hour"), py::arg("per_km"))
.def("set_durations_matrix", &vroom::CostWrapper::set_durations_matrix)
.def("set_distances_matrix", &vroom::CostWrapper::set_distances_matrix)
.def("set_costs_matrix", &vroom::CostWrapper::set_costs_matrix);

py::class_<vroom::Vehicle>(m, "Vehicle")
.def(py::init<vroom::Id, std::optional<vroom::Location> &,
std::optional<vroom::Location> &, std::string &,
vroom::Amount &, vroom::Skills &, vroom::TimeWindow &,
std::vector<vroom::Break> &, std::string &, vroom::VehicleCosts, double, size_t,
std::optional<vroom::Duration>,
std::vector<vroom::Break> &, std::string &,
vroom::VehicleCosts, double, std::optional<size_t> &,
std::optional<vroom::UserDuration> &,
std::optional<vroom::UserDistance> &,
std::vector<vroom::VehicleStep> &>(),
"Vehicle constructor.", py::arg("id"), py::arg("start"),
py::arg("end"), py::arg("profile"),
py::arg("capacity"),
py::arg("skills"),
py::arg("time_window"),
py::arg("breaks"),
py::arg("description"),
py::arg("costs"),
py::arg("speed_factor"),
py::arg("max_tasks"),
py::arg("max_travel_time"),
py::arg("steps"))
py::arg("end"), py::arg("profile"), py::arg("capacity"),
py::arg("skills"), py::arg("time_window"), py::arg("breaks"),
py::arg("description"), py::arg("costs"), py::arg("speed_factor"),
py::arg("max_tasks"), py::arg("max_travel_time"),
py::arg("max_distance"), py::arg("steps"))
// .def("has_start", &vroom::Vehicle::has_start)
// .def("has_end", &vroom::Vehicle::has_end)
.def("_has_same_locations", &vroom::Vehicle::has_same_locations)
Expand All @@ -59,5 +54,6 @@ void init_vehicle(py::module_ &m) {
// .def_readwrite("_speed_factor", &vroom::Vehicle::speed_factor)
.def_readonly("_max_tasks", &vroom::Vehicle::max_tasks)
.def_readonly("_max_travel_time", &vroom::Vehicle::max_travel_time)
.def_readonly("_max_distance", &vroom::Vehicle::max_distance)
.def_readonly("_steps", &vroom::Vehicle::steps);
}
1 change: 1 addition & 0 deletions src/vroom/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Vehicle routing open-source optimization machine (VROOM)."""

import sys
from typing import Optional, Sequence
from ._vroom import _main, JOB_TYPE, STEP_TYPE # type: ignore
Expand Down
Loading

0 comments on commit 3dc0458

Please sign in to comment.