PGROUTING  2.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
pgrouting::vrp::Vehicle Class Reference

Vehicle with time windows. More...

#include "vehicle.h"

Inheritance diagram for pgrouting::vrp::Vehicle:
pgrouting::vrp::Vehicle_pickDeliver

Public Types

typedef std::tuple< int, int,
size_t, double, double > 
Cost
 

Public Member Functions

 Vehicle (ID id, const Vehicle_node &starting_site, const Vehicle_node &ending_site, double max_capacity)
 
double deltaTime (const Vehicle_node &node, POS pos) const
 
void get_postgres_result (int vid, std::vector< General_vehicle_orders_t > &result) const
 
POS insert_less_travel_time (const Vehicle_node &node, POS after_pos=0)
 
std::pair< POS, POSposition_limits (const Vehicle_node node) const
 
void swap (POS i, POS j)
 Swap two nodes in the path. More...
 
deque like functions
Returns
True if the operation was performed
Warning
Assertions are performed for out of range operations
no feasability nor time window or capacity violations checks are performed
Todo:
TODO more deque like functions here
void invariant () const
 Invariant The path must: More...
 
void insert (POS pos, Vehicle_node node)
 @ { More...
 
POS insert (std::pair< POS, POS > position_limits, const Vehicle_node &node)
 Insert node in best position of the position_limits. More...
 
void push_back (const Vehicle_node &node)
 Evaluated: push_back a node to the path. More...
 
void push_front (const Vehicle_node &node)
 Evaluated: push_back a node to the path. More...
 
void pop_back ()
 Evaluated: pop_back a node to the path. More...
 
void pop_front ()
 Evaluated: pop_front a node to the path. More...
 
void erase (const Vehicle_node &node)
 Erase node.id() More...
 
void erase (POS pos)
 Erase node at pos from the path. More...
 
bool empty () const
 return true when no nodes are in the truck More...
 
ID id () const
 
Cost cost () const
 @ { More...
 
bool cost_compare (const Cost &, const Cost &) const
 
double duration () const
 
double total_wait_time () const
 
double total_travel_time () const
 
double total_service_time () const
 
double free_time () const
 
int twvTot () const
 
int cvTot () const
 
bool has_twv () const
 
bool has_cv () const
 
bool is_feasable () const
 
Evaluation

Path evaluation is done incrementally: from a given position to the end of the path, and intermediate values are cached on each node.

So, for example, changing the path at position 100: the evaluation function should be called as evaluate(100, maxcapacity) and from that position to the end of the path will be evaluated. None of the "unaffected" positions get reevaluated

void evaluate ()
 @ { More...
 
void evaluate (POS from)
 Evaluate: Evaluate a path from the given position. More...
 
accessors
std::deque< Vehicle_nodepath () const
 @ { More...
 

Protected Types

typedef size_t ID
 
typedef size_t POS
 

Protected Attributes

ID m_id
 
std::deque< Vehicle_nodem_path
 
double max_capacity
 

Private Member Functions

POS getPosHighLimit (const Vehicle_node &node) const
 
POS getPosLowLimit (const Vehicle_node &node) const
 

operators

std::string tau () const
 
std::ostream & operator<< (std::ostream &log, const Vehicle &v)
 @ { More...
 
bool operator< (const Vehicle &lhs, const Vehicle &rhs)
 

Detailed Description

Vehicle with time windows.

General functionality for a vehicle in a VRP problem

Recommended use:

Class my_vehicle : public vechicle
Note
All members return true when the operation is successful

A vehicle is a sequence of Vehicle_node from starting site to ending site.

See Also
Vehicle_node

Definition at line 62 of file vehicle.h.

Member Typedef Documentation

typedef std::tuple< int, int, size_t, double, double > pgrouting::vrp::Vehicle::Cost

Definition at line 74 of file vehicle.h.

typedef size_t pgrouting::vrp::Vehicle::ID
protected

Definition at line 64 of file vehicle.h.

typedef size_t pgrouting::vrp::Vehicle::POS
protected

Definition at line 65 of file vehicle.h.

Constructor & Destructor Documentation

pgrouting::vrp::Vehicle::Vehicle ( ID  id,
const Vehicle_node starting_site,
const Vehicle_node ending_site,
double  max_capacity 
)

Definition at line 450 of file vehicle.cpp.

References evaluate(), invariant(), and m_path.

Member Function Documentation

Vehicle::Cost pgrouting::vrp::Vehicle::cost ( ) const

@ {

Definition at line 156 of file vehicle.cpp.

References cvTot(), duration(), m_path, total_wait_time(), and twvTot().

Referenced by insert().

bool pgrouting::vrp::Vehicle::cost_compare ( const Cost lhs,
const Cost rhs 
) const

Definition at line 88 of file vehicle.cpp.

Referenced by insert().

int pgrouting::vrp::Vehicle::cvTot ( ) const
inline

Definition at line 231 of file vehicle.h.

References m_path.

Referenced by cost(), has_cv(), and tau().

double pgrouting::vrp::Vehicle::deltaTime ( const Vehicle_node node,
POS  pos 
) const
double pgrouting::vrp::Vehicle::duration ( ) const
inline
void pgrouting::vrp::Vehicle::erase ( const Vehicle_node node)

Erase node.id()

Note
start and ending nodes cannot be erased

Numbers are positions before: S .... node.id() .... E after: S .... .... E

Definition at line 228 of file vehicle.cpp.

References evaluate(), pgrouting::vrp::Node::id(), invariant(), and m_path.

Referenced by pgrouting::vrp::Vehicle_pickDeliver::erase(), pgrouting::vrp::Vehicle_pickDeliver::insert(), pop_back(), and pop_front().

void pgrouting::vrp::Vehicle::erase ( POS  pos)

Erase node at pos from the path.

Note
start and ending nodes cannot be erased

Numbers are positions before: S 1 2 3 4 5 6 pos 8 9 E after: S 1 2 3 4 5 6 8 9 E

Parameters
[in]posto be erased.

Definition at line 303 of file vehicle.cpp.

References evaluate(), invariant(), m_path, and pgassert.

void pgrouting::vrp::Vehicle::evaluate ( )
void pgrouting::vrp::Vehicle::evaluate ( POS  from)

Evaluate: Evaluate a path from the given position.

Parameters
[in]fromThe starting position in the path for evaluation to the end of the path.

Definition at line 349 of file vehicle.cpp.

References invariant(), m_path, max_capacity, and pgassert.

double pgrouting::vrp::Vehicle::free_time ( ) const
inline

Definition at line 225 of file vehicle.h.

References duration(), m_path, and total_wait_time().

void pgrouting::vrp::Vehicle::get_postgres_result ( int  vid,
std::vector< General_vehicle_orders_t > &  result 
) const

Definition at line 135 of file vehicle.cpp.

References m_path.

size_t pgrouting::vrp::Vehicle::getPosHighLimit ( const Vehicle_node node) const
private

Definition at line 431 of file vehicle.cpp.

References invariant(), pgrouting::vrp::Tw_node::is_compatible_IJ(), and m_path.

Referenced by position_limits().

size_t pgrouting::vrp::Vehicle::getPosLowLimit ( const Vehicle_node node) const
private

Definition at line 399 of file vehicle.cpp.

References invariant(), and m_path.

Referenced by position_limits().

bool pgrouting::vrp::Vehicle::has_cv ( ) const
inline
bool pgrouting::vrp::Vehicle::has_twv ( ) const
inline

Definition at line 234 of file vehicle.h.

References twvTot().

Referenced by is_feasable().

ID pgrouting::vrp::Vehicle::id ( ) const
inline

Definition at line 206 of file vehicle.h.

References m_id.

Referenced by pgrouting::vrp::operator<<(), and tau().

void pgrouting::vrp::Vehicle::insert ( POS  pos,
Vehicle_node  node 
)

@ {

Insert node at pos position.

Parameters
[in]posThe position that the node should be inserted.
[in]nodeThe node to insert.

Definition at line 164 of file vehicle.cpp.

References evaluate(), pgrouting::vrp::Node::id(), invariant(), m_path, and pgassert.

Referenced by insert(), pgrouting::vrp::Vehicle_pickDeliver::insert(), insert_less_travel_time(), push_back(), and push_front().

size_t pgrouting::vrp::Vehicle::insert ( std::pair< POS, POS position_limits,
const Vehicle_node node 
)

Insert node in best position of the position_limits.

Parameters
[in]position_limits
[in]nodeThe node to insert
Returns
position where it was inserted

Definition at line 54 of file vehicle.cpp.

References cost(), cost_compare(), pgrouting::vrp::Node::id(), insert(), invariant(), m_path, pgassert, and swap().

size_t pgrouting::vrp::Vehicle::insert_less_travel_time ( const Vehicle_node node,
POS  after_pos = 0 
)

Definition at line 205 of file vehicle.cpp.

References deltaTime(), insert(), invariant(), and m_path.

std::deque< Vehicle_node > pgrouting::vrp::Vehicle::path ( ) const

@ {

Definition at line 370 of file vehicle.cpp.

References invariant(), and m_path.

Referenced by pgrouting::vrp::operator<<().

void pgrouting::vrp::Vehicle::pop_back ( )

Evaluated: pop_back a node to the path.

before: S <nodes> n E
after: S <nodes> E

Definition at line 279 of file vehicle.cpp.

References erase(), invariant(), m_path, and pgassert.

void pgrouting::vrp::Vehicle::pop_front ( )

Evaluated: pop_front a node to the path.

before: S n <nodes> E
after: S <nodes> E

Definition at line 290 of file vehicle.cpp.

References erase(), invariant(), m_path, and pgassert.

std::pair< size_t, size_t > pgrouting::vrp::Vehicle::position_limits ( const Vehicle_node  node) const

Definition at line 377 of file vehicle.cpp.

References getPosHighLimit(), and getPosLowLimit().

Referenced by pgrouting::vrp::Vehicle_pickDeliver::insert().

void pgrouting::vrp::Vehicle::push_back ( const Vehicle_node node)

Evaluated: push_back a node to the path.

before: S <nodes> E
after: S <nodes> n E
Parameters
[in]nodeto be push_back.

Definition at line 269 of file vehicle.cpp.

References insert(), invariant(), and m_path.

void pgrouting::vrp::Vehicle::push_front ( const Vehicle_node node)

Evaluated: push_back a node to the path.

before: S <nodes> E
after: S n <nodes> E
Parameters
[in]nodeto be push_back.

Definition at line 252 of file vehicle.cpp.

References insert(), and invariant().

void pgrouting::vrp::Vehicle::swap ( POS  i,
POS  j 
)

Swap two nodes in the path.

Before: S <nodesA> I <nodesB> J <nodesC> E
After: S <nodesA> J <nodesB> I <nodesC> E
Parameters
[in]iThe position of the first node to swap.
[in]jThe position of the second node to swap.

Definition at line 318 of file vehicle.cpp.

References evaluate(), invariant(), m_path, and pgassert.

Referenced by insert().

std::string pgrouting::vrp::Vehicle::tau ( ) const

Definition at line 468 of file vehicle.cpp.

References cvTot(), duration(), id(), m_path, total_wait_time(), and twvTot().

Referenced by pgrouting::vrp::Vehicle_pickDeliver::insert().

double pgrouting::vrp::Vehicle::total_service_time ( ) const
inline

Definition at line 222 of file vehicle.h.

References m_path.

double pgrouting::vrp::Vehicle::total_travel_time ( ) const
inline

Definition at line 219 of file vehicle.h.

References m_path.

double pgrouting::vrp::Vehicle::total_wait_time ( ) const
inline

Definition at line 216 of file vehicle.h.

References m_path.

Referenced by cost(), free_time(), pgrouting::vrp::Optimize::sort_for_move(), and tau().

int pgrouting::vrp::Vehicle::twvTot ( ) const
inline

Definition at line 228 of file vehicle.h.

References m_path.

Referenced by cost(), has_twv(), and tau().

Friends And Related Function Documentation

bool operator< ( const Vehicle lhs,
const Vehicle rhs 
)
friend

Definition at line 500 of file vehicle.cpp.

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

@ {

Definition at line 488 of file vehicle.cpp.

Member Data Documentation

ID pgrouting::vrp::Vehicle::m_id
protected

Definition at line 66 of file vehicle.h.

Referenced by id().

double pgrouting::vrp::Vehicle::max_capacity
protected

Definition at line 68 of file vehicle.h.

Referenced by evaluate().


The documentation for this class was generated from the following files: