Skip to content

Commit

Permalink
(vroom) consting some functions and using a typedef
Browse files Browse the repository at this point in the history
  • Loading branch information
cvvergara committed Aug 25, 2024
1 parent 3fd0d3a commit 2499571
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
16 changes: 9 additions & 7 deletions include/vroom/vroom.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,24 +49,26 @@ namespace vrprouting {
namespace problem {

class Vroom : public vrprouting::Messages {
using MapTW = std::vector<Vroom_time_window_t>;

public:
/** @brief sets m_jobs by adding the Vroom_job_t */
void add_jobs(
const std::vector<Vroom_job_t>&,
const std::vector<Vroom_time_window_t>&);
const MapTW&);
void add_jobs(const Vroom_job_t*, size_t, const Vroom_time_window_t*, size_t);

/** @brief sets m_shipments by adding the Vroom_shipment_t */
void add_shipments(
const std::vector<Vroom_shipment_t>&,
const std::vector<Vroom_time_window_t>&);
const MapTW&);
void add_shipments(const Vroom_shipment_t*, size_t, const Vroom_time_window_t*, size_t);

/** @brief sets m_vehicles by adding the Vroom_vehicle_t */
void add_vehicles(
const std::vector<Vroom_vehicle_t>&,
const std::vector<Vroom_break_t>&,
const std::vector<Vroom_time_window_t>&);
const MapTW&);
void add_vehicles(const Vroom_vehicle_t*, size_t, const Vroom_break_t*, size_t, const Vroom_time_window_t*, size_t);

/** @brief sets m_matrix */
Expand Down Expand Up @@ -94,10 +96,10 @@ class Vroom : public vrprouting::Messages {
const Vroom_vehicle_t&,
const std::vector<Vroom_break_t>&,
const std::vector<Vroom_time_window_t>&) const;
void get_amount(::vroom::Amount, Amount**);
StepType get_job_step_type(::vroom::JOB_TYPE);
StepType get_step_type(::vroom::Step);
std::vector<Vroom_rt> get_results(::vroom::Solution);
void get_amount(const ::vroom::Amount&, Amount**);
StepType get_job_step_type(const ::vroom::JOB_TYPE&);
StepType get_step_type(const ::vroom::Step&);
std::vector<Vroom_rt> get_results(const ::vroom::Solution&);

private:
std::vector<::vroom::Job> m_jobs;
Expand Down
10 changes: 5 additions & 5 deletions src/problem/vroom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,15 +297,15 @@ Vroom::add_matrix(const vrprouting::vroom::Matrix &matrix) {
}

void
Vroom::get_amount(::vroom::Amount vroom_amount, Amount **amount) {
Vroom::get_amount(const ::vroom::Amount &vroom_amount, Amount **amount) {
size_t amount_size = vroom_amount.size();
for (size_t i = 0; i < amount_size; i++) {
*((*amount) + i) = vroom_amount[i];
}
}

StepType
Vroom::get_job_step_type(::vroom::JOB_TYPE vroom_job_type) {
Vroom::get_job_step_type(const ::vroom::JOB_TYPE &vroom_job_type) {
StepType step_type;
switch (vroom_job_type) {
case ::vroom::JOB_TYPE::SINGLE:
Expand All @@ -322,7 +322,7 @@ Vroom::get_job_step_type(::vroom::JOB_TYPE vroom_job_type) {
}

StepType
Vroom::get_step_type(::vroom::Step step) {
Vroom::get_step_type(const ::vroom::Step &step) {
StepType step_type = 0;
switch (step.step_type) {
case ::vroom::STEP_TYPE::START:
Expand All @@ -342,7 +342,7 @@ Vroom::get_step_type(::vroom::Step step) {
}

std::vector<Vroom_rt>
Vroom::get_results(::vroom::Solution solution) {
Vroom::get_results(const ::vroom::Solution &solution) {
std::vector<Vroom_rt> results;
auto routes = solution.routes;
Idx vehicle_seq = 1;
Expand Down Expand Up @@ -508,7 +508,7 @@ Vroom::solve(
static_cast<unsigned>(exploration_level), threads);
results = get_results(solution);
} else {
int timeout_ms = (loading_time <= timeout * 1000) ? (timeout * 1000 - loading_time) : 0;
auto timeout_ms = (loading_time <= timeout * 1000) ? (timeout * 1000 - loading_time) : 0;
auto solution = problem_instance.solve(
static_cast<unsigned>(exploration_level), threads, timeout_ms);
results = get_results(solution);
Expand Down

0 comments on commit 2499571

Please sign in to comment.