* @brief LMM element
* Elements can be seen as glue between constraint objects and variable objects.
* Basically, each variable will have a set of elements, one for each constraint where it is involved.
- * Then, it is used to list all variables involved in constraint through constraint's xxx_element_set lists, or vice-versa list all constraints for a given variable.
+ * Then, it is used to list all variables involved in constraint through constraint's xxx_element_set lists, or
+ * vice-versa list all constraints for a given variable.
*/
-struct s_lmm_element_t {
+class s_lmm_element_t {
+public:
+ int get_concurrency() const;
+ void decrease_concurrency();
+ void increase_concurrency();
+
+ void make_active();
+ void make_inactive();
+
/* hookup to constraint */
s_xbt_swag_hookup_t enabled_element_set_hookup;
s_xbt_swag_hookup_t disabled_element_set_hookup;
// - If network, then 1 in forward direction and 0.05 backward for the ACKs
double consumption_weight;
};
-#define make_elem_active(elem) xbt_swag_insert_at_head((elem), &((elem)->constraint->active_element_set))
-#define make_elem_inactive(elem) xbt_swag_remove((elem), &((elem)->constraint->active_element_set))
struct s_lmm_constraint_light_t {
double remaining_over_usage;
*
* When something prevents us from enabling a variable, we "stage" the weight that we would have like to set, so that as soon as possible we enable the variable with desired weight
*/
-struct s_lmm_variable_t {
+class s_lmm_variable_t {
+public:
+ void initialize(simgrid::surf::Action* id_value, double sharing_weight_value, double bound_value,
+ int number_of_constraints, unsigned visited_value);
+
+ /**
+ * @brief Get the value of the variable after the last lmm solve
+ * @return The value of the variable
+ */
+ double get_value() const { return value; }
+
+ /**
+ * @brief Get the maximum value of the variable (-1.0 if no maximum value)
+ * @return The bound of the variable
+ */
+ double get_bound() const { return bound; }
+
+ /**
+ * @brief Set the concurrent share of the variable
+ * @param concurrency_share The new concurrency share
+ */
+ void set_concurrency_share(short int value) { concurrency_share = value; }
+
+ /**
+ * @brief Get the numth constraint associated to the variable
+ * @param num The rank of constraint we want to get
+ * @return The numth constraint
+ */
+ lmm_constraint_t get_constraint(unsigned num) const { return num < cnsts.size() ? cnsts[num].constraint : nullptr; }
+
+ /**
+ * @brief Get the weigth of the numth constraint associated to the variable
+ * @param num The rank of constraint we want to get
+ * @return The numth constraint
+ */
+ double get_constraint_weight(unsigned num) const { return num < cnsts.size() ? cnsts[num].consumption_weight : 0.0; }
+
+ /**
+ * @brief Get the number of constraint associated to a variable
+ * @return The number of constraint associated to the variable
+ */
+ int get_number_of_constraint() const { return cnsts.size(); }
+
+ /**
+ * @brief Get the data associated to a variable
+ * @return The data associated to the variable
+ */
+ simgrid::surf::Action* get_id() const { return id; }
+
+ /**
+ * @brief Get the weight of a variable
+ * @return The weight of the variable
+ */
+ double get_weight() const { return sharing_weight; }
+
+ /** @brief Measure the minimum concurrency slack across all constraints where the given var is involved */
+ int get_min_concurrency_slack() const;
+
+ /** @brief Check if a variable can be enabled
+ * Make sure to set staged_weight before, if your intent is only to check concurrency
+ */
+ int can_enable() const { return staged_weight > 0 && get_min_concurrency_slack() >= concurrency_share; }
+
/* hookup to system */
s_xbt_swag_hookup_t variable_set_hookup;
s_xbt_swag_hookup_t saturated_variable_set_hookup;
double (*func_fp)(s_lmm_variable_t* var, double x); /* (f') */
double (*func_fpi)(s_lmm_variable_t* var, double x); /* (f')^{-1} */
/* \end{For Lagrange only} */
+
+private:
+ static int Global_debug_id;
};
+inline void s_lmm_element_t::make_active()
+{
+ xbt_swag_insert_at_head(this, &constraint->active_element_set);
+}
+inline void s_lmm_element_t::make_inactive()
+{
+ xbt_swag_remove(this, &constraint->active_element_set);
+}
+
/** @ingroup SURF_lmm
* @brief LMM system
*/