PGROUTING  2.6-dev
pickDeliverEuclidean_driver.h File Reference
Include dependency graph for pickDeliverEuclidean_driver.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void do_pgr_pickDeliverEuclidean (PickDeliveryOrders_t *pd_orders_arr, size_t total_pd_orders, Vehicle_t *vehicles_arr, size_t total_vehicles, double factor, int max_cycles, int initial_solution_id, General_vehicle_orders_t **return_tuples, size_t *return_count, char **log_msg, char **notice_msg, char **err_msg)
 

Function Documentation

void do_pgr_pickDeliverEuclidean ( PickDeliveryOrders_t pd_orders_arr,
size_t  total_pd_orders,
Vehicle_t vehicles_arr,
size_t  total_vehicles,
double  factor,
int  max_cycles,
int  initial_solution_id,
General_vehicle_orders_t **  return_tuples,
size_t *  return_count,
char **  log_msg,
char **  notice_msg,
char **  err_msg 
)

Definition at line 52 of file pickDeliverEuclidean_driver.cpp.

References pgrouting::Pgr_messages::get_error(), pgrouting::Pgr_messages::get_log(), pgrouting::vrp::Pgr_pickDeliver::get_postgres_result(), pgrouting::vrp::PD_problem::msg, pgassert, pgr_alloc(), pgr_msg(), pgrouting::vrp::Pgr_pickDeliver::solve(), and AssertFailedException::what().

Referenced by process().

68  {
69  std::ostringstream log;
70  std::ostringstream notice;
71  std::ostringstream err;
72  try {
73  std::ostringstream tmp_log;
74  *return_tuples = NULL;
75  *return_count = 0;
76 
77  /*
78  * transform to C++ containers
79  */
80  std::vector<PickDeliveryOrders_t> orders(
81  customers_arr, customers_arr + total_customers);
82  std::vector<Vehicle_t> vehicles(
83  vehicles_arr, vehicles_arr + total_vehicles);
84 
85  log << "Initialize problem\n";
87  orders,
88  vehicles,
89  factor,
90  max_cycles,
91  initial_solution_id);
92 
93  err << pd_problem.msg.get_error();
94  if (!err.str().empty()) {
95  log.str("");
96  log.clear();
97  log << pd_problem.msg.get_error();
98  log << pd_problem.msg.get_log();
99  *log_msg = pgr_msg(log.str().c_str());
100  *err_msg = pgr_msg(err.str().c_str());
101  return;
102  }
103  log << pd_problem.msg.get_log();
104  log << "Finish Reading data\n";
105 
106  try {
107  pd_problem.solve();
108  } catch (AssertFailedException &except) {
109  log << pd_problem.msg.get_log();
110  throw except;
111  } catch(...) {
112  log << "Caught unknown exception!";
113  throw;
114  }
115 
116  log << pd_problem.msg.get_log();
117  log << "Finish solve\n";
118 
119  auto solution = pd_problem.get_postgres_result();
120  log << pd_problem.msg.get_log();
121  log << "solution size: " << solution.size() << "\n";
122 
123 
124  if (!solution.empty()) {
125  (*return_tuples) = pgr_alloc(solution.size(), (*return_tuples));
126  int seq = 0;
127  for (const auto &row : solution) {
128  (*return_tuples)[seq] = row;
129  ++seq;
130  }
131  }
132  (*return_count) = solution.size();
133 
134  log << pd_problem.msg.get_log();
135 
136  pgassert(*err_msg == NULL);
137  *log_msg = log.str().empty()?
138  nullptr :
139  pgr_msg(log.str().c_str());
140  *notice_msg = notice.str().empty()?
141  nullptr :
142  pgr_msg(notice.str().c_str());
143  } catch (AssertFailedException &except) {
144  if (*return_tuples) free(*return_tuples);
145  (*return_count) = 0;
146  err << except.what();
147  *err_msg = pgr_msg(err.str().c_str());
148  *log_msg = pgr_msg(log.str().c_str());
149  } catch (std::exception& except) {
150  if (*return_tuples) free(*return_tuples);
151  (*return_count) = 0;
152  err << except.what();
153  *err_msg = pgr_msg(err.str().c_str());
154  *log_msg = pgr_msg(log.str().c_str());
155  } catch(...) {
156  if (*return_tuples) free(*return_tuples);
157  (*return_count) = 0;
158  err << "Caught unknown exception!";
159  *err_msg = pgr_msg(err.str().c_str());
160  *log_msg = pgr_msg(log.str().c_str());
161  }
162 }
Extends std::exception and is the exception that we throw if an assert fails.
Definition: pgr_assert.h:126
#define pgassert(expr)
Uses the standard assert syntax.
Definition: pgr_assert.h:81
char * pgr_msg(const std::string &msg)
Definition: pgr_alloc.cpp:30
T * pgr_alloc(std::size_t size, T *ptr)
allocates memory
Definition: pgr_alloc.hpp:66
virtual const char * what() const
Definition: pgr_assert.cpp:53

Here is the call graph for this function:

Here is the caller graph for this function: