nb++;
}
XBT_DEBUG("\tThere are %d variables", nb);
- if (nb > 0 && cnst.sharing_policy_ == s4u::Link::SharingPolicy::FATPIPE)
+ if (nb > 0 && cnst.sharing_policy_ == Constraint::SharingPolicy::FATPIPE)
nb = 1;
if (nb == 0) {
cnst.remaining_ = 0.0;
for (auto iter = std::begin(cnst_list); iter != std::end(cnst_list);) {
Constraint& cnst = *iter;
XBT_DEBUG("Updating cnst %p ", &cnst);
- if (cnst.sharing_policy_ != s4u::Link::SharingPolicy::FATPIPE) {
+ if (cnst.sharing_policy_ != Constraint::SharingPolicy::FATPIPE) {
for (const Element& elem : cnst.enabled_element_set_) {
xbt_assert(elem.variable->sharing_penalty_ > 0);
XBT_DEBUG("\tUpdate constraint %p (%g) with variable %p by %g", &cnst, cnst.remaining_, elem.variable,
if (var->sharing_penalty_ != 0.0)
elem.decrease_concurrency();
- if (cnst->sharing_policy_ != s4u::Link::SharingPolicy::FATPIPE)
+ if (cnst->sharing_policy_ != Constraint::SharingPolicy::FATPIPE)
elem.consumption_weight += value;
else
elem.consumption_weight = std::max(elem.consumption_weight, value);
}
template <class ElemList>
-static void format_element_list(const ElemList& elem_list, s4u::Link::SharingPolicy sharing_policy, double& sum,
+static void format_element_list(const ElemList& elem_list, Constraint::SharingPolicy sharing_policy, double& sum,
std::string& buf)
{
for (Element const& elem : elem_list) {
buf += std::to_string(elem.consumption_weight) + ".'" + std::to_string(elem.variable->rank_) + "'(" +
std::to_string(elem.variable->value_) + ")" +
- (sharing_policy != s4u::Link::SharingPolicy::FATPIPE ? " + " : " , ");
- if (sharing_policy != s4u::Link::SharingPolicy::FATPIPE)
+ (sharing_policy != Constraint::SharingPolicy::FATPIPE ? " + " : " , ");
+ if (sharing_policy != Constraint::SharingPolicy::FATPIPE)
sum += elem.consumption_weight * elem.variable->value_;
else
sum = std::max(sum, elem.consumption_weight * elem.variable->value_);
double sum = 0.0;
// Show the enabled variables
buf += "\t";
- buf += cnst.sharing_policy_ != s4u::Link::SharingPolicy::FATPIPE ? "(" : "max(";
+ buf += cnst.sharing_policy_ != Constraint::SharingPolicy::FATPIPE ? "(" : "max(";
format_element_list(cnst.enabled_element_set_, cnst.sharing_policy_, sum, buf);
// TODO: Adding disabled elements only for test compatibility, but do we really want them to be printed?
format_element_list(cnst.disabled_element_set_, cnst.sharing_policy_, sum, buf);
buf += "0) <= " + std::to_string(cnst.bound_) + " ('" + std::to_string(cnst.rank_) + "')";
- if (cnst.sharing_policy_ == s4u::Link::SharingPolicy::FATPIPE) {
+ if (cnst.sharing_policy_ == Constraint::SharingPolicy::FATPIPE) {
buf += " [MAX-Constraint]";
}
XBT_DEBUG("%s", buf.c_str());
xbt_assert(elem.variable->sharing_penalty_ > 0.0);
elem.variable->value_ = 0.0;
if (elem.consumption_weight > 0) {
- if (cnst.sharing_policy_ != s4u::Link::SharingPolicy::FATPIPE)
+ if (cnst.sharing_policy_ != Constraint::SharingPolicy::FATPIPE)
cnst.usage_ += elem.consumption_weight / elem.variable->sharing_penalty_;
else if (cnst.usage_ < elem.consumption_weight / elem.variable->sharing_penalty_)
cnst.usage_ = elem.consumption_weight / elem.variable->sharing_penalty_;
/* Update the usage of constraints where this variable is involved */
for (Element& elem : var.cnsts_) {
Constraint* cnst = elem.constraint;
- if (cnst->sharing_policy_ != s4u::Link::SharingPolicy::FATPIPE) {
+ if (cnst->sharing_policy_ != Constraint::SharingPolicy::FATPIPE) {
// Remember: shared constraints require that sum(elem.value * var.value) < cnst->bound
double_update(&(cnst->remaining_), elem.consumption_weight * var.value_, cnst->bound_ * sg_maxmin_precision);
double_update(&(cnst->usage_), elem.consumption_weight / var.sharing_penalty_, sg_maxmin_precision);
double Constraint::get_usage() const
{
double result = 0.0;
- if (sharing_policy_ != s4u::Link::SharingPolicy::FATPIPE) {
+ if (sharing_policy_ != SharingPolicy::FATPIPE) {
for (Element const& elem : enabled_element_set_)
if (elem.consumption_weight > 0)
result += elem.consumption_weight * elem.variable->value_;
*/
class XBT_PUBLIC Constraint {
public:
+ enum class SharingPolicy { SHARED = 1, FATPIPE = 0 };
Constraint() = delete;
Constraint(resource::Resource* id_value, double bound_value);
/** @brief Unshare a constraint. */
- void unshare() { sharing_policy_ = s4u::Link::SharingPolicy::FATPIPE; }
+ void unshare() { sharing_policy_ = SharingPolicy::FATPIPE; }
/** @brief Set how a constraint is shared */
- void set_sharing_policy(s4u::Link::SharingPolicy policy) { sharing_policy_ = policy; }
+ void set_sharing_policy(SharingPolicy policy) { sharing_policy_ = policy; }
/** @brief Check how a constraint is shared */
- s4u::Link::SharingPolicy get_sharing_policy() const { return sharing_policy_; }
+ SharingPolicy get_sharing_policy() const { return sharing_policy_; }
/** @brief Get the usage of the constraint after the last lmm solve */
double get_usage() const;
int concurrency_maximum_ = 0; /* The maximum number of (enabled and disabled) variables associated to the constraint
* at any given time (essentially for tracing)*/
- s4u::Link::SharingPolicy sharing_policy_ = s4u::Link::SharingPolicy::SHARED;
+ SharingPolicy sharing_policy_ = SharingPolicy::SHARED;
int rank_; // Only used in debug messages to identify the constraint
double lambda_ = 0.0;
double new_lambda_ = 0.0;