vrpRouting  0.3
vrprouting::problem::Order Class Reference

#include "order.h"

Inheritance diagram for vrprouting::problem::Order:
Collaboration diagram for vrprouting::problem::Order:

Public Member Functions

 Order ()=delete
 Order without data is not permitted. More...
 
 Order (const Order &)=default
 copy constructor More...
 
 Order (Idx o_idx, Id o_id, const Vehicle_node &p_pickup, const Vehicle_node &p_delivery)
 initializing an order with the pick & drop information More...
 
bool is_valid (Speed speed=1.0) const
 is the order valid? More...
 
bool isCompatibleIJ (const Order &I, Speed speed=1.0) const
 Can order I be placed before this order? More...
 
void set_compatibles (const Order &, Speed speed=1.0)
 set compatability of this orther with the other order More...
 
Accessors
const Vehicle_nodepickup () const
 The pickup node identifier. More...
 
const Vehicle_nodedelivery () const
 The delivery node identifier. More...
 
Identifiers< size_t > subsetJ (const Identifiers< size_t > &J) const
 Get a subset of the orders that can be placed after this order. More...
 
Identifiers< size_t > subsetI (const Identifiers< size_t > &I) const
 Get a subset of the orders that can be placed before this order. More...
 

Protected Attributes

Identifiers< size_t > m_compatibleI
 Storage for the orders that can be placed before this order. More...
 
Identifiers< size_t > m_compatibleJ
 Storage for the orders that can be placed after this order. More...
 
Vehicle_node m_delivery
 The delivery node identifier. More...
 
Vehicle_node m_pickup
 The pick up node identifier. More...
 

Private Attributes

int64_t m_id
 
size_t m_idx
 

Friends

std::ostream & operator<< (std::ostream &, const Order &)
 Print the order. More...
 

Detailed Description

Definition at line 40 of file order.h.

Constructor & Destructor Documentation

◆ Order() [1/3]

vrprouting::problem::Order::Order ( )
delete

Order without data is not permitted.

◆ Order() [2/3]

vrprouting::problem::Order::Order ( const Order )
default

copy constructor

◆ Order() [3/3]

vrprouting::problem::Order::Order ( Idx  o_idx,
Id  o_id,
const Vehicle_node p_pickup,
const Vehicle_node p_delivery 
)
inline

initializing an order with the pick & drop information

Definition at line 52 of file order.h.

54  :
55  Identifier(o_idx, o_id),
56  m_pickup(p_pickup),
57  m_delivery(p_delivery) {
58  }

Member Function Documentation

◆ delivery()

◆ id()

◆ idx()

◆ is_valid()

bool vrprouting::problem::Order::is_valid ( Speed  speed = 1.0) const

is the order valid?

Parameters
[in]speedvalue to do the calculation
Returns
ture when:

Validate a pickup/delivery order

  • The pickup is well formed
  • The delivery is well formed
  • isCompatibleIJ to go to delivery after immediately visiting pickup

Definition at line 109 of file order.cpp.

109  {
110  return
111  pickup().is_pickup()
112  && delivery().is_delivery()
113  /* IS P -> D */
114  && delivery().is_compatible_IJ(pickup(), speed);
115 }

References delivery(), vrprouting::problem::Tw_node::is_compatible_IJ(), vrprouting::problem::Tw_node::is_delivery(), vrprouting::problem::Tw_node::is_pickup(), and pickup().

Referenced by vrprouting::problem::Fleet::is_order_ok().

◆ isCompatibleIJ()

bool vrprouting::problem::Order::isCompatibleIJ ( const Order I,
Speed  speed = 1.0 
) const

Can order I be placed before this order?

Returns
True when I -> this
dot_inline_dotgraph_21.png
Parameters
[in]Iorder
[in]speedvalue to do the calculation
Returns
true when order I can be placed before this order

Definition at line 161 of file order.cpp.

161  {
162  /* this is true in all cases */
163  auto all_cases(
164  pickup().is_compatible_IJ(I.pickup(), speed)
165  && delivery().is_compatible_IJ(I.pickup(), speed));
166 
167  /* case other(P) other(D) this(P) this(D) */
168  auto case1(pickup().is_compatible_IJ(I.delivery(), speed)
169  && delivery().is_compatible_IJ(I.delivery(), speed));
170 
171  /* case other(P) this(P) other(D) this(D) */
172  auto case2(I.delivery().is_compatible_IJ(pickup(), speed)
173  && delivery().is_compatible_IJ(I.delivery(), speed));
174 
175  /* case other(P) this(P) this(D) other(D) */
176  auto case3(I.delivery().is_compatible_IJ(pickup(), speed)
177  && I.delivery().is_compatible_IJ(delivery(), speed));
178 
179  return all_cases && (case1 || case2 || case3);
180 }

References delivery(), vrprouting::problem::Tw_node::is_compatible_IJ(), and pickup().

Referenced by set_compatibles().

◆ pickup()

◆ 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().

◆ set_compatibles()

void vrprouting::problem::Order::set_compatibles ( const Order J,
Speed  speed = 1.0 
)

set compatability of this orther with the other order

Initializing the set of nodes that can be placed immediately after this node.

(this) -> J

Parameters
[in]Jorder after this node
[in]speedvalue to do the calculation
Postcondition
m_compatibleJ has order when this -> order
m_compatibleI has order when order -> this

Definition at line 130 of file order.cpp.

130  {
131  if (J.idx() == idx()) return;
132  if (J.isCompatibleIJ(*this, speed)) {
133  m_compatibleJ += J.idx();
134  }
135  if (this->isCompatibleIJ(J, speed)) {
136  m_compatibleI += J.idx();
137  }
138 }

References vrprouting::Identifier::idx(), isCompatibleIJ(), m_compatibleI, and m_compatibleJ.

◆ subsetI()

Identifiers< size_t > vrprouting::problem::Order::subsetI ( const Identifiers< size_t > &  I) const

Get a subset of the orders that can be placed before this order.

Returns
Orders from I that are compatible with this order
Parameters
[in]ISet of orders that possibly are I -> this
dot_inline_dotgraph_22.png

Definition at line 45 of file order.cpp.

45  {
46  return m_compatibleI * I;
47 }

References m_compatibleI.

◆ subsetJ()

Identifiers< size_t > vrprouting::problem::Order::subsetJ ( const Identifiers< size_t > &  J) const

Get a subset of the orders that can be placed after this order.

Returns
Orders from J that are compatible with this order
Parameters
[in]JSet of orders that possibly are this -> J
dot_inline_dotgraph_23.png

Definition at line 62 of file order.cpp.

62  {
63  return m_compatibleJ * J;
64 }

References m_compatibleJ.

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  log,
const Order order 
)
friend

Print the order.

  • the pickup
  • dropoff
  • Set of orders I than are I -> this
  • Set of orders J than are this -> I
    Parameters
    [in,out]log
    [in]order
    Returns
    the ostream

Definition at line 77 of file order.cpp.

77  {
78  log << "\n\nOrder "
79  << static_cast<Identifier>(order) << ": \n"
80  << "\tPickup: " << order.pickup() << "\n"
81  << "\tDropoff: " << order.delivery() << "\n";
82  log << "\nThere are | {I}| = "
83  << order.m_compatibleI.size()
84  << " -> order(" << order.idx()
85  << ") -> | {J}| = " << order.m_compatibleJ.size()
86  << "\n\n {";
87  for (const auto o : order.m_compatibleI) {
88  log << o << ", ";
89  }
90  log << "} -> " << order.idx() << " -> {";
91  for (const auto o : order.m_compatibleJ) {
92  log << o << ", ";
93  }
94  log << "}";
95 
96  return log;
97 }

Member Data Documentation

◆ m_compatibleI

Identifiers<size_t> vrprouting::problem::Order::m_compatibleI
protected

Storage for the orders that can be placed before this order.

dot_inline_dotgraph_24.png

Definition at line 110 of file order.h.

Referenced by vrprouting::problem::operator<<(), set_compatibles(), and subsetI().

◆ m_compatibleJ

Identifiers<size_t> vrprouting::problem::Order::m_compatibleJ
protected

Storage for the orders that can be placed after this order.

dot_inline_dotgraph_25.png

Definition at line 98 of file order.h.

Referenced by vrprouting::problem::operator<<(), set_compatibles(), and subsetJ().

◆ m_delivery

Vehicle_node vrprouting::problem::Order::m_delivery
protected

The delivery node identifier.

It hold's the idx of the node

Definition at line 122 of file order.h.

Referenced by delivery().

◆ 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_pickup

Vehicle_node vrprouting::problem::Order::m_pickup
protected

The pick up node identifier.

It hold's the idx of the node

Definition at line 116 of file order.h.

Referenced by pickup().


The documentation for this class was generated from the following files:
vrprouting::problem::Tw_node::is_delivery
bool is_delivery() const
Is the node a valid order's delivery node.
Definition: tw_node.cpp:210
vrprouting::Identifier::Identifier
Identifier()=default
vrprouting::Identifier::m_id
int64_t m_id
Definition: identifier.h:87
vrprouting::problem::Order::isCompatibleIJ
bool isCompatibleIJ(const Order &I, Speed speed=1.0) const
Can order I be placed before this order?
Definition: order.cpp:161
vrprouting::Identifier::m_idx
size_t m_idx
Definition: identifier.h:86
vrprouting::problem::Order::m_pickup
Vehicle_node m_pickup
The pick up node identifier.
Definition: order.h:116
vrprouting::Identifier::idx
size_t idx() const
get the internal index
Definition: identifier.cpp:37
vrprouting::problem::Tw_node::is_pickup
bool is_pickup() const
Is the node a valid order's pickup node.
Definition: tw_node.cpp:199
vrprouting::problem::Tw_node::is_compatible_IJ
bool is_compatible_IJ(const Tw_node &I, Speed=1.0) const
is possible to arrive to this after visiting other?
Definition: tw_node.cpp:94
vrprouting::problem::Order::m_delivery
Vehicle_node m_delivery
The delivery node identifier.
Definition: order.h:122
vrprouting::problem::Order::pickup
const Vehicle_node & pickup() const
The pickup node identifier.
Definition: order.h:65
vrprouting::problem::Order::m_compatibleI
Identifiers< size_t > m_compatibleI
Storage for the orders that can be placed before this order.
Definition: order.h:110
vrprouting::problem::Order::delivery
const Vehicle_node & delivery() const
The delivery node identifier.
Definition: order.h:68
vrprouting::problem::Order::m_compatibleJ
Identifiers< size_t > m_compatibleJ
Storage for the orders that can be placed after this order.
Definition: order.h:98