Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' into fix/execute_benched
[simgrid.git] / src / surf / maxmin.cpp
index f1ddd53..0ae0d70 100644 (file)
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_maxmin, surf, "Logging specific to SURF (maxmin)");
 
-typedef std::vector<int> dyn_light_t;
-
 double sg_maxmin_precision = 0.00001; /* Change this with --cfg=maxmin/precision:VALUE */
 double sg_surf_precision   = 0.00001; /* Change this with --cfg=surf/precision:VALUE */
 int sg_concurrency_limit   = -1;      /* Change this with --cfg=maxmin/concurrency-limit:VALUE */
 
+namespace simgrid {
+namespace surf {
+
+typedef std::vector<int> dyn_light_t;
+
 int s_lmm_variable_t::Global_debug_id   = 1;
 int s_lmm_constraint_t::Global_debug_id = 1;
 
@@ -119,7 +122,7 @@ void s_lmm_system_t::check_concurrency()
 void s_lmm_system_t::var_free(lmm_variable_t var)
 {
   XBT_IN("(sys=%p, var=%p)", this, var);
-  modified = 1;
+  modified = true;
 
   // TODOLATER Can do better than that by leaving only the variable in only one enabled_element_set, call
   // update_modified_set, and then remove it..
@@ -148,13 +151,12 @@ void s_lmm_system_t::var_free(lmm_variable_t var)
   XBT_OUT();
 }
 
-s_lmm_system_t::s_lmm_system_t(bool selective_update)
+s_lmm_system_t::s_lmm_system_t(bool selective_update) : selective_update_active(selective_update)
 {
   s_lmm_variable_t var;
   s_lmm_constraint_t cnst;
 
-  modified                = 0;
-  selective_update_active = selective_update;
+  modified                = false;
   visited_counter         = 1;
 
   XBT_DEBUG("Setting selective_update_active flag to %d", selective_update_active);
@@ -197,11 +199,10 @@ void s_lmm_system_t::cnst_free(lmm_constraint_t cnst)
   delete cnst;
 }
 
-s_lmm_constraint_t::s_lmm_constraint_t(void* id_value, double bound_value)
+s_lmm_constraint_t::s_lmm_constraint_t(void* id_value, double bound_value) : bound(bound_value), id(id_value)
 {
   s_lmm_element_t elem;
 
-  id     = id_value;
   id_int = Global_debug_id++;
   xbt_swag_init(&enabled_element_set, xbt_swag_offset(elem, enabled_element_set_hookup));
   xbt_swag_init(&disabled_element_set, xbt_swag_offset(elem, disabled_element_set_hookup));
@@ -209,7 +210,6 @@ s_lmm_constraint_t::s_lmm_constraint_t(void* id_value, double bound_value)
 
   remaining           = 0.0;
   usage               = 0.0;
-  bound               = bound_value;
   concurrency_limit   = sg_concurrency_limit;
   concurrency_current = 0;
   concurrency_maximum = 0;
@@ -261,7 +261,7 @@ void s_lmm_system_t::variable_free(lmm_variable_t var)
 
 void s_lmm_system_t::expand(lmm_constraint_t cnst, lmm_variable_t var, double consumption_weight)
 {
-  modified = 1;
+  modified = true;
 
   //Check if this variable already has an active element in this constraint
   //If it does, substract it from the required slack
@@ -314,7 +314,7 @@ void s_lmm_system_t::expand(lmm_constraint_t cnst, lmm_variable_t var, double co
 
 void s_lmm_system_t::expand_add(lmm_constraint_t cnst, lmm_variable_t var, double value)
 {
-  modified = 1;
+  modified = true;
 
   check_concurrency();
 
@@ -706,7 +706,7 @@ void s_lmm_system_t::solve()
 
   } while (cnst_light_num > 0);
 
-  modified = 0;
+  modified = false;
   if (selective_update_active)
     remove_all_modified_set();
 
@@ -736,7 +736,7 @@ void lmm_solve(lmm_system_t sys)
  */
 void s_lmm_system_t::update_variable_bound(lmm_variable_t var, double bound)
 {
-  modified   = 1;
+  modified   = true;
   var->bound = bound;
 
   if (not var->cnsts.empty())
@@ -747,7 +747,7 @@ void s_lmm_variable_t::initialize(simgrid::surf::Action* id_value, double sharin
                                   int number_of_constraints, unsigned visited_value)
 {
   id     = id_value;
-  id_int = s_lmm_variable_t::Global_debug_id++;
+  id_int = Global_debug_id++;
   cnsts.reserve(number_of_constraints);
   sharing_weight    = sharing_weight_value;
   staged_weight     = 0.0;
@@ -892,7 +892,7 @@ void s_lmm_system_t::update_variable_weight(lmm_variable_t var, double weight)
 
   XBT_IN("(sys=%p, var=%p, weight=%f)", this, var, weight);
 
-  modified = 1;
+  modified = true;
 
   //Are we enabling this variable?
   if (enabling_var){
@@ -919,7 +919,7 @@ void s_lmm_system_t::update_variable_weight(lmm_variable_t var, double weight)
 
 void s_lmm_system_t::update_constraint_bound(lmm_constraint_t cnst, double bound)
 {
-  modified = 1;
+  modified = true;
   update_modified_set(cnst);
   cnst->bound = bound;
 }
@@ -1020,3 +1020,5 @@ int s_lmm_constraint_t::get_variable_amount() const
   }
   return result;
 }
+}
+}