vrpRouting  0.3
vrprouting::problem::Vehicle_pickDeliver Class Reference

#include "vehicle_pickDeliver.h"

Inheritance diagram for vrprouting::problem::Vehicle_pickDeliver:
Collaboration diagram for vrprouting::problem::Vehicle_pickDeliver:

Public Member Functions

 Vehicle_pickDeliver ()=delete
 
 Vehicle_pickDeliver (const Vehicle_pickDeliver &)=default
 
 Vehicle_pickDeliver (Idx p_idx, Id p_id, const Vehicle_node &p_starting_site, const Vehicle_node &p_ending_site, const std::vector< int64_t > &p_stops, PAmount p_capacity, Speed p_speed, const Orders &p_orders)
 
PAmount capacity () const
 returns the capacity of the vehicle More...
 
int cvTot () const
 
TInterval duration () const
 duration of vehicle while not in a "depot" More...
 
bool empty () const
 
bool empty () const
 
const Vehicle_nodeend_site () const
 
void erase (const Order &order)
 erases the order from the vehicle More...
 
void erase (const Vehicle_node &node)
 deletes a node if it exists More...
 
void erase (size_t pos)
 
void evaluate ()
 
void evaluate (size_t from)
 
Identifiers< size_t > & feasible_orders ()
 returns the set of feasible orders for modification More...
 
const Identifiers< size_t > & feasible_orders () const
 returns the set of feasible orders More...
 
Order get_first_order () const
 
std::vector< Solution_rtget_postgres_result (int vid) const
 
std::vector< Idget_stops () const
 
bool has_cv () const
 
bool has_order (const Order &order) const
 does the vehicle has the order? More...
 
bool has_twv () const
 
bool hillClimb (const Order &order)
 Inserts an order with hill Climb approach. More...
 
void insert (size_t pos, const Vehicle_node &node)
 
void insert_node (size_t pos, const Vehicle_node &node)
 
void invariant () const
 
void invariant () const
 
bool is_feasible () const
 
bool is_feasible () const
 
bool is_ok () const
 
bool is_order_feasible (const Order &order) const
 
bool is_phony () const
 
bool is_real () const
 
size_t length () const
 
Pgr_messagesmsg ()
 
double objective () const
 Get the value of the objective function. More...
 
const Ordersorders () const
 
Identifiers< size_t > orders_in_vehicle () const
 returns the number of orders in the vehicle More...
 
size_t orders_size () const
 
std::string path_str () const
 
size_t pop_back ()
 
size_t pop_front ()
 
void push_back (const Order &order)
 puts an order at the end of the truck More...
 
void push_front (const Order &order)
 Puts an order at the end front of the truck. More...
 
bool semiLIFO (const Order &order)
 Inserts an order In semi-Lifo (almost last in first out) order. More...
 
void set_initial_solution (const Orders &, Identifiers< size_t > &, Identifiers< size_t > &, TTimestamp, bool)
 sets the initial solution given by the user More...
 
void set_unmovable (TTimestamp execution_date)
 sets as unmovable the orders that start before the execution date More...
 
Speed speed () const
 the speed of the vehicle More...
 
const Vehicle_nodestart_site () const
 
std::string tau () const
 
TInterval total_service_time () const
 total time spent moving from one node to another More...
 
TInterval total_travel_time () const
 total time spent moving from one node to another More...
 
TInterval total_wait_time () const
 duration of vehicle while waiting for a node to open More...
 
int twvTot () const
 
Inherited functions from Identifier
int64_t id () const
 get the original id More...
 
size_t idx () const
 get the internal index More...
 
void reset_id (int64_t)
 change the original id More...
 
Inherited functions from Identifier
int64_t id () const
 get the original id More...
 
size_t idx () const
 get the internal index More...
 
void reset_id (int64_t)
 change the original id More...
 
Inherited functions from Identifier
int64_t id () const
 get the original id More...
 
size_t idx () const
 get the internal index More...
 
void reset_id (int64_t)
 change the original id More...
 
Inherited functions from Identifier
int64_t id () const
 get the original id More...
 
size_t idx () const
 get the internal index More...
 
void reset_id (int64_t)
 change the original id More...
 
Inherited functions from Identifier
int64_t id () const
 get the original id More...
 
size_t idx () const
 get the internal index More...
 
void reset_id (int64_t)
 change the original id More...
 
Inherited functions from Identifier
int64_t id () const
 get the original id More...
 
size_t idx () const
 get the internal index More...
 
void reset_id (int64_t)
 change the original id More...
 

Protected Member Functions

std::pair< size_t, size_t > drop_position_limits (const Vehicle_node &node) const
 
void erase (const Vehicle_node &node)
 deletes a node if it exists More...
 
void erase (size_t pos)
 
void erase_node (size_t pos)
 
void evaluate (size_t from)
 
size_t getDropPosLowLimit (const Vehicle_node &node) const
 
size_t getPosHighLimit (const Vehicle_node &node) const
 Get the highest position on the path where node can be placed. More...
 
size_t getPosLowLimit (const Vehicle_node &node) const
 Get the lowest position on the path where node can be placed. More...
 
void insert (size_t pos, const Vehicle_node &node)
 
void insert_node (size_t pos, const Vehicle_node &node)
 
std::pair< size_t, size_t > position_limits (const Vehicle_node &node) const
 Get the limits to insert the node. More...
 
void push_back (const Vehicle_node &node)
 
void push_back_node (const Vehicle_node &node)
 
void push_front (const Vehicle_node &node)
 
void push_front_node (const Vehicle_node &node)
 
void swap (size_t i, size_t j)
 

Protected Attributes

elements
 STL member. More...
 
double m_cost
 
Identifiers< size_t > m_feasible_orders
 orders that fit in the truck More...
 
Pgr_messages m_msg
 
Orders m_orders
 
Identifiers< size_t > m_orders_in_vehicle
 orders inserted in this vehicle More...
 
int m_user_cv {0}
 Time window violations on solution. More...
 
int m_user_twv {0}
 Time window violations on solution. More...
 

Private Attributes

PAmount m_capacity
 
int64_t m_id
 
size_t m_idx
 
Speed m_speed = 1.0
 
std::vector< int64_t > m_stops
 order ids of an initial solution given by the user [1,2,1,3,3,2] = P1 P2 D1 P3 D3 D2 More...
 

Friends

std::ostream & operator<< (std::ostream &log, const Vehicle_pickDeliver &v)
 

Detailed Description

Definition at line 46 of file vehicle_pickDeliver.h.

Constructor & Destructor Documentation

◆ Vehicle_pickDeliver() [1/3]

vrprouting::problem::Vehicle_pickDeliver::Vehicle_pickDeliver ( )
delete

◆ Vehicle_pickDeliver() [2/3]

vrprouting::problem::Vehicle_pickDeliver::Vehicle_pickDeliver ( const Vehicle_pickDeliver )
default

◆ Vehicle_pickDeliver() [3/3]

vrprouting::problem::Vehicle_pickDeliver::Vehicle_pickDeliver ( Idx  p_idx,
Id  p_id,
const Vehicle_node p_starting_site,
const Vehicle_node p_ending_site,
const std::vector< int64_t > &  p_stops,
PAmount  p_capacity,
Speed  p_speed,
const Orders p_orders 
)
inline

Definition at line 82 of file vehicle_pickDeliver.h.

90  :
91  Vehicle(p_idx, p_id, p_starting_site, p_ending_site, p_capacity, p_speed),
92  m_cost((std::numeric_limits<double>::max)()),
95  m_orders(p_orders),
96  m_stops(p_stops) {}

Member Function Documentation

◆ capacity()

PAmount vrprouting::problem::Vehicle::capacity ( ) const
inherited

returns the capacity of the vehicle

Returns
the capacity of the vehicle

Definition at line 66 of file vehicle.cpp.

66 {return m_capacity;}

References vrprouting::problem::Vehicle::m_capacity.

Referenced by vrprouting::problem::Vehicle::evaluate().

◆ cvTot()

int vrprouting::problem::Vehicle::cvTot ( ) const
inherited

◆ drop_position_limits()

std::pair< size_t, size_t > vrprouting::problem::Vehicle::drop_position_limits ( const Vehicle_node node) const
protectedinherited

Definition at line 426 of file vehicle.cpp.

426  {
427  size_t high = getPosHighLimit(node);
428  size_t low = getDropPosLowLimit(node);
429  return std::make_pair(low, high);
430 }

References vrprouting::problem::Vehicle::getDropPosLowLimit(), and vrprouting::problem::Vehicle::getPosHighLimit().

Referenced by semiLIFO().

◆ duration()

TInterval vrprouting::problem::Vehicle::duration ( ) const
inherited

duration of vehicle while not in a "depot"

Returns
0 when the Vehicle is phony
duration of vehicle while not in a stop or ending site

Definition at line 72 of file vehicle.cpp.

72 {return is_phony()? 0 : back().arrival_time() - front().departure_time();}

References vrprouting::problem::Vehicle::is_phony().

Referenced by vrprouting::problem::Solution::duration(), vrprouting::problem::operator<(), and vrprouting::problem::Vehicle::tau().

◆ empty() [1/2]

bool vrprouting::problem::Vehicle::empty

◆ empty() [2/2]

bool vrprouting::problem::Vehicle::empty ( ) const
inherited

Definition at line 112 of file vehicle.cpp.

112 {return size() <= 2;}

Referenced by get_first_order(), pop_back(), and pop_front().

◆ end_site()

const Vehicle_node & vrprouting::problem::Vehicle::end_site ( ) const
inherited

Definition at line 124 of file vehicle.cpp.

124 {return back();}

Referenced by vrprouting::problem::Vehicle::is_ok().

◆ erase() [1/5]

void vrprouting::problem::Vehicle_pickDeliver::erase ( const Order order)

erases the order from the vehicle

Parameters
[in]orderorder to be removed from the vehicle
Precondition
has_order(order)
Postcondition
!has_order(order)

Definition at line 154 of file vehicle_pickDeliver.cpp.

154  {
155  pgassert(has_order(order));
156  erase(order.pickup());
157  erase(order.delivery());
158  m_orders_in_vehicle -= order.idx();
159  pgassert(!has_order(order));
160 }

References vrprouting::problem::Order::delivery(), has_order(), vrprouting::Identifier::idx(), m_orders_in_vehicle, pgassert, and vrprouting::problem::Order::pickup().

Referenced by vrprouting::initialsol::simple::Initial_solution::do_while_feasible(), hillClimb(), vrprouting::optimizers::simple::Optimize::move_order(), pop_back(), pop_front(), semiLIFO(), set_initial_solution(), and vrprouting::optimizers::simple::Optimize::swap_order().

◆ erase() [2/5]

void vrprouting::problem::Vehicle::erase

deletes a node if it exists

Parameters
[in]node
Precondition
the node can not be S or E
S .... [node.idx()] .... E
Postcondition
S .... .... E

Definition at line 184 of file vehicle.cpp.

184  {
185  pgassert(!node.is_start() && !node.is_end());
186 #if 0
187  /* TODO this works, but somehow gives docqueries give different results */
188  std::deque<Vehicle_node>::erase(
189  std::remove_if(begin(), end(),
190  [&](const Vehicle_node& n) {return n.idx() == idx();}), end());
191  evaluate();
192 #else
193  for (size_t pos = 0 ; pos < size() ; ++pos) {
194  if (node.idx() == at(pos).idx()) {
195  erase(pos);
196  break;
197  }
198  }
199 #endif
200 }

◆ erase() [3/5]

void vrprouting::problem::Vehicle::erase ( const Vehicle_node node)
protectedinherited

deletes a node if it exists

Parameters
[in]node
Precondition
the node can not be S or E
S .... [node.idx()] .... E
Postcondition
S .... .... E

Definition at line 184 of file vehicle.cpp.

184  {
185  pgassert(!node.is_start() && !node.is_end());
186 #if 0
187  /* TODO this works, but somehow gives docqueries give different results */
188  std::deque<Vehicle_node>::erase(
189  std::remove_if(begin(), end(),
190  [&](const Vehicle_node& n) {return n.idx() == idx();}), end());
191  evaluate();
192 #else
193  for (size_t pos = 0 ; pos < size() ; ++pos) {
194  if (node.idx() == at(pos).idx()) {
195  erase(pos);
196  break;
197  }
198  }
199 #endif
200 }

References vrprouting::problem::Vehicle::erase(), vrprouting::problem::Vehicle::evaluate(), vrprouting::Identifier::idx(), vrprouting::problem::Tw_node::is_end(), vrprouting::problem::Tw_node::is_start(), and pgassert.

◆ erase() [4/5]

void vrprouting::problem::Vehicle::erase

Definition at line 172 of file vehicle.cpp.

172  {
173  erase_node(pos);
174  evaluate(pos);
175 }

◆ erase() [5/5]

void vrprouting::problem::Vehicle::erase ( size_t  pos)
protectedinherited

Definition at line 172 of file vehicle.cpp.

172  {
173  erase_node(pos);
174  evaluate(pos);
175 }

References vrprouting::problem::Vehicle::erase_node(), and vrprouting::problem::Vehicle::evaluate().

Referenced by vrprouting::problem::Vehicle::erase().

◆ erase_node()

void vrprouting::problem::Vehicle::erase_node ( size_t  pos)
protectedinherited

Definition at line 152 of file vehicle.cpp.

152  {
153  using difference_type = std::vector<double>::difference_type;
154  pgassert(pos < size() - 1 && static_cast<difference_type>(pos) > 0);
155  std::deque<Vehicle_node>::erase(std::deque<Vehicle_node>::begin() + static_cast<difference_type>(pos));
156 }

References pgassert.

Referenced by vrprouting::problem::Vehicle::erase(), hillClimb(), vrprouting::problem::Vehicle::pop_back(), and vrprouting::problem::Vehicle::pop_front().

◆ evaluate() [1/3]

void vrprouting::problem::Vehicle::evaluate

Definition at line 126 of file vehicle.cpp.

126 {evaluate(0);}

◆ evaluate() [2/3]

void vrprouting::problem::Vehicle::evaluate
Parameters
[in]fromThe position in the path for evaluation to the end of the path.

Definition at line 131 of file vehicle.cpp.

131  {
132  invariant();
133  // preconditions
134  pgassert(from < size());
135 
136  using difference_type = std::vector<Vehicle_node>::difference_type;
137  auto node = begin() + static_cast<difference_type>(from);
138 
139  while (node != end()) {
140  if (node == begin()) {
141  node->evaluate(capacity());
142  } else {
143  node->evaluate(*(node - 1), capacity(), speed());
144  }
145 
146  ++node;
147  }
148  invariant();
149 }

◆ evaluate() [3/3]

void vrprouting::problem::Vehicle::evaluate ( size_t  from)
protectedinherited
Parameters
[in]fromThe position in the path for evaluation to the end of the path.

Definition at line 131 of file vehicle.cpp.

131  {
132  invariant();
133  // preconditions
134  pgassert(from < size());
135 
136  using difference_type = std::vector<Vehicle_node>::difference_type;
137  auto node = begin() + static_cast<difference_type>(from);
138 
139  while (node != end()) {
140  if (node == begin()) {
141  node->evaluate(capacity());
142  } else {
143  node->evaluate(*(node - 1), capacity(), speed());
144  }
145 
146  ++node;
147  }
148  invariant();
149 }

References vrprouting::problem::Vehicle::capacity(), vrprouting::problem::Vehicle::invariant(), pgassert, and vrprouting::problem::Vehicle::speed().

◆ feasible_orders() [1/2]

Identifiers<size_t>& vrprouting::problem::Vehicle_pickDeliver::feasible_orders ( )
inline

◆ feasible_orders() [2/2]

const Identifiers<size_t>& vrprouting::problem::Vehicle_pickDeliver::feasible_orders ( ) const
inline

returns the set of feasible orders

Definition at line 102 of file vehicle_pickDeliver.h.

102 {return m_feasible_orders;}

References m_feasible_orders.

◆ get_first_order()

Order vrprouting::problem::Vehicle_pickDeliver::get_first_order ( ) const
inline

Definition at line 131 of file vehicle_pickDeliver.h.

131  {
132  pgassert(!empty());
133  return orders()[at(1).idx()];
134  }

References vrprouting::problem::Vehicle::empty(), orders(), and pgassert.

◆ get_postgres_result()

std::vector< Solution_rt > vrprouting::problem::Vehicle::get_postgres_result ( int  vid) const
inherited
Returns
the vehicle's path in a structure for postgres
Parameters
[in]vidit is the vid-th vehicle in the solution

Definition at line 292 of file vehicle.cpp.

292  {
293  std::vector<Solution_rt> result;
294  int stop_seq(1);
295  for (const auto &p_stop : *this) {
296  result.push_back(p_stop.get_postgres_result(vid, id(), stop_seq));
297  ++stop_seq;
298  }
299  return result;
300 }

◆ get_stops()

std::vector< Id > vrprouting::problem::Vehicle::get_stops ( ) const
inherited
Returns
container for postgres

Definition at line 306 of file vehicle.cpp.

306  {
307  if (is_phony()) return std::vector<Id>();
308  std::vector<Id> result;
309  for (const auto &p_stop : *this) {
310  if (p_stop.is_start() || p_stop.is_end()) continue;
311  result.push_back(p_stop.order());
312  }
313  return result;
314 }

References vrprouting::problem::Vehicle::is_phony().

◆ getDropPosLowLimit()

size_t vrprouting::problem::Vehicle::getDropPosLowLimit ( const Vehicle_node node) const
protectedinherited

Definition at line 331 of file vehicle.cpp.

331  {
332  invariant();
333 
334  size_t low = 0;
335  size_t high = size();
336  size_t low_limit = high;
337 
338  /* J == m_path[low_limit - 1] */
339  while (low_limit > low
340  && at(low_limit - 1).is_compatible_IJ(nodeI, speed())
341  && !at(low_limit - 1).is_pickup()) {
342  --low_limit;
343  }
344 
345  invariant();
346  return low_limit;
347 }

References vrprouting::problem::Vehicle::invariant(), and vrprouting::problem::Vehicle::speed().

Referenced by vrprouting::problem::Vehicle::drop_position_limits().

◆ getPosHighLimit()

size_t vrprouting::problem::Vehicle::getPosHighLimit ( const Vehicle_node node) const
protectedinherited

Get the highest position on the path where node can be placed.

Definition at line 397 of file vehicle.cpp.

397  {
398  invariant();
399 
400  size_t low = 0;
401  size_t high = size();
402  size_t high_limit = low;
403 
404  /* I == m_path[high_limit] */
405  while (high_limit < high
406  && nodeJ.is_compatible_IJ(at(high_limit), speed())) {
407  ++high_limit;
408  }
409 
410  invariant();
411  return high_limit;
412 }

References vrprouting::problem::Vehicle::invariant(), vrprouting::problem::Tw_node::is_compatible_IJ(), and vrprouting::problem::Vehicle::speed().

Referenced by vrprouting::problem::Vehicle::drop_position_limits(), and vrprouting::problem::Vehicle::position_limits().

◆ getPosLowLimit()

size_t vrprouting::problem::Vehicle::getPosLowLimit ( const Vehicle_node nodeI) const
protectedinherited

Get the lowest position on the path where node can be placed.

Returns
the lowest position where the node can be placed
Parameters
[in]nodeIstart searching from postition low = pos(E)

S 1 2 3 4 5 6 7 ..... E node -> E node -> ... node -> 7 node -> 6 node -> 5 node /-> 4

return low_limit = 5

Definition at line 366 of file vehicle.cpp.

366  {
367  invariant();
368 
369  size_t low = 0;
370  size_t high = size();
371  size_t low_limit = high;
372 
373  /* J == m_path[low_limit - 1] */
374  while (low_limit > low
375  && at(low_limit - 1).is_compatible_IJ(nodeI)) {
376  --low_limit;
377  }
378 
379  invariant();
380  return low_limit;
381 }

References vrprouting::problem::Vehicle::invariant().

Referenced by vrprouting::problem::Vehicle::position_limits().

◆ has_cv()

bool vrprouting::problem::Vehicle::has_cv ( ) const
inherited

◆ has_order()

◆ has_twv()

bool vrprouting::problem::Vehicle::has_twv ( ) const
inherited

◆ hillClimb()

bool vrprouting::problem::Vehicle_pickDeliver::hillClimb ( const Order order)

Inserts an order with hill Climb approach.

Parameters
[in]orderto be inserted
Precondition
invariant(order)
!has_order(order)
Postcondition
has_order(order)
invariant(order)
Before: S ...... E
After: S ....P .... D .... E

check pre conditions

Inserting the order

check post conditions

Definition at line 444 of file vehicle_pickDeliver.cpp.

