4#include <digraphx/neg_cycle.hpp>
40 using Vec = std::valarray<double>;
41 using Cut = std::pair<Vec, double>;
45 NegCycleFinder<Graph> _S;
57 auto assess_optim(
const Vec& x,
double& gamma) -> std::tuple<Cut, bool> {
58 const auto tcp = x[0];
59 const auto beta = x[1];
61 return {Cut{Vec{-1.0, 0.0}, -tcp},
false};
63 if (
const auto fj = tcp - gamma * beta; fj > 0.0) {
64 return {Cut{Vec{1.0, -gamma}, fj},
false};
66 const auto get_weight = [tcp, beta](
const Edge& edge) ->
double {
67 return edge.type ==
's' ? tcp - edge.delay - beta : edge.delay - beta;
71 auto best = std::optional<Cut>{};
72 auto min_weight = 0.0;
73 for (
auto&& C : this->_S.howard(this->_dist, get_weight)) {
74 auto weight_sum = 0.0;
76 for (
auto&& edge : C) {
77 weight_sum += get_weight(edge);
78 setup += edge.type ==
's' ? 1.0 : 0.0;
80 if (weight_sum < min_weight) {
81 min_weight = weight_sum;
82 best = Cut{Vec{-setup,
static_cast<double>(C.size())}, -weight_sum};
86 return {std::move(*best),
false};
89 throw std::domain_error(
"ClockScheduleOracle: beta is zero (unbounded ratio)");
92 return {Cut{Vec{1.0, -1.0}, 0.0},
true};
99 auto operator()(
const Vec& x,
double& gamma) -> std::tuple<Cut, bool> {
auto assess_optim(const Vec &x, double &gamma) -> std::tuple< Cut, bool >
Assess optimality at x = (TCP, beta) (cutting-plane interface).
Definition css_oracle.hpp:57
ClockScheduleOracle(const Graph &gra, Mapping &dist)
Construct a new clock-schedule oracle.
Definition css_oracle.hpp:51
auto operator()(const Vec &x, double &gamma) -> std::tuple< Cut, bool >
Function call operator for cutting_plane_optim().
Definition css_oracle.hpp:99
Definition css_oracle.hpp:13
Internal implementation helpers shared by the netoptim algorithms.
std::remove_cv_t< std::remove_reference_t< decltype(_get_val( std::declval< NbrElem >(), std::declval< const Nbrs & >()))> > Edge
Definition netoptim_detail.hpp:36
Edge for the clock-skew scheduling oracle: delay and type.
Definition css_oracle.hpp:16
char type
's' setup, 'h' hold
Definition css_oracle.hpp:18
double delay
Definition css_oracle.hpp:17