80auto min_cycle_ratio(
const Graph& gra, T& r0, Fn1&& get_cost, Fn2&& get_time, Mapping&& dist,
81 size_t max_iters = 1000) {
83 using Elem =
decltype(*std::declval<const Graph&>().begin());
84 using Nbrs = std::remove_cv_t<std::remove_reference_t<
decltype(_get_val(
85 std::declval<Elem>(), std::declval<const Graph&>()))>>;
86 using NbrElem =
decltype(*std::declval<const Nbrs&>().begin());
87 using Edge = std::remove_cv_t<std::remove_reference_t<
decltype(_get_val(
88 std::declval<NbrElem>(), std::declval<const Nbrs&>()))>>;
91 auto calc_ratio = [&](
const auto& C) -> T {
92 using cost_T =
decltype(get_cost(std::declval<edge_t>()));
93 using time_T =
decltype(get_time(std::declval<edge_t>()));
94 auto total_cost = cost_T(0);
95 auto total_time = time_T(0);
96 for (
auto&& edge : C) {
97 total_cost += get_cost(edge);
98 total_time += get_time(edge);
100 return T(total_cost) / total_time;
103 auto calc_weight = [&](
const T& r,
const edge_t& edge) -> T {
104 return get_cost(edge) - r * T(get_time(edge));
107 return max_parametric(gra, r0, std::move(calc_weight), std::move(calc_ratio),
108 std::forward<Mapping>(dist), max_iters);
auto min_cycle_ratio(const Graph &gra, T &r0, Fn1 &&get_cost, Fn2 &&get_time, Mapping &&dist, size_t max_iters=1000)
Solve the minimum cost-to-time cycle ratio problem.
Definition min_cycle_ratio.hpp:80
auto max_parametric(const Graph &gra, T &r_opt, Fn1 &&distrance, Fn2 &&zero_cancel, Mapping &&dist, size_t max_iters=1000)
Solve the maximum parametric problem.
Definition parametric.hpp:71
typename boost::graph_traits< graph_t >::edge_iterator edge_t
Type alias for edge iterator.
Definition test_cases2_boost.hpp:39