444  {
448  invariant();
449  pgassert(!has_order(order));
450 
451  auto pick_pos(position_limits(order.pickup()));
452  auto deliver_pos(position_limits(order.delivery()));
453 
454  if (pick_pos.second < pick_pos.first) {
455  /*
456  * pickup generates twv everywhere
457  */
458  return false;
459  }
460 
461  if (deliver_pos.second < deliver_pos.first) {
462  /*
463  * delivery generates twv everywhere
464  */
465  return false;
466  }
467  /*
468  * Because delivery positions were estimated without the pickup:
469  * - increase the upper limit position estimation
470  */
471  ++deliver_pos.first;
472  ++deliver_pos.second;
473 
474 
475  auto best_pick_pos = size();
476  auto best_deliver_pos = size() + 1;
477  auto current_objective(objective());
478  auto min_delta_objective = (std::numeric_limits<double>::max)();
479 
480  auto found(false);
481 
482  // insert order.pickup() (that is, the order pickup node) into the earliest possible pick position
483  insert(pick_pos.first, order.pickup());
484 
485  // while the pick is < latest pick
486  while (pick_pos.first <= pick_pos.second) {
487  auto deliver_range = deliver_pos;
488  if (deliver_range.first <= pick_pos.first) deliver_range.first = pick_pos.first + 1;
489 
490  /*
491  * hill climb
492  * - find the best position
493  * finds the best position based on objective.
494  */
495  insert(deliver_range.first, order.delivery());
496  while (deliver_range.first <= deliver_range.second) {
497  if (is_feasible()) {
498  auto delta_objective = objective() - current_objective;
499  if (delta_objective < min_delta_objective) {
500  min_delta_objective = delta_objective;
501  best_pick_pos = pick_pos.first;
502  best_deliver_pos = deliver_range.first;
503  found = true;
504  }
505  }
506  if (at(deliver_range.first + 1).is_end()) break;
507  swap(deliver_range.first, deliver_range.first + 1);
508  ++deliver_range.first;
509  }
510 
511  pgassert(at(deliver_range.first).order() == order.id());
512  pgassert(at(pick_pos.first).order() == order.id());
513  erase_node(deliver_range.first);
514 
515  if (at(pick_pos.first + 1).is_end()) break;
516 
517  swap(pick_pos.first, pick_pos.first + 1);
518 
519  ++pick_pos.first;
520  }
521  erase(pick_pos.first);
522 
523  if (!found) {
524  /* order causes twv or cv */
525  return false;
526  }
527 
531  insert(best_pick_pos, order.pickup());
532  insert(best_deliver_pos, order.delivery());
533  m_orders_in_vehicle += order.idx();
534 
539  invariant();
540  return true;
541 }

References vrprouting::problem::Order::delivery(), erase(), vrprouting::problem::Vehicle::erase_node(), has_order(), vrprouting::Identifier::id(), vrprouting::Identifier::idx(), vrprouting::problem::Vehicle::insert(), vrprouting::problem::Vehicle::invariant(), vrprouting::problem::Vehicle::is_feasible(), m_orders_in_vehicle, objective(), pgassert, vrprouting::problem::Order::pickup(), vrprouting::problem::Vehicle::position_limits(), and vrprouting::problem::Vehicle::swap().

Referenced by vrprouting::initialsol::simple::Initial_solution::do_while_feasible(), vrprouting::optimizers::simple::Optimize::move_order(), and vrprouting::optimizers::simple::Optimize::swap_order().

◆ id()

◆ idx()

◆ insert() [1/2]

void vrprouting::problem::Vehicle::insert

Definition at line 202 of file vehicle.cpp.

202  {
203  insert_node(pos, node);
204  evaluate(pos);
205 }

◆ insert() [2/2]

void vrprouting::problem::Vehicle::insert ( size_t  pos,
const Vehicle_node node 
)
protectedinherited

Definition at line 202 of file vehicle.cpp.

202  {
203  insert_node(pos, node);
204  evaluate(pos);
205 }

References vrprouting::problem::Vehicle::evaluate(), and vrprouting::problem::Vehicle::insert_node().

Referenced by hillClimb(), semiLIFO(), and set_initial_solution().

◆ insert_node() [1/2]

void vrprouting::problem::Vehicle::insert_node

Definition at line 158 of file vehicle.cpp.

158  {
159  using difference_type = std::vector<double>::difference_type;
160  pgassert(pos < size() && static_cast<difference_type>(pos) > 0);
161  std::deque<Vehicle_node>::insert(std::deque<Vehicle_node>::begin() + static_cast<difference_type>(pos), node);
162 }

◆ insert_node() [2/2]

void vrprouting::problem::Vehicle::insert_node ( size_t  pos,
const Vehicle_node node 
)
protectedinherited

Definition at line 158 of file vehicle.cpp.

158  {
159  using difference_type = std::vector<double>::difference_type;
160  pgassert(pos < size() && static_cast<difference_type>(pos) > 0);
161  std::deque<Vehicle_node>::insert(std::deque<Vehicle_node>::begin() + static_cast<difference_type>(pos), node);
162 }

References pgassert.

Referenced by vrprouting::problem::Vehicle::insert(), push_back(), vrprouting::problem::Vehicle::push_back(), vrprouting::problem::Vehicle::push_back_node(), push_front(), vrprouting::problem::Vehicle::push_front(), and vrprouting::problem::Vehicle::push_front_node().

◆ invariant() [1/2]

void vrprouting::problem::Vehicle::invariant

Definition at line 100 of file vehicle.cpp.

100  {
101  pgassert(size() >= 2);
102  pgassert(front().is_start());
103  pgassert(back().is_end());
104 }

◆ invariant() [2/2]

void vrprouting::problem::Vehicle::invariant ( ) const
inherited

◆ is_feasible() [1/2]

bool vrprouting::problem::Vehicle::is_feasible

Definition at line 120 of file vehicle.cpp.

120 {return !(has_twv() || has_cv());}

Referenced by vrprouting::optimizers::simple::Optimize::swap_order().

◆ is_feasible() [2/2]

bool vrprouting::problem::Vehicle::is_feasible ( ) const
inherited

Definition at line 120 of file vehicle.cpp.

120 {return !(has_twv() || has_cv());}

References vrprouting::problem::Vehicle::has_cv(), and vrprouting::problem::Vehicle::has_twv().

Referenced by hillClimb(), semiLIFO(), and set_initial_solution().

◆ is_ok()

bool vrprouting::problem::Vehicle::is_ok ( ) const
inherited

◆ is_order_feasible()

bool vrprouting::problem::Vehicle_pickDeliver::is_order_feasible ( const Order order) const
Returns
ture when the order is feasible on the vehicle
Parameters
[in]orderto be tested
Precondition
vehicle is empty

Definition at line 334 of file vehicle_pickDeliver.cpp.

334  {
335  auto test_truck = *this;
336  test_truck.push_back(order);
337  return test_truck.is_feasible();
338 }

◆ is_phony()

◆ is_real()

bool vrprouting::problem::Vehicle::is_real ( ) const
inherited

Definition at line 118 of file vehicle.cpp.

118 {return !is_phony();}

References vrprouting::problem::Vehicle::is_phony().

◆ length()

size_t vrprouting::problem::Vehicle::length ( ) const
inherited

Definition at line 114 of file vehicle.cpp.

114 {return size() - 2;}

◆ msg()

Pgr_messages& vrprouting::problem::Vehicle_pickDeliver::msg ( )
inline

Definition at line 150 of file vehicle_pickDeliver.h.

150 {return m_msg;}

References m_msg.

Referenced by set_initial_solution(), and set_unmovable().

◆ objective()

double vrprouting::problem::Vehicle_pickDeliver::objective ( ) const

Get the value of the objective function.

Returns
0 when the Vehicle is phony
the value of the objective function

Definition at line 321 of file vehicle_pickDeliver.cpp.

321  {
322  return is_phony()?
323  0 :
324  static_cast<double>(total_travel_time());
325 }

References vrprouting::problem::Vehicle::is_phony(), and vrprouting::problem::Vehicle::total_travel_time().

Referenced by hillClimb(), and vrprouting::optimizers::tabu::Optimize::swap_between_routes().

◆ orders()

const Orders& vrprouting::problem::Vehicle_pickDeliver::orders ( ) const
inline

◆ orders_in_vehicle()

Identifiers<size_t> vrprouting::problem::Vehicle_pickDeliver::orders_in_vehicle ( ) const
inline

◆ orders_size()

size_t vrprouting::problem::Vehicle_pickDeliver::orders_size ( ) const
inline

◆ path_str()

std::string vrprouting::problem::Vehicle::path_str ( ) const
inherited

Definition at line 272 of file vehicle.cpp.

272  {
273  std::ostringstream key;
274 
275  for (const auto &p_stop : *this) {
276  if (!(p_stop == front())) key << ",";
277 
278  if (p_stop.is_start() || p_stop.is_end()) {
279  key << p_stop.type_str();
280  } else {
281  key << p_stop.type_str() << p_stop.order();
282  }
283  }
284  return key.str();
285 }

◆ pop_back()

size_t vrprouting::problem::Vehicle_pickDeliver::pop_back ( )

Definition at line 95 of file vehicle_pickDeliver.cpp.

95  {
96  invariant();
97  pgassert(!empty());
98 
99  auto pick_itr = rbegin();
100  while (pick_itr != rend() && !pick_itr->is_pickup()) {
101  ++pick_itr;
102  }
103 
104  pgassert(pick_itr->is_pickup());
105 
106  auto deleted_pick_idx = pick_itr->idx();
107 
108  for (const auto &o : this->orders()) {
109  if (o.pickup().idx() == deleted_pick_idx) {
110  erase(o);
111  invariant();
112  return o.idx();
113  }
114  }
115  pgassert(false);
116  return 0;
117 }

References vrprouting::problem::Vehicle::empty(), erase(), vrprouting::problem::Vehicle::invariant(), orders(), and pgassert.

◆ pop_front()

size_t vrprouting::problem::Vehicle_pickDeliver::pop_front ( )

Definition at line 121 of file vehicle_pickDeliver.cpp.

121  {
122  invariant();
123  pgassert(!empty());
124 
125  auto pick_itr = begin();
126  while (pick_itr != end() && !pick_itr->is_pickup()) {
127  ++pick_itr;
128  }
129 
130  pgassert(pick_itr->is_pickup());
131 
132  auto deleted_pick_idx = pick_itr->idx();
133 
134  for (const auto &o : this->orders()) {
135  if (o.pickup().idx() == deleted_pick_idx) {
136  erase(o);
137  invariant();
138  return o.idx();
139  }
140  }
141 
142  pgassert(false);
143  return 0;
144 }

References vrprouting::problem::Vehicle::empty(), erase(), vrprouting::problem::Vehicle::invariant(), orders(), and pgassert.

◆ position_limits()

std::pair< size_t, size_t > vrprouting::problem::Vehicle::position_limits ( const Vehicle_node node) const
protectedinherited

Get the limits to insert the node.

Returns
the upper and lower position on the path where the node can be inserted
Parameters
[in]nodeto try to be tested

Definition at line 419 of file vehicle.cpp.

419  {
420  size_t high = getPosHighLimit(node);
421  size_t low = getPosLowLimit(node);
422  return std::make_pair(low, high);
423 }

References vrprouting::problem::Vehicle::getPosHighLimit(), and vrprouting::problem::Vehicle::getPosLowLimit().

Referenced by hillClimb().

◆ push_back() [1/2]

void vrprouting::problem::Vehicle_pickDeliver::push_back ( const Order order)

puts an order at the end of the truck

Parameters
[in]orderorder to be pushed back
Precondition
!has_order(order)
Postcondition
has_order(order)
Before: S <nodes> E
After: S <nodes> P D E
Postcondition
Can generate time window violation
Can generate capacity violation

Definition at line 57 of file vehicle_pickDeliver.cpp.

57  {
58  pgassert(!has_order(order));
59  m_orders_in_vehicle += order.idx();
60  insert_node(size() - 1, order.pickup());
61  insert_node(size() - 1, order.delivery());
62  evaluate(size() - 3);
63  pgassert(has_order(order));
64 }

References vrprouting::problem::Order::delivery(), vrprouting::problem::Vehicle::evaluate(), has_order(), vrprouting::Identifier::idx(), vrprouting::problem::Vehicle::insert_node(), m_orders_in_vehicle, pgassert, and vrprouting::problem::Order::pickup().

Referenced by vrprouting::initialsol::simple::Initial_solution::do_while_feasible(), and vrprouting::initialsol::tabu::Initial_solution::process_unassigned().

◆ push_back() [2/2]

void vrprouting::problem::Vehicle::push_back ( const Vehicle_node node)
protectedinherited

Definition at line 208 of file vehicle.cpp.

208  {
209  insert_node(size() - 1, node);
210  evaluate(size() - 2);
211 }

References vrprouting::problem::Vehicle::evaluate(), and vrprouting::problem::Vehicle::insert_node().

◆ push_back_node()

void vrprouting::problem::Vehicle::push_back_node ( const Vehicle_node node)
protectedinherited

Definition at line 164 of file vehicle.cpp.

164  {
165  insert_node(1, node);
166 }

References vrprouting::problem::Vehicle::insert_node().

◆ push_front() [1/2]

void vrprouting::problem::Vehicle_pickDeliver::push_front ( const Order order)

Puts an order at the end front of the truck.

Precondition: !has_order(order)

Postcondition: has_order(order) !has_cv();

Before: S <nodes> E
After: S P D <nodes> E

Can generate time window violation No capacity violation

Definition at line 84 of file vehicle_pickDeliver.cpp.

84  {
85  pgassert(!has_order(order));
86  m_orders_in_vehicle += order.idx();
87  insert_node(1, order.delivery());
88  insert_node(1, order.pickup());
89  evaluate();
90  pgassert(has_order(order));
91 }

References vrprouting::problem::Order::delivery(), vrprouting::problem::Vehicle::evaluate(), has_order(), vrprouting::Identifier::idx(), vrprouting::problem::Vehicle::insert_node(), m_orders_in_vehicle, pgassert, and vrprouting::problem::Order::pickup().

Referenced by vrprouting::initialsol::simple::Initial_solution::do_while_feasible().

◆ push_front() [2/2]

void vrprouting::problem::Vehicle::push_front ( const Vehicle_node node)
protectedinherited

Definition at line 213 of file vehicle.cpp.

213  {
214  insert_node(1, node);
215  evaluate();
216 }

References vrprouting::problem::Vehicle::evaluate(), and vrprouting::problem::Vehicle::insert_node().

◆ push_front_node()

void vrprouting::problem::Vehicle::push_front_node ( const Vehicle_node node)
protectedinherited

Definition at line 168 of file vehicle.cpp.

168  {
169  insert_node(size() - 1, node);
170 }

References vrprouting::problem::Vehicle::insert_node().

◆ reset_id()

void vrprouting::Identifier::reset_id ( int64_t  _id)
inherited

change the original id

Definition at line 47 of file identifier.cpp.

47  {
48  m_id = _id;
49 }

References vrprouting::Identifier::m_id.

Referenced by vrprouting::problem::Tw_node::Tw_node().

◆ semiLIFO()

bool vrprouting::problem::Vehicle_pickDeliver::semiLIFO ( const Order order)

Inserts an order In semi-Lifo (almost last in first out) order.

Precondition: !has_order(order)

Postcondition: has_order(order) !has_cv();

Before: S .... (P1 ....... P2) ... D2 .... D1 .... E
After: S .... (P .. P1 .. P2) ... D2 .. D .. D1 .... E

push_back is performed when

  • drop generates a time window violation

Can generate time window violation No capacity violation

Definition at line 361 of file vehicle_pickDeliver.cpp.

361  {
362  invariant();
363  pgassert(!has_order(order));
364 
365  /*
366  * Insert pick up as first picked
367  */
368  insert(1, order.pickup());
369 
370  auto deliver_pos(drop_position_limits(order.delivery()));
371 
372  /*
373  * delivery generates twv in all positions
374  */
375  if (deliver_pos.second < deliver_pos.first) {
376  /*
377  * Remove inserted pickup
378  */
379  erase(1);
380  invariant();
381  return false;
382  }
383 
384  pgassert(!has_order(order));
385  while (deliver_pos.first <= deliver_pos.second) {
386  insert(deliver_pos.second, order.delivery());
387 
388  if (is_feasible() && !at(deliver_pos.second + 1).is_pickup()) {
389  /*
390  * Found a position to insert the delivery
391  */
392 
393 
394  m_orders_in_vehicle += order.idx();
395 
396  /*
397  * There is one more order in the vehicle
398  */
399  pgassert(has_order(order));
401  pgassert(!has_cv());
402  pgassert(!has_twv());
403  pgassert(has_order(order));
404  invariant();
405  return true;
406  }
407 
408  /*
409  * This position in path is not suitable
410  */
411  erase(deliver_pos.second);
412 
413  /*
414  * got to next position
415  */
416  --deliver_pos.second;
417  }
418 
419  /*
420  * Order could not be inserted
421  */
422  erase(1);
423 
424  pgassert(!has_order(order));
425  invariant();
426  return false;
427 }

References vrprouting::problem::Order::delivery(), vrprouting::problem::Vehicle::drop_position_limits(), erase(), vrprouting::problem::Vehicle::has_cv(), has_order(), vrprouting::problem::Vehicle::has_twv(), vrprouting::Identifier::idx(), vrprouting::problem::Vehicle::insert(), vrprouting::problem::Vehicle::invariant(), vrprouting::problem::Vehicle::is_feasible(), m_orders_in_vehicle, pgassert, and vrprouting::problem::Order::pickup().

Referenced by vrprouting::initialsol::simple::Initial_solution::do_while_feasible(), vrprouting::optimizers::simple::Optimize::move_order(), and vrprouting::optimizers::simple::Optimize::swap_order().

◆ set_initial_solution()

void vrprouting::problem::Vehicle_pickDeliver::set_initial_solution ( const Orders orders,
Identifiers< size_t > &  assigned,
Identifiers< size_t > &  unassigned,
TTimestamp  execution_date,
bool  optimize 
)

sets the initial solution given by the user

Parameters
[in]ordersfrom the problem
[in]assignedset of orders ids already assigned
[in]unassignedset of orders to be assigned
[in]execution_datereference date to set orders unmovable
[in]optimizeflag to set up for optimization

check pre conditions

no stops -> exit

Cycle the stops

Find the order

its a drop off

its a pickup

Can not ignore user error when giving an initial solution

Removing movable orders

check post conditions

Definition at line 171 of file vehicle_pickDeliver.cpp.

176  {
180  pgassert(this->m_user_twv == 0);
181  pgassert(this->m_user_cv == 0);
182 
186  if (m_stops.empty()) return;
187  std::vector<size_t> stops;
188 #if 1
189  msg().log << "\n******\n" << this->id() << "\t stops(o_id) -> ";
190  for (const auto &s : m_stops) {
191  msg().log << s << ", ";
192  }
193 #endif
194 
195 
196  Identifiers<size_t> picked_orders;
197  size_t i(0);
201  for (const auto o_id : m_stops) {
205  auto order = std::find_if(orders.begin(), orders.end(), [o_id]
206  (const Order& o) -> bool {
207  return o.id() == o_id;
208  });
209 
210  pgassert(order != orders.end());
211 
212  if (assigned.has(order->idx())) {
213  pgassertwm(false, "Assigning an order twice");
214  }
215 
216  stops.push_back(order->idx());
217  if (picked_orders.has(order->idx())) {
221  insert(i + 1, order->delivery());
222  picked_orders -= order->idx();
223  m_orders_in_vehicle += order->idx();
224  assigned += order->idx();
225  unassigned -= order->idx();
226  } else {
230  insert(i + 1, order->pickup());
231  picked_orders += order->idx();
232  }
233  ++i;
234  }
235  evaluate();
236  set_unmovable(execution_date);
237 
238 #if 1
239  msg().log << "\n" << this->id() << "\t (idx,id) -> ";
240  for (const auto &s : stops) {
241  msg().log << "(" << s << ", " << orders[s].id() << ")";
242  }
243 #endif
244 
248  if (!is_feasible()) {
249  msg().log << "\n**********************************Vehicle is not feasible with initial orders";
250  msg().log << "twvTot " << this->twvTot() << "\tm_user_twv" << this->m_user_twv << "\n";
251  msg().log << "cvTot " << this->cvTot() << "\tm_user_cv" << this->m_user_cv << "\n";
252  msg().log << "\nVehicle: " << this->id() << "Orders: ";
253  for (const auto &s : m_stops) msg().log << s << ",";
254  msg().log << "\n";
255  msg().log << "\n" << *this;
256 
257 
258 
259  if (optimize) {
260  auto orders_to_remove = m_orders_in_vehicle;
264  for (const auto o : orders_to_remove) {
265  auto order = this->orders();
266  erase(this->orders()[o]);
267  m_orders_in_vehicle -= o;
268  assigned -= o;
269  unassigned += o;
270  }
271  }
272  this->m_user_twv = this->twvTot();
273  this->m_user_cv = this->cvTot();
274  }
275 
280  msg().log << "\n" << this->tau();
281 }

References vrprouting::problem::Vehicle::cvTot(), erase(), vrprouting::problem::Vehicle::evaluate(), Identifiers< T >::has(), vrprouting::Identifier::id(), vrprouting::problem::Vehicle::insert(), vrprouting::problem::Vehicle::is_feasible(), vrprouting::Pgr_messages::log, m_orders_in_vehicle, m_stops, vrprouting::problem::Vehicle::m_user_cv, vrprouting::problem::Vehicle::m_user_twv, msg(), orders(), pgassert, pgassertwm, set_unmovable(), vrprouting::problem::Vehicle::tau(), and vrprouting::problem::Vehicle::twvTot().

◆ set_unmovable()

void vrprouting::problem::Vehicle_pickDeliver::set_unmovable ( TTimestamp  execution_date)

sets as unmovable the orders that start before the execution date

When order's open < execution date.

  • collects the idx()
  • removes the order idx from the m_orders_in_vehicle
Parameters
[in]execution_dateorders starting before this time are marked as unmovable

For the optimizer is like the order does not exist

Definition at line 292 of file vehicle_pickDeliver.cpp.

292  {
293  Identifiers<size_t> unmovable;
294  msg().log << "\nVehicle: " << this->id() << "unmovable: {";
295  for (const auto &o : m_orders_in_vehicle) {
296  for (const auto &s : *this) {
297  auto order = this->orders()[o];
298 
299  if (s.order() == order.id() && s.is_pickup()) {
300  if (s.opens() < execution_date) {
301  unmovable += o;
302  msg().log << order.id() << ",";
303  }
304  }
305  }
306  }
307 
308  msg().log << "}";
309 
313  m_orders_in_vehicle -= unmovable;
314 }

References vrprouting::Identifier::id(), vrprouting::Pgr_messages::log, m_orders_in_vehicle, msg(), and orders().

Referenced by set_initial_solution().

◆ speed()

Speed vrprouting::problem::Vehicle::speed ( ) const
inherited

the speed of the vehicle

Returns
the value of the speed

When the matrix is a time matrix: speed should be in t / t^2 When the matrix is a distance matrix: speed should be in d / t^2

where: d = distance units t = time units

The calculated value of the traveling time will become tt(a, b) = matrix(a,b) / speed;

Definition at line 63 of file vehicle.cpp.

63 {return m_speed;}

References vrprouting::problem::Vehicle::m_speed.

Referenced by vrprouting::problem::Vehicle::evaluate(), vrprouting::problem::Vehicle::getDropPosLowLimit(), and vrprouting::problem::Vehicle::getPosHighLimit().

◆ start_site()

const Vehicle_node & vrprouting::problem::Vehicle::start_site ( ) const
inherited

Definition at line 122 of file vehicle.cpp.

122 {return front();}

Referenced by vrprouting::problem::Vehicle::is_ok().

◆ swap()

void vrprouting::problem::Vehicle::swap ( size_t  i,
size_t  j 
)
protectedinherited

Definition at line 228 of file vehicle.cpp.

228  {
229  pgassert(i < size() - 1 && i > 0);
230  pgassert(j < size() - 1 && j > 0);
231  std::swap(at(i), at(j));
232  i < j ? evaluate(i) : evaluate(j);
233 }

References vrprouting::problem::Vehicle::evaluate(), and pgassert.

Referenced by hillClimb().

◆ tau()

std::string vrprouting::problem::Vehicle::tau ( ) const
inherited

Definition at line 251 of file vehicle.cpp.

251  {
252  invariant();
253  std::ostringstream log;
254  log << "truck " << id() << "(" << idx() << ")" << " (";
255  for (const auto &p_stop : *this) {
256  if (!(p_stop == front())) log << ", ";
257  p_stop.is_start() || p_stop.is_end()?
258  log << p_stop.type_str() << id() :
259  log << p_stop.type_str() << p_stop.order();
260  }
261  log << std::fixed << std::setprecision(4) << ")\t"
262  << "twv=" << twvTot()
263  << " cv=" << cvTot()
264  << " wait=" << total_wait_time()
265  << " duration=" << duration()
266  << " tt=" << total_travel_time()
267  << "\t";
268  return log.str();
269 }

References vrprouting::problem::Vehicle::cvTot(), vrprouting::problem::Vehicle::duration(), vrprouting::Identifier::id(), vrprouting::Identifier::idx(), vrprouting::problem::Vehicle::invariant(), vrprouting::problem::Vehicle::total_travel_time(), vrprouting::problem::Vehicle::total_wait_time(), and vrprouting::problem::Vehicle::twvTot().

Referenced by set_initial_solution().

◆ total_service_time()

TInterval vrprouting::problem::Vehicle::total_service_time ( ) const
inherited

total time spent moving from one node to another

Returns
duration of vehicle while moving for a node to open
0 when the Vehicle is phony

Definition at line 90 of file vehicle.cpp.

90 {return is_phony()? 0 : back().total_service_time();}

References vrprouting::problem::Vehicle::is_phony().

Referenced by vrprouting::problem::Solution::total_service_time().

◆ total_travel_time()

TInterval vrprouting::problem::Vehicle::total_travel_time ( ) const
inherited

total time spent moving from one node to another

Returns
total time vehicle spent moving from a node to another
0 when the Vehicle is phony

Definition at line 84 of file vehicle.cpp.

84 {return is_phony()? 0 : back().total_travel_time();}

References vrprouting::problem::Vehicle::is_phony().

Referenced by objective(), vrprouting::problem::operator<(), vrprouting::problem::Vehicle::tau(), and vrprouting::problem::Solution::total_travel_time().

◆ total_wait_time()

TInterval vrprouting::problem::Vehicle::total_wait_time ( ) const
inherited

duration of vehicle while waiting for a node to open

Returns
duration of vehicle while waiting for a node to open
0 when the Vehicle is phony

Definition at line 78 of file vehicle.cpp.

78 {return is_phony()? 0 : back().total_wait_time(); }

References vrprouting::problem::Vehicle::is_phony().

Referenced by vrprouting::problem::operator<(), vrprouting::problem::Vehicle::tau(), and vrprouting::problem::Solution::wait_time().

◆ twvTot()

int vrprouting::problem::Vehicle::twvTot ( ) const
inherited

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  log,
const Vehicle_pickDeliver v 
)
friend
Returns
The vehicle's information on the log
Parameters
[in,out]logplace to store the vehicle's information
[in]vthe vehicle to work with

Definition at line 64 of file vehicle_pickDeliver.h.

64  {
65  int i(0);
66  log << "\n\n****************** " << v.idx() << "th VEHICLE*************\n";
67  log << "id = " << v.id()
68  << "\tcapacity = " << v.capacity() << "\n";
69 
70  for (const auto &path_stop : v) {
71  log << "Path_stop" << ++i << "\n";
72  log << path_stop << "\n";
73  }
74 
75  log << v.feasible_orders() << "\n";
76  return log;
77  }

Member Data Documentation

◆ elements

T std::deque< T >::elements
inherited

STL member.

◆ m_capacity

PAmount vrprouting::problem::Vehicle::m_capacity
privateinherited

◆ m_cost

double vrprouting::problem::Vehicle_pickDeliver::m_cost
protected

Definition at line 158 of file vehicle_pickDeliver.h.

◆ m_feasible_orders

Identifiers<size_t> vrprouting::problem::Vehicle_pickDeliver::m_feasible_orders
protected

orders that fit in the truck

Definition at line 164 of file vehicle_pickDeliver.h.

Referenced by feasible_orders().

◆ m_id

int64_t vrprouting::Identifier::m_id
privateinherited

Definition at line 87 of file identifier.h.

Referenced by vrprouting::Identifier::id(), and vrprouting::Identifier::reset_id().

◆ m_idx

size_t vrprouting::Identifier::m_idx
privateinherited

Definition at line 86 of file identifier.h.

Referenced by vrprouting::Identifier::idx().

◆ m_msg

Pgr_messages vrprouting::problem::Vehicle_pickDeliver::m_msg
protected

Definition at line 168 of file vehicle_pickDeliver.h.

Referenced by msg().

◆ m_orders

Orders vrprouting::problem::Vehicle_pickDeliver::m_orders
protected

Definition at line 166 of file vehicle_pickDeliver.h.

Referenced by orders().

◆ m_orders_in_vehicle

Identifiers<size_t> vrprouting::problem::Vehicle_pickDeliver::m_orders_in_vehicle
protected

◆ m_speed

Speed vrprouting::problem::Vehicle::m_speed = 1.0
privateinherited

Definition at line 183 of file vehicle.h.

Referenced by vrprouting::problem::Vehicle::speed().

◆ m_stops

std::vector<int64_t> vrprouting::problem::Vehicle_pickDeliver::m_stops
private

order ids of an initial solution given by the user [1,2,1,3,3,2] = P1 P2 D1 P3 D3 D2

Definition at line 175 of file vehicle_pickDeliver.h.

Referenced by set_initial_solution().

◆ m_user_cv

int vrprouting::problem::Vehicle::m_user_cv {0}
protectedinherited

Time window violations on solution.

The user can give a solution that has capacity violations

Definition at line 179 of file vehicle.h.

Referenced by vrprouting::problem::Vehicle::has_cv(), and set_initial_solution().

◆ m_user_twv

int vrprouting::problem::Vehicle::m_user_twv {0}
protectedinherited

Time window violations on solution.

The user can give a solution that has time window violations

Definition at line 173 of file vehicle.h.

Referenced by vrprouting::problem::Vehicle::has_twv(), and set_initial_solution().


The documentation for this class was generated from the following files:
vrprouting::problem::Vehicle::m_speed
Speed m_speed
Definition: vehicle.h:183
vrprouting::problem::Vehicle_pickDeliver::set_unmovable
void set_unmovable(TTimestamp execution_date)
sets as unmovable the orders that start before the execution date
Definition: vehicle_pickDeliver.cpp:292
vrprouting::problem::Vehicle_pickDeliver::erase
void erase(const Order &order)
erases the order from the vehicle
Definition: vehicle_pickDeliver.cpp:154
vrprouting::problem::Vehicle_pickDeliver::m_orders
Orders m_orders
Definition: vehicle_pickDeliver.h:166
vrprouting::problem::Vehicle::twvTot
int twvTot() const
Definition: vehicle.cpp:92
vrprouting::problem::Vehicle::evaluate
void evaluate()
Definition: vehicle.cpp:126
vrprouting::Pgr_messages::log
std::ostringstream log
Stores the hint information.
Definition: pgr_messages.h:91
vrprouting::problem::Vehicle::invariant
void invariant() const
Definition: vehicle.cpp:100
vrprouting::problem::Vehicle::start_site
const Vehicle_node & start_site() const
Definition: vehicle.cpp:122
vrprouting::problem::Vehicle_pickDeliver::m_feasible_orders
Identifiers< size_t > m_feasible_orders
orders that fit in the truck
Definition: vehicle_pickDeliver.h:164
vrprouting::Identifier::id
int64_t id() const
get the original id
Definition: identifier.cpp:42
vrprouting::Identifier::m_id
int64_t m_id
Definition: identifier.h:87
vrprouting::problem::Vehicle::has_twv
bool has_twv() const
Definition: vehicle.cpp:96
vrprouting::problem::Tw_node::closes
TTimestamp closes() const
Returns the closing time.
Definition: tw_node.h:81
pgassertwm
#define pgassertwm(expr, msg)
Adds a message to the assertion.
Definition: pgr_assert.h:118
vrprouting::problem::Vehicle::m_user_cv
int m_user_cv
Time window violations on solution.
Definition: vehicle.h:179
vrprouting::problem::Vehicle_pickDeliver::m_stops
std::vector< int64_t > m_stops
order ids of an initial solution given by the user [1,2,1,3,3,2] = P1 P2 D1 P3 D3 D2
Definition: vehicle_pickDeliver.h:175
vrprouting::Identifier::m_idx
size_t m_idx
Definition: identifier.h:86
vrprouting::problem::Vehicle::getDropPosLowLimit
size_t getDropPosLowLimit(const Vehicle_node &node) const
Definition: vehicle.cpp:331
vrprouting::problem::Vehicle::is_phony
bool is_phony() const
Definition: vehicle.cpp:116
vrprouting::problem::Vehicle_pickDeliver::msg
Pgr_messages & msg()
Definition: vehicle_pickDeliver.h:150
vrprouting::problem::Vehicle::is_feasible
bool is_feasible() const
Definition: vehicle.cpp:120
pgassert
#define pgassert(expr)
Uses the standard assert syntax.
Definition: pgr_assert.h:95
vrprouting::problem::Vehicle_pickDeliver::objective
double objective() const
Get the value of the objective function.
Definition: vehicle_pickDeliver.cpp:321
vrprouting::problem::Vehicle_pickDeliver::m_orders_in_vehicle
Identifiers< size_t > m_orders_in_vehicle
orders inserted in this vehicle
Definition: vehicle_pickDeliver.h:161
vrprouting::problem::Vehicle::end_site
const Vehicle_node & end_site() const
Definition: vehicle.cpp:124
Identifiers::size
size_t size() const
Definition: identifiers.hpp:77
vrprouting::problem::Vehicle_pickDeliver::has_order
bool has_order(const Order &order) const
does the vehicle has the order?
Definition: vehicle_pickDeliver.h:108
vrprouting::problem::Vehicle::m_user_twv
int m_user_twv
Time window violations on solution.
Definition: vehicle.h:173
vrprouting::problem::Vehicle_pickDeliver::orders
const Orders & orders() const
Definition: vehicle_pickDeliver.h:148
vrprouting::problem::Vehicle::getPosHighLimit
size_t getPosHighLimit(const Vehicle_node &node) const
Get the highest position on the path where node can be placed.
Definition: vehicle.cpp:397
vrprouting::Identifier::idx
size_t idx() const
get the internal index
Definition: identifier.cpp:37
vrprouting::problem::Vehicle::m_capacity
PAmount m_capacity
Definition: vehicle.h:182
vrprouting::problem::Vehicle::swap
void swap(size_t i, size_t j)
Definition: vehicle.cpp:228
vrprouting::problem::Vehicle::cvTot
int cvTot() const
Definition: vehicle.cpp:94
vrprouting::problem::Vehicle::total_wait_time
TInterval total_wait_time() const
duration of vehicle while waiting for a node to open
Definition: vehicle.cpp:78
vrprouting::problem::Vehicle::duration
TInterval duration() const
duration of vehicle while not in a "depot"
Definition: vehicle.cpp:72
vrprouting::problem::Vehicle_pickDeliver::m_msg
Pgr_messages m_msg
Definition: vehicle_pickDeliver.h:168
vrprouting::problem::Vehicle::erase
void erase(size_t pos)
Definition: vehicle.cpp:172
Identifiers::has
bool has(const T other) const
true ids() has element
Definition: identifiers.hpp:100
vrprouting::problem::Vehicle_pickDeliver::m_cost
double m_cost
Definition: vehicle_pickDeliver.h:158
vrprouting::problem::Vehicle::total_travel_time
TInterval total_travel_time() const
total time spent moving from one node to another
Definition: vehicle.cpp:84
vrprouting::problem::Vehicle::erase_node
void erase_node(size_t pos)
Definition: vehicle.cpp:152
vrprouting::problem::Vehicle::Vehicle
Vehicle()=delete
vrprouting::problem::Vehicle::insert_node
void insert_node(size_t pos, const Vehicle_node &node)
Definition: vehicle.cpp:158
vrprouting::problem::Vehicle::getPosLowLimit
size_t getPosLowLimit(const Vehicle_node &node) const
Get the lowest position on the path where node can be placed.
Definition: vehicle.cpp:366
vrprouting::problem::Vehicle::tau
std::string tau() const
Definition: vehicle.cpp:251
vrprouting::problem::Vehicle::capacity
PAmount capacity() const
returns the capacity of the vehicle
Definition: vehicle.cpp:66
vrprouting::problem::Vehicle::has_cv
bool has_cv() const
Definition: vehicle.cpp:98
vrprouting::problem::Vehicle::drop_position_limits
std::pair< size_t, size_t > drop_position_limits(const Vehicle_node &node) const
Definition: vehicle.cpp:426
vrprouting::problem::Vehicle::speed
Speed speed() const
the speed of the vehicle
Definition: vehicle.cpp:63
vrprouting::problem::Tw_node::opens
TTimestamp opens() const
Returns the opening time.
Definition: tw_node.h:78
vrprouting::problem::Vehicle::position_limits
std::pair< size_t, size_t > position_limits(const Vehicle_node &node) const
Get the limits to insert the node.
Definition: vehicle.cpp:419
Identifiers< size_t >
vrprouting::problem::Vehicle::insert
void insert(size_t pos, const Vehicle_node &node)
Definition: vehicle.cpp:202
vrprouting::problem::Vehicle::empty
bool empty() const
Definition: vehicle.cpp:112