Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Make s_lmm_system_t a class with its methods.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Wed, 22 Nov 2017 14:17:50 +0000 (15:17 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Sun, 26 Nov 2017 14:48:00 +0000 (15:48 +0100)
16 files changed:
src/include/surf/maxmin.hpp
src/plugins/vm/VirtualMachineImpl.cpp
src/surf/StorageImpl.cpp
src/surf/cpu_cas01.cpp
src/surf/fair_bottleneck.cpp
src/surf/lagrange.cpp
src/surf/maxmin.cpp
src/surf/maxmin_private.hpp
src/surf/network_cm02.cpp
src/surf/network_ib.cpp
src/surf/network_interface.cpp
src/surf/ptask_L07.cpp
src/surf/storage_n11.cpp
src/surf/surf_interface.cpp
teshsuite/surf/lmm_usage/lmm_usage.cpp
teshsuite/surf/maxmin_bench/maxmin_bench.cpp

index 179793a..d2aad09 100644 (file)
@@ -148,25 +148,6 @@ static inline int double_equals(double value1, double value2, double precision)
 }
 
 /** @{ @ingroup SURF_lmm */
 }
 
 /** @{ @ingroup SURF_lmm */
-/**
- * @brief Create a new Linear MaxMim system
- * @param selective_update whether we should do lazy updates
- */
-XBT_PUBLIC(lmm_system_t) lmm_system_new(bool selective_update);
-
-/**
- * @brief Free an existing Linear MaxMin system
- * @param sys The lmm system to free
- */
-XBT_PUBLIC(void) lmm_system_free(lmm_system_t sys);
-
-/**
- * @brief Create a new Linear MaxMin constraint
- * @param sys The system in which we add a constraint
- * @param id Data associated to the constraint (e.g.: a network link)
- * @param bound_value The bound value of the constraint
- */
-XBT_PUBLIC(lmm_constraint_t) lmm_constraint_new(lmm_system_t sys, void* id, double bound_value);
 
 /**
  * @brief Share a constraint
 
 /**
  * @brief Share a constraint
@@ -218,24 +199,6 @@ XBT_PUBLIC(void) lmm_constraint_concurrency_maximum_reset(lmm_constraint_t cnst)
  */
 XBT_PUBLIC(int) lmm_constraint_concurrency_maximum_get(lmm_constraint_t cnst);
 
  */
 XBT_PUBLIC(int) lmm_constraint_concurrency_maximum_get(lmm_constraint_t cnst);
 
-/**
- * @brief Create a new Linear MaxMin variable
- * @param sys The system in which we add a constaint
- * @param id Data associated to the variable (e.g.: a network communication)
- * @param weight_value The weight of the variable (0.0 if not used)
- * @param bound The maximum value of the variable (-1.0 if no maximum value)
- * @param number_of_constraints The maximum number of constraint to associate to the variable
- */
-XBT_PUBLIC(lmm_variable_t)
-lmm_variable_new(lmm_system_t sys, simgrid::surf::Action* id, double weight_value, double bound,
-                 int number_of_constraints);
-/**
- * @brief Free a variable
- * @param sys The system associated to the variable
- * @param var The variable to free
- */
-XBT_PUBLIC(void) lmm_variable_free(lmm_system_t sys, lmm_variable_t var);
-
 /**
  * @brief Get the value of the variable after the last lmm solve
  * @param var A variable
 /**
  * @brief Get the value of the variable after the last lmm solve
  * @param var A variable
@@ -257,24 +220,6 @@ XBT_PUBLIC(double) lmm_variable_getbound(lmm_variable_t var);
  */
 XBT_PUBLIC(void) lmm_variable_concurrency_share_set(lmm_variable_t var, short int concurrency_share);
 
  */
 XBT_PUBLIC(void) lmm_variable_concurrency_share_set(lmm_variable_t var, short int concurrency_share);
 
-/**
- * @brief Associate a variable to a constraint with a coefficient
- * @param sys A system
- * @param cnst A constraint
- * @param var A variable
- * @param value The coefficient associated to the variable in the constraint
- */
-XBT_PUBLIC(void) lmm_expand(lmm_system_t sys, lmm_constraint_t cnst, lmm_variable_t var, double value);
-
-/**
- * @brief Add value to the coefficient between a constraint and a variable or create one
- * @param sys A system
- * @param cnst A constraint
- * @param var A variable
- * @param value The value to add to the coefficient associated to the variable in the constraint
- */
-XBT_PUBLIC(void) lmm_expand_add(lmm_system_t sys, lmm_constraint_t cnst, lmm_variable_t var, double value);
-
 /**
  * @brief Get the numth constraint associated to the variable
  * @param sys The system associated to the variable (not used)
 /**
  * @brief Get the numth constraint associated to the variable
  * @param sys The system associated to the variable (not used)
@@ -339,31 +284,6 @@ XBT_PUBLIC(void*) lmm_constraint_id(lmm_constraint_t cnst);
  */
 XBT_PUBLIC(void*) lmm_variable_id(lmm_variable_t var);
 
  */
 XBT_PUBLIC(void*) lmm_variable_id(lmm_variable_t var);
 
-/**
- * @brief Update the value of element linking the constraint and the variable
- * @param sys A system
- * @param cnst A constraint
- * @param var A variable
- * @param value The new value
- */
-XBT_PUBLIC(void) lmm_update(lmm_system_t sys, lmm_constraint_t cnst, lmm_variable_t var, double value);
-
-/**
- * @brief Update the bound of a variable
- * @param sys A system
- * @param var A constraint
- * @param bound The new bound
- */
-XBT_PUBLIC(void) lmm_update_variable_bound(lmm_system_t sys, lmm_variable_t var, double bound);
-
-/**
- * @brief Update the weight of a variable
- * @param sys A system
- * @param var A variable
- * @param weight The new weight of the variable
- */
-XBT_PUBLIC(void) lmm_update_variable_weight(lmm_system_t sys, lmm_variable_t var, double weight);
-
 /**
  * @brief Get the weight of a variable
  * @param var A variable
 /**
  * @brief Get the weight of a variable
  * @param var A variable
@@ -371,28 +291,6 @@ XBT_PUBLIC(void) lmm_update_variable_weight(lmm_system_t sys, lmm_variable_t var
  */
 XBT_PUBLIC(double) lmm_get_variable_weight(lmm_variable_t var);
 
  */
 XBT_PUBLIC(double) lmm_get_variable_weight(lmm_variable_t var);
 
-/**
- * @brief Update a constraint bound
- * @param sys A system
- * @param cnst A constraint
- * @param bound The new bound of the consrtaint
- */
-XBT_PUBLIC(void) lmm_update_constraint_bound(lmm_system_t sys, lmm_constraint_t cnst, double bound);
-
-/**
- * @brief [brief description]
- * @param sys A system
- * @param cnst A constraint
- * @return [description]
- */
-XBT_PUBLIC(int) lmm_constraint_used(lmm_system_t sys, lmm_constraint_t cnst);
-
-/**
- * @brief Print the lmm system
- * @param sys The lmm system to print
- */
-XBT_PUBLIC(void) lmm_print(lmm_system_t sys);
-
 /**
  * @brief Solve the lmm system
  * @param sys The lmm system to solve
 /**
  * @brief Solve the lmm system
  * @param sys The lmm system to solve
index aa60f1e..08ee5a1 100644 (file)
@@ -99,7 +99,7 @@ double VMModel::nextOccuringEvent(double now)
 
     xbt_assert(cpu->model() == surf_cpu_model_vm);
     lmm_system_t vcpu_system = cpu->model()->getMaxminSystem();
 
     xbt_assert(cpu->model() == surf_cpu_model_vm);
     lmm_system_t vcpu_system = cpu->model()->getMaxminSystem();
-    lmm_update_constraint_bound(vcpu_system, cpu->constraint(), virt_overhead * solved_value);
+    vcpu_system->update_constraint_bound(cpu->constraint(), virt_overhead * solved_value);
   }
 
   /* 2. Calculate resource share at the virtual machine layer. */
   }
 
   /* 2. Calculate resource share at the virtual machine layer. */
index 9ce12e2..160053b 100644 (file)
@@ -5,6 +5,7 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "StorageImpl.hpp"
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "StorageImpl.hpp"
+#include "maxmin_private.hpp"
 #include "surf_private.hpp"
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_storage, surf, "Logging specific to the SURF storage module");
 #include "surf_private.hpp"
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_storage, surf, "Logging specific to the SURF storage module");
@@ -40,12 +41,12 @@ StorageImpl* StorageImpl::byName(std::string name)
 
 StorageModel::StorageModel() : Model()
 {
 
 StorageModel::StorageModel() : Model()
 {
-  maxminSystem_ = lmm_system_new(true /* lazy update */);
+  maxminSystem_ = new s_lmm_system_t(true /* lazy update */);
 }
 
 StorageModel::~StorageModel()
 {
 }
 
 StorageModel::~StorageModel()
 {
-  lmm_system_free(maxminSystem_);
+  delete maxminSystem_;
   surf_storage_model = nullptr;
 }
 
   surf_storage_model = nullptr;
 }
 
@@ -55,7 +56,7 @@ StorageModel::~StorageModel()
 
 StorageImpl::StorageImpl(Model* model, std::string name, lmm_system_t maxminSystem, double bread, double bwrite,
                          std::string type_id, std::string content_name, sg_size_t size, std::string attach)
 
 StorageImpl::StorageImpl(Model* model, std::string name, lmm_system_t maxminSystem, double bread, double bwrite,
                          std::string type_id, std::string content_name, sg_size_t size, std::string attach)
-    : Resource(model, name.c_str(), lmm_constraint_new(maxminSystem, this, std::max(bread, bwrite)))
+    : Resource(model, name.c_str(), maxminSystem->constraint_new(this, std::max(bread, bwrite)))
     , piface_(this)
     , typeId_(type_id)
     , content_name(content_name)
     , piface_(this)
     , typeId_(type_id)
     , content_name(content_name)
@@ -64,8 +65,8 @@ StorageImpl::StorageImpl(Model* model, std::string name, lmm_system_t maxminSyst
 {
   StorageImpl::turnOn();
   XBT_DEBUG("Create resource with Bread '%f' Bwrite '%f' and Size '%llu'", bread, bwrite, size);
 {
   StorageImpl::turnOn();
   XBT_DEBUG("Create resource with Bread '%f' Bwrite '%f' and Size '%llu'", bread, bwrite, size);
-  constraintRead_  = lmm_constraint_new(maxminSystem, this, bread);
-  constraintWrite_ = lmm_constraint_new(maxminSystem, this, bwrite);
+  constraintRead_  = maxminSystem->constraint_new(this, bread);
+  constraintWrite_ = maxminSystem->constraint_new(this, bwrite);
   storages->insert({name, this});
 }
 
   storages->insert({name, this});
 }
 
index 99707a2..c25b816 100644 (file)
@@ -53,7 +53,7 @@ CpuCas01Model::CpuCas01Model() : simgrid::surf::CpuModel()
   }
 
   p_cpuRunningActionSetThatDoesNotNeedBeingChecked = new ActionList();
   }
 
   p_cpuRunningActionSetThatDoesNotNeedBeingChecked = new ActionList();
-  maxminSystem_ = lmm_system_new(selectiveUpdate_);
+  maxminSystem_                                    = new s_lmm_system_t(selectiveUpdate_);
 
   if (getUpdateMechanism() == UM_LAZY) {
     modifiedSet_ = new ActionLmmList();
 
   if (getUpdateMechanism() == UM_LAZY) {
     modifiedSet_ = new ActionLmmList();
@@ -63,7 +63,7 @@ CpuCas01Model::CpuCas01Model() : simgrid::surf::CpuModel()
 
 CpuCas01Model::~CpuCas01Model()
 {
 
 CpuCas01Model::~CpuCas01Model()
 {
-  lmm_system_free(maxminSystem_);
+  delete maxminSystem_;
   maxminSystem_ = nullptr;
   delete modifiedSet_;
 
   maxminSystem_ = nullptr;
   delete modifiedSet_;
 
@@ -80,9 +80,9 @@ Cpu *CpuCas01Model::createCpu(simgrid::s4u::Host *host, std::vector<double> *spe
 /************
  * Resource *
  ************/
 /************
  * Resource *
  ************/
-CpuCas01::CpuCas01(CpuCas01Model *model, simgrid::s4u::Host *host, std::vector<double> *speedPerPstate, int core)
-: Cpu(model, host, lmm_constraint_new(model->getMaxminSystem(), this, core * speedPerPstate->front()),
-    speedPerPstate, core)
+CpuCas01::CpuCas01(CpuCas01Model* model, simgrid::s4u::Host* host, std::vector<double>* speedPerPstate, int core)
+    : Cpu(model, host, model->getMaxminSystem()->constraint_new(this, core * speedPerPstate->front()), speedPerPstate,
+          core)
 {
 }
 
 {
 }
 
@@ -98,7 +98,7 @@ std::vector<double> * CpuCas01::getSpeedPeakList(){
 
 bool CpuCas01::isUsed()
 {
 
 bool CpuCas01::isUsed()
 {
-  return lmm_constraint_used(model()->getMaxminSystem(), constraint());
+  return model()->getMaxminSystem()->constraint_used(constraint());
 }
 
 /** @brief take into account changes of speed (either load or max) */
 }
 
 /** @brief take into account changes of speed (either load or max) */
@@ -106,12 +106,12 @@ void CpuCas01::onSpeedChange() {
   lmm_variable_t var = nullptr;
   lmm_element_t elem = nullptr;
 
   lmm_variable_t var = nullptr;
   lmm_element_t elem = nullptr;
 
-  lmm_update_constraint_bound(model()->getMaxminSystem(), constraint(), coresAmount_ * speed_.scale * speed_.peak);
+  model()->getMaxminSystem()->update_constraint_bound(constraint(), coresAmount_ * speed_.scale * speed_.peak);
   while ((var = lmm_get_var_from_cnst(model()->getMaxminSystem(), constraint(), &elem))) {
     CpuCas01Action* action = static_cast<CpuCas01Action*>(lmm_variable_id(var));
 
   while ((var = lmm_get_var_from_cnst(model()->getMaxminSystem(), constraint(), &elem))) {
     CpuCas01Action* action = static_cast<CpuCas01Action*>(lmm_variable_id(var));
 
-    lmm_update_variable_bound(model()->getMaxminSystem(), action->getVariable(),
-                              action->requestedCore() * speed_.scale * speed_.peak);
+    model()->getMaxminSystem()->update_variable_bound(action->getVariable(),
+                                                      action->requestedCore() * speed_.scale * speed_.peak);
   }
 
   Cpu::onSpeedChange();
   }
 
   Cpu::onSpeedChange();
@@ -189,7 +189,7 @@ CpuAction *CpuCas01::sleep(double duration)
     action->getStateSet()->push_back(*action);
   }
 
     action->getStateSet()->push_back(*action);
   }
 
-  lmm_update_variable_weight(model()->getMaxminSystem(), action->getVariable(), 0.0);
+  model()->getMaxminSystem()->update_variable_weight(action->getVariable(), 0.0);
   if (model()->getUpdateMechanism() == UM_LAZY) { // remove action from the heap
     action->heapRemove(model()->getActionHeap());
     // this is necessary for a variable with weight 0 since such variables are ignored in lmm and we need to set its
   if (model()->getUpdateMechanism() == UM_LAZY) { // remove action from the heap
     action->heapRemove(model()->getActionHeap());
     // this is necessary for a variable with weight 0 since such variables are ignored in lmm and we need to set its
@@ -207,14 +207,14 @@ CpuAction *CpuCas01::sleep(double duration)
 CpuCas01Action::CpuCas01Action(Model* model, double cost, bool failed, double speed, lmm_constraint_t constraint,
                                int requestedCore)
     : CpuAction(model, cost, failed,
 CpuCas01Action::CpuCas01Action(Model* model, double cost, bool failed, double speed, lmm_constraint_t constraint,
                                int requestedCore)
     : CpuAction(model, cost, failed,
-                lmm_variable_new(model->getMaxminSystem(), this, 1.0 / requestedCore, requestedCore * speed, 1))
+                model->getMaxminSystem()->variable_new(this, 1.0 / requestedCore, requestedCore * speed, 1))
     , requestedCore_(requestedCore)
 {
   if (model->getUpdateMechanism() == UM_LAZY) {
     refreshLastUpdate();
     setLastValue(0.0);
   }
     , requestedCore_(requestedCore)
 {
   if (model->getUpdateMechanism() == UM_LAZY) {
     refreshLastUpdate();
     setLastValue(0.0);
   }
-  lmm_expand(model->getMaxminSystem(), constraint, getVariable(), 1.0);
+  model->getMaxminSystem()->expand(constraint, getVariable(), 1.0);
 }
 
 CpuCas01Action::CpuCas01Action(Model* model, double cost, bool failed, double speed, lmm_constraint_t constraint)
 }
 
 CpuCas01Action::CpuCas01Action(Model* model, double cost, bool failed, double speed, lmm_constraint_t constraint)
index 84be37f..2270080 100644 (file)
@@ -82,7 +82,7 @@ void bottleneck_solve(lmm_system_t sys)
   do {
     if (XBT_LOG_ISENABLED(surf_maxmin, xbt_log_priority_debug)) {
       XBT_DEBUG("Fair bottleneck done");
   do {
     if (XBT_LOG_ISENABLED(surf_maxmin, xbt_log_priority_debug)) {
       XBT_DEBUG("Fair bottleneck done");
-      lmm_print(sys);
+      sys->print();
     }
     XBT_DEBUG("******* Constraints to process: %d *******", xbt_swag_size(cnst_list));
     xbt_swag_foreach_safe(_cnst, _cnst_next, cnst_list) {
     }
     XBT_DEBUG("******* Constraints to process: %d *******", xbt_swag_size(cnst_list));
     xbt_swag_foreach_safe(_cnst, _cnst_next, cnst_list) {
@@ -172,6 +172,6 @@ void bottleneck_solve(lmm_system_t sys)
   sys->modified = 0;
   if (XBT_LOG_ISENABLED(surf_maxmin, xbt_log_priority_debug)) {
     XBT_DEBUG("Fair bottleneck done");
   sys->modified = 0;
   if (XBT_LOG_ISENABLED(surf_maxmin, xbt_log_priority_debug)) {
     XBT_DEBUG("Fair bottleneck done");
-    lmm_print(sys);
+    sys->print();
   }
 }
   }
 }
index 447273b..fed6aa0 100644 (file)
@@ -179,7 +179,7 @@ void lagrange_solve(lmm_system_t sys)
   XBT_DEBUG("#### Minimum error tolerated (dichotomy) : %e", dichotomy_min_error);
 
   if (XBT_LOG_ISENABLED(surf_lagrange, xbt_log_priority_debug)) {
   XBT_DEBUG("#### Minimum error tolerated (dichotomy) : %e", dichotomy_min_error);
 
   if (XBT_LOG_ISENABLED(surf_lagrange, xbt_log_priority_debug)) {
-    lmm_print(sys);
+    sys->print();
   }
 
   if (not sys->modified)
   }
 
   if (not sys->modified)
@@ -299,7 +299,7 @@ void lagrange_solve(lmm_system_t sys)
   }
 
   if (XBT_LOG_ISENABLED(surf_lagrange, xbt_log_priority_debug)) {
   }
 
   if (XBT_LOG_ISENABLED(surf_lagrange, xbt_log_priority_debug)) {
-    lmm_print(sys);
+    sys->print();
   }
 }
 
   }
 }
 
index e5006da..f76a376 100644 (file)
@@ -25,20 +25,10 @@ double sg_maxmin_precision = 0.00001; /* Change this with --cfg=maxmin/precision
 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 */
 
 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 */
 
-static void *lmm_variable_mallocator_new_f();
-static void lmm_variable_mallocator_free_f(void *var);
-#define lmm_variable_mallocator_reset_f ((void_f_pvoid_t)nullptr)
-static void lmm_update_modified_set(lmm_system_t sys, lmm_constraint_t cnst);
-static void lmm_remove_all_modified_set(lmm_system_t sys);
 static int Global_debug_id = 1;
 static int Global_const_debug_id = 1;
 
 static int Global_debug_id = 1;
 static int Global_const_debug_id = 1;
 
-static inline void lmm_cnst_free(lmm_system_t sys, lmm_constraint_t cnst);
-
-static void lmm_on_disabled_var(lmm_system_t sys, lmm_constraint_t cnstr);
-static void lmm_enable_var(lmm_system_t sys, lmm_variable_t var);
 static int lmm_can_enable_var(lmm_variable_t var);
 static int lmm_can_enable_var(lmm_variable_t var);
-static void lmm_disable_var(lmm_system_t sys, lmm_variable_t var);
 static int lmm_concurrency_slack(lmm_constraint_t cnstr);
 static int lmm_cnstrs_min_concurrency_slack(lmm_variable_t var);
 
 static int lmm_concurrency_slack(lmm_constraint_t cnstr);
 static int lmm_cnstrs_min_concurrency_slack(lmm_variable_t var);
 
@@ -73,14 +63,14 @@ static inline void lmm_increase_concurrency(lmm_element_t elem)
              "Concurrency limit overflow!");
 }
 
              "Concurrency limit overflow!");
 }
 
-static void lmm_check_concurrency(lmm_system_t sys)
+void s_lmm_system_t::check_concurrency()
 {
   // These checks are very expensive, so do them only if we want to debug SURF LMM
   if (not XBT_LOG_ISENABLED(surf_maxmin, xbt_log_priority_debug))
     return;
 
   void* cnstIt;
 {
   // These checks are very expensive, so do them only if we want to debug SURF LMM
   if (not XBT_LOG_ISENABLED(surf_maxmin, xbt_log_priority_debug))
     return;
 
   void* cnstIt;
-  xbt_swag_foreach(cnstIt, &(sys->constraint_set))
+  xbt_swag_foreach(cnstIt, &constraint_set)
   {
     lmm_constraint_t cnst = (lmm_constraint_t)cnstIt;
     int concurrency       = 0;
   {
     lmm_constraint_t cnst = (lmm_constraint_t)cnstIt;
     int concurrency       = 0;
@@ -107,7 +97,7 @@ static void lmm_check_concurrency(lmm_system_t sys)
 
   // Check that for each variable, all corresponding elements are in the same state (i.e. same element sets)
   void* varIt;
 
   // Check that for each variable, all corresponding elements are in the same state (i.e. same element sets)
   void* varIt;
-  xbt_swag_foreach(varIt, &(sys->variable_set))
+  xbt_swag_foreach(varIt, &variable_set)
   {
     lmm_variable_t var = (lmm_variable_t)varIt;
 
   {
     lmm_variable_t var = (lmm_variable_t)varIt;
 
@@ -130,15 +120,15 @@ static void lmm_check_concurrency(lmm_system_t sys)
   }
 }
 
   }
 }
 
-static void lmm_var_free(lmm_system_t sys, lmm_variable_t var)
+void s_lmm_system_t::var_free(lmm_variable_t var)
 {
 {
-  XBT_IN("(sys=%p, var=%p)", sys, var);
-  sys->modified = 1;
+  XBT_IN("(sys=%p, var=%p)", this, var);
+  modified = 1;
 
   // TODOLATER Can do better than that by leaving only the variable in only one enabled_element_set, call
 
   // TODOLATER Can do better than that by leaving only the variable in only one enabled_element_set, call
-  // lmm_update_modified_set, and then remove it..
+  // update_modified_set, and then remove it..
   if (not var->cnsts.empty())
   if (not var->cnsts.empty())
-    lmm_update_modified_set(sys, var->cnsts[0].constraint);
+    update_modified_set(var->cnsts[0].constraint);
 
   for (s_lmm_element_t& elem : var->cnsts) {
     if (var->sharing_weight > 0)
 
   for (s_lmm_element_t& elem : var->cnsts) {
     if (var->sharing_weight > 0)
@@ -149,79 +139,69 @@ static void lmm_var_free(lmm_system_t sys, lmm_variable_t var)
     int nelements = xbt_swag_size(&(elem.constraint->enabled_element_set)) +
                     xbt_swag_size(&(elem.constraint->disabled_element_set));
     if (nelements == 0)
     int nelements = xbt_swag_size(&(elem.constraint->enabled_element_set)) +
                     xbt_swag_size(&(elem.constraint->disabled_element_set));
     if (nelements == 0)
-      make_constraint_inactive(sys, elem.constraint);
+      make_constraint_inactive(elem.constraint);
     else
     else
-      lmm_on_disabled_var(sys, elem.constraint);
+      on_disabled_var(elem.constraint);
   }
 
   var->cnsts.clear();
 
   }
 
   var->cnsts.clear();
 
-  lmm_check_concurrency(sys);
+  check_concurrency();
 
 
-  xbt_mallocator_release(sys->variable_mallocator, var);
+  xbt_mallocator_release(variable_mallocator, var);
   XBT_OUT();
 }
 
   XBT_OUT();
 }
 
-lmm_system_t lmm_system_new(bool selective_update)
+s_lmm_system_t::s_lmm_system_t(bool selective_update)
 {
   s_lmm_variable_t var;
   s_lmm_constraint_t cnst;
 
 {
   s_lmm_variable_t var;
   s_lmm_constraint_t cnst;
 
-  lmm_system_t l = new s_lmm_system_t();
-
-  l->modified = 0;
-  l->selective_update_active = selective_update;
-  l->visited_counter = 1;
-
-  XBT_DEBUG("Setting selective_update_active flag to %d", l->selective_update_active);
+  modified                = 0;
+  selective_update_active = selective_update;
+  visited_counter         = 1;
 
 
-  xbt_swag_init(&(l->variable_set), xbt_swag_offset(var, variable_set_hookup));
-  xbt_swag_init(&(l->constraint_set), xbt_swag_offset(cnst, constraint_set_hookup));
+  XBT_DEBUG("Setting selective_update_active flag to %d", selective_update_active);
 
 
-  xbt_swag_init(&(l->active_constraint_set), xbt_swag_offset(cnst, active_constraint_set_hookup));
+  xbt_swag_init(&variable_set, xbt_swag_offset(var, variable_set_hookup));
+  xbt_swag_init(&constraint_set, xbt_swag_offset(cnst, constraint_set_hookup));
 
 
-  xbt_swag_init(&(l->modified_constraint_set), xbt_swag_offset(cnst, modified_constraint_set_hookup));
-  xbt_swag_init(&(l->saturated_variable_set), xbt_swag_offset(var, saturated_variable_set_hookup));
-  xbt_swag_init(&(l->saturated_constraint_set), xbt_swag_offset(cnst, saturated_constraint_set_hookup));
+  xbt_swag_init(&active_constraint_set, xbt_swag_offset(cnst, active_constraint_set_hookup));
 
 
-  l->variable_mallocator = xbt_mallocator_new(65536,
-                                              lmm_variable_mallocator_new_f,
-                                              lmm_variable_mallocator_free_f,
-                                              lmm_variable_mallocator_reset_f);
+  xbt_swag_init(&modified_constraint_set, xbt_swag_offset(cnst, modified_constraint_set_hookup));
+  xbt_swag_init(&saturated_variable_set, xbt_swag_offset(var, saturated_variable_set_hookup));
+  xbt_swag_init(&saturated_constraint_set, xbt_swag_offset(cnst, saturated_constraint_set_hookup));
 
 
-  l->solve_fun = &lmm_solve;
-
-  return l;
+  keep_track          = nullptr;
+  variable_mallocator = xbt_mallocator_new(65536, s_lmm_system_t::variable_mallocator_new_f,
+                                           s_lmm_system_t::variable_mallocator_free_f, nullptr);
+  solve_fun = &lmm_solve;
 }
 
 }
 
-void lmm_system_free(lmm_system_t sys)
+s_lmm_system_t::~s_lmm_system_t()
 {
 {
-  lmm_variable_t var = nullptr;
-  lmm_constraint_t cnst = nullptr;
+  lmm_variable_t var;
+  lmm_constraint_t cnst;
 
 
-  if (sys == nullptr)
-    return;
-
-  while ((var = (lmm_variable_t) extract_variable(sys))) {
+  while ((var = extract_variable())) {
     auto demangled = simgrid::xbt::demangle(typeid(*var->id).name());
     XBT_WARN("Probable bug: a %s variable (#%d) not removed before the LMM system destruction.", demangled.get(),
              var->id_int);
     auto demangled = simgrid::xbt::demangle(typeid(*var->id).name());
     XBT_WARN("Probable bug: a %s variable (#%d) not removed before the LMM system destruction.", demangled.get(),
              var->id_int);
-    lmm_var_free(sys, var);
+    var_free(var);
   }
   }
-  while ((cnst = (lmm_constraint_t) extract_constraint(sys)))
-    lmm_cnst_free(sys, cnst);
+  while ((cnst = extract_constraint()))
+    cnst_free(cnst);
 
 
-  xbt_mallocator_free(sys->variable_mallocator);
-  delete sys;
+  xbt_mallocator_free(variable_mallocator);
 }
 
 }
 
-static inline void lmm_cnst_free(lmm_system_t sys, lmm_constraint_t cnst)
+void s_lmm_system_t::cnst_free(lmm_constraint_t cnst)
 {
 {
-  make_constraint_inactive(sys, cnst);
+  make_constraint_inactive(cnst);
   delete cnst;
 }
 
   delete cnst;
 }
 
-lmm_constraint_t lmm_constraint_new(lmm_system_t sys, void *id, double bound_value)
+lmm_constraint_t s_lmm_system_t::constraint_new(void* id, double bound_value)
 {
   lmm_constraint_t cnst = nullptr;
   s_lmm_element_t elem;
 {
   lmm_constraint_t cnst = nullptr;
   s_lmm_element_t elem;
@@ -239,7 +219,7 @@ lmm_constraint_t lmm_constraint_new(lmm_system_t sys, void *id, double bound_val
   cnst->concurrency_limit  = sg_concurrency_limit;
   cnst->usage = 0;
   cnst->sharing_policy = 1; /* FIXME: don't hardcode the value */
   cnst->concurrency_limit  = sg_concurrency_limit;
   cnst->usage = 0;
   cnst->sharing_policy = 1; /* FIXME: don't hardcode the value */
-  insert_constraint(sys, cnst);
+  insert_constraint(cnst);
 
   return cnst;
 }
 
   return cnst;
 }
@@ -280,22 +260,22 @@ int lmm_constraint_sharing_policy(lmm_constraint_t cnst)
   return (cnst->sharing_policy);
 }
 
   return (cnst->sharing_policy);
 }
 
-static void *lmm_variable_mallocator_new_f()
+void* s_lmm_system_t::variable_mallocator_new_f()
 {
   return new s_lmm_variable_t;
 }
 
 {
   return new s_lmm_variable_t;
 }
 
-static void lmm_variable_mallocator_free_f(void *var)
+void s_lmm_system_t::variable_mallocator_free_f(void* var)
 {
   delete static_cast<lmm_variable_t>(var);
 }
 
 {
   delete static_cast<lmm_variable_t>(var);
 }
 
-lmm_variable_t lmm_variable_new(lmm_system_t sys, simgrid::surf::Action* id, double sharing_weight, double bound,
-                                int number_of_constraints)
+lmm_variable_t s_lmm_system_t::variable_new(simgrid::surf::Action* id, double sharing_weight, double bound,
+                                            int number_of_constraints)
 {
 {
-  XBT_IN("(sys=%p, id=%p, weight=%f, bound=%f, num_cons =%d)", sys, id, sharing_weight, bound, number_of_constraints);
+  XBT_IN("(sys=%p, id=%p, weight=%f, bound=%f, num_cons =%d)", this, id, sharing_weight, bound, number_of_constraints);
 
 
-  lmm_variable_t var = (lmm_variable_t)xbt_mallocator_get(sys->variable_mallocator);
+  lmm_variable_t var = (lmm_variable_t)xbt_mallocator_get(variable_mallocator);
   var->id = id;
   var->id_int = Global_debug_id++;
   var->cnsts.reserve(number_of_constraints);
   var->id = id;
   var->id_int = Global_debug_id++;
   var->cnsts.reserve(number_of_constraints);
@@ -304,7 +284,7 @@ lmm_variable_t lmm_variable_new(lmm_system_t sys, simgrid::surf::Action* id, dou
   var->bound = bound;
   var->concurrency_share = 1;
   var->value = 0.0;
   var->bound = bound;
   var->concurrency_share = 1;
   var->value = 0.0;
-  var->visited = sys->visited_counter - 1;
+  var->visited           = visited_counter - 1;
   var->mu = 0.0;
   var->new_mu = 0.0;
   var->func_f = func_f_def;
   var->mu = 0.0;
   var->new_mu = 0.0;
   var->func_f = func_f_def;
@@ -317,18 +297,18 @@ lmm_variable_t lmm_variable_new(lmm_system_t sys, simgrid::surf::Action* id, dou
   var->saturated_variable_set_hookup.prev = nullptr;
 
   if (sharing_weight)
   var->saturated_variable_set_hookup.prev = nullptr;
 
   if (sharing_weight)
-    xbt_swag_insert_at_head(var, &(sys->variable_set));
+    xbt_swag_insert_at_head(var, &variable_set);
   else
   else
-    xbt_swag_insert_at_tail(var, &(sys->variable_set));
+    xbt_swag_insert_at_tail(var, &variable_set);
 
   XBT_OUT(" returns %p", var);
   return var;
 }
 
 
   XBT_OUT(" returns %p", var);
   return var;
 }
 
-void lmm_variable_free(lmm_system_t sys, lmm_variable_t var)
+void s_lmm_system_t::variable_free(lmm_variable_t var)
 {
 {
-  remove_variable(sys, var);
-  lmm_var_free(sys, var);
+  remove_variable(var);
+  var_free(var);
 }
 
 double lmm_variable_getvalue(lmm_variable_t var)
 }
 
 double lmm_variable_getvalue(lmm_variable_t var)
@@ -346,9 +326,9 @@ double lmm_variable_getbound(lmm_variable_t var)
   return (var->bound);
 }
 
   return (var->bound);
 }
 
-void lmm_expand(lmm_system_t sys, lmm_constraint_t cnst, lmm_variable_t var, double consumption_weight)
+void s_lmm_system_t::expand(lmm_constraint_t cnst, lmm_variable_t var, double consumption_weight)
 {
 {
-  sys->modified = 1;
+  modified = 1;
 
   //Check if this variable already has an active element in this constraint
   //If it does, substract it from the required slack
 
   //Check if this variable already has an active element in this constraint
   //If it does, substract it from the required slack
@@ -363,9 +343,9 @@ void lmm_expand(lmm_system_t sys, lmm_constraint_t cnst, lmm_variable_t var, dou
   //Check if we need to disable the variable
   if (var->sharing_weight > 0 && var->concurrency_share - current_share > lmm_concurrency_slack(cnst)) {
     double weight = var->sharing_weight;
   //Check if we need to disable the variable
   if (var->sharing_weight > 0 && var->concurrency_share - current_share > lmm_concurrency_slack(cnst)) {
     double weight = var->sharing_weight;
-    lmm_disable_var(sys,var);
+    disable_var(var);
     for (s_lmm_element_t const& elem : var->cnsts)
     for (s_lmm_element_t const& elem : var->cnsts)
-      lmm_on_disabled_var(sys, elem.constraint);
+      on_disabled_var(elem.constraint);
     consumption_weight = 0;
     var->staged_weight=weight;
     xbt_assert(not var->sharing_weight);
     consumption_weight = 0;
     var->staged_weight=weight;
     xbt_assert(not var->sharing_weight);
@@ -386,24 +366,24 @@ void lmm_expand(lmm_system_t sys, lmm_constraint_t cnst, lmm_variable_t var, dou
   } else
     xbt_swag_insert_at_tail(&elem, &(elem.constraint->disabled_element_set));
 
   } else
     xbt_swag_insert_at_tail(&elem, &(elem.constraint->disabled_element_set));
 
-  if (not sys->selective_update_active) {
-    make_constraint_active(sys, cnst);
+  if (not selective_update_active) {
+    make_constraint_active(cnst);
   } else if (elem.consumption_weight > 0 || var->sharing_weight > 0) {
   } else if (elem.consumption_weight > 0 || var->sharing_weight > 0) {
-    make_constraint_active(sys, cnst);
-    lmm_update_modified_set(sys, cnst);
+    make_constraint_active(cnst);
+    update_modified_set(cnst);
     //TODOLATER: Why do we need this second call?
     if (var->cnsts.size() > 1)
     //TODOLATER: Why do we need this second call?
     if (var->cnsts.size() > 1)
-      lmm_update_modified_set(sys, var->cnsts[0].constraint);
+      update_modified_set(var->cnsts[0].constraint);
   }
 
   }
 
-  lmm_check_concurrency(sys);
+  check_concurrency();
 }
 
 }
 
-void lmm_expand_add(lmm_system_t sys, lmm_constraint_t cnst, lmm_variable_t var, double value)
+void s_lmm_system_t::expand_add(lmm_constraint_t cnst, lmm_variable_t var, double value)
 {
 {
-  sys->modified = 1;
+  modified = 1;
 
 
-  lmm_check_concurrency(sys);
+  check_concurrency();
 
   //BEWARE: In case you have multiple elements in one constraint, this will always add value to the first element.
   auto elem_it = std::find_if(begin(var->cnsts), end(var->cnsts),
 
   //BEWARE: In case you have multiple elements in one constraint, this will always add value to the first element.
   auto elem_it = std::find_if(begin(var->cnsts), end(var->cnsts),
@@ -422,19 +402,19 @@ void lmm_expand_add(lmm_system_t sys, lmm_constraint_t cnst, lmm_variable_t var,
     if (var->sharing_weight) {
       if (lmm_concurrency_slack(cnst) < lmm_element_concurrency(&elem)) {
         double weight = var->sharing_weight;
     if (var->sharing_weight) {
       if (lmm_concurrency_slack(cnst) < lmm_element_concurrency(&elem)) {
         double weight = var->sharing_weight;
-        lmm_disable_var(sys,var);
+        disable_var(var);
         for (s_lmm_element_t const& elem2 : var->cnsts)
         for (s_lmm_element_t const& elem2 : var->cnsts)
-          lmm_on_disabled_var(sys, elem2.constraint);
+          on_disabled_var(elem2.constraint);
         var->staged_weight=weight;
         xbt_assert(not var->sharing_weight);
       }
       lmm_increase_concurrency(&elem);
     }
         var->staged_weight=weight;
         xbt_assert(not var->sharing_weight);
       }
       lmm_increase_concurrency(&elem);
     }
-    lmm_update_modified_set(sys, cnst);
+    update_modified_set(cnst);
   } else
   } else
-    lmm_expand(sys, cnst, var, value);
+    expand(cnst, var, value);
 
 
-  lmm_check_concurrency(sys);
+  check_concurrency();
 }
 
 lmm_constraint_t lmm_get_cnst_from_var(lmm_system_t /*sys*/, lmm_variable_t var, unsigned num)
 }
 
 lmm_constraint_t lmm_get_cnst_from_var(lmm_system_t /*sys*/, lmm_variable_t var, unsigned num)
@@ -557,13 +537,13 @@ static inline void saturated_variable_set_update(s_lmm_constraint_light_t* cnst_
   }
 }
 
   }
 }
 
-void lmm_print(lmm_system_t sys)
+void s_lmm_system_t::print()
 {
   std::string buf       = std::string("MAX-MIN ( ");
   void* _var;
 
   /* Printing Objective */
 {
   std::string buf       = std::string("MAX-MIN ( ");
   void* _var;
 
   /* Printing Objective */
-  xbt_swag_t var_list = &(sys->variable_set);
+  xbt_swag_t var_list = &variable_set;
   xbt_swag_foreach(_var, var_list) {
     lmm_variable_t var = (lmm_variable_t)_var;
     buf = buf + "'" + std::to_string(var->id_int) + "'(" + std::to_string(var->sharing_weight) + ") ";
   xbt_swag_foreach(_var, var_list) {
     lmm_variable_t var = (lmm_variable_t)_var;
     buf = buf + "'" + std::to_string(var->id_int) + "'(" + std::to_string(var->sharing_weight) + ") ";
@@ -575,7 +555,7 @@ void lmm_print(lmm_system_t sys)
   XBT_DEBUG("Constraints");
   /* Printing Constraints */
   void* _cnst;
   XBT_DEBUG("Constraints");
   /* Printing Constraints */
   void* _cnst;
-  xbt_swag_t cnst_list = &(sys->active_constraint_set);
+  xbt_swag_t cnst_list = &active_constraint_set;
   xbt_swag_foreach(_cnst, cnst_list) {
     lmm_constraint_t cnst = (lmm_constraint_t)_cnst;
     double sum = 0.0;
   xbt_swag_foreach(_cnst, cnst_list) {
     lmm_constraint_t cnst = (lmm_constraint_t)_cnst;
     double sum = 0.0;
@@ -630,7 +610,7 @@ void lmm_print(lmm_system_t sys)
   }
 }
 
   }
 }
 
-void lmm_solve(lmm_system_t sys)
+void s_lmm_system_t::solve()
 {
   void* _cnst;
   void* _cnst_next;
 {
   void* _cnst;
   void* _cnst_next;
@@ -638,15 +618,15 @@ void lmm_solve(lmm_system_t sys)
   double min_usage = -1;
   double min_bound = -1;
 
   double min_usage = -1;
   double min_bound = -1;
 
-  if (not sys->modified)
+  if (not modified)
     return;
 
     return;
 
-  XBT_IN("(sys=%p)", sys);
+  XBT_IN("(sys=%p)", this);
 
   /* Compute Usage and store the variables that reach the maximum. If selective_update_active is true, only constraints
    * that changed are considered. Otherwise all constraints with active actions are considered.
    */
 
   /* Compute Usage and store the variables that reach the maximum. If selective_update_active is true, only constraints
    * that changed are considered. Otherwise all constraints with active actions are considered.
    */
-  xbt_swag_t cnst_list = sys->selective_update_active ? &(sys->modified_constraint_set) : &(sys->active_constraint_set);
+  xbt_swag_t cnst_list = selective_update_active ? &modified_constraint_set : &active_constraint_set;
 
   XBT_DEBUG("Active constraints : %d", xbt_swag_size(cnst_list));
   /* Init: Only modified code portions: reset the value of active variables */
 
   XBT_DEBUG("Active constraints : %d", xbt_swag_size(cnst_list));
   /* Init: Only modified code portions: reset the value of active variables */
@@ -684,8 +664,8 @@ void lmm_solve(lmm_system_t sys)
 
         make_elem_active(elem);
         simgrid::surf::Action *action = static_cast<simgrid::surf::Action*>(elem->variable->id);
 
         make_elem_active(elem);
         simgrid::surf::Action *action = static_cast<simgrid::surf::Action*>(elem->variable->id);
-        if (sys->keep_track && not action->is_linked())
-          sys->keep_track->push_back(*action);
+        if (keep_track && not action->is_linked())
+          keep_track->push_back(*action);
       }
     }
     XBT_DEBUG("Constraint '%d' usage: %f remaining: %f concurrency: %i<=%i<=%i", cnst->id_int, cnst->usage,
       }
     }
     XBT_DEBUG("Constraint '%d' usage: %f remaining: %f concurrency: %i<=%i<=%i", cnst->id_int, cnst->usage,
@@ -703,12 +683,12 @@ void lmm_solve(lmm_system_t sys)
     }
   }
 
     }
   }
 
-  saturated_variable_set_update(  cnst_light_tab, saturated_constraint_set, sys);
+  saturated_variable_set_update(cnst_light_tab, saturated_constraint_set, this);
 
   /* Saturated variables update */
   do {
     /* Fix the variables that have to be */
 
   /* Saturated variables update */
   do {
     /* Fix the variables that have to be */
-    xbt_swag_t var_list = &(sys->saturated_variable_set);
+    xbt_swag_t var_list = &saturated_variable_set;
     void* _var;
     lmm_variable_t var = nullptr;
     xbt_swag_foreach(_var, var_list) {
     void* _var;
     lmm_variable_t var = nullptr;
     xbt_swag_foreach(_var, var_list) {
@@ -822,24 +802,29 @@ void lmm_solve(lmm_system_t sys)
                                       &min_usage);
     }
 
                                       &min_usage);
     }
 
-    saturated_variable_set_update(cnst_light_tab, saturated_constraint_set, sys);
+    saturated_variable_set_update(cnst_light_tab, saturated_constraint_set, this);
 
   } while (cnst_light_num > 0);
 
 
   } while (cnst_light_num > 0);
 
-  sys->modified = 0;
-  if (sys->selective_update_active)
-    lmm_remove_all_modified_set(sys);
+  modified = 0;
+  if (selective_update_active)
+    remove_all_modified_set();
 
   if (XBT_LOG_ISENABLED(surf_maxmin, xbt_log_priority_debug)) {
 
   if (XBT_LOG_ISENABLED(surf_maxmin, xbt_log_priority_debug)) {
-    lmm_print(sys);
+    print();
   }
 
   }
 
-  lmm_check_concurrency(sys);
+  check_concurrency();
 
   delete[] cnst_light_tab;
   XBT_OUT();
 }
 
 
   delete[] cnst_light_tab;
   XBT_OUT();
 }
 
+void lmm_solve(lmm_system_t sys)
+{
+  sys->solve();
+}
+
 /** \brief Attribute the value bound to var->bound.
  *
  *  \param sys the lmm_system_t
 /** \brief Attribute the value bound to var->bound.
  *
  *  \param sys the lmm_system_t
@@ -849,13 +834,13 @@ void lmm_solve(lmm_system_t sys)
  *  Makes var->bound equal to bound. Whenever this function is called a change is  signed in the system. To
  *  avoid false system changing detection it is a good idea to test (bound != 0) before calling it.
  */
  *  Makes var->bound equal to bound. Whenever this function is called a change is  signed in the system. To
  *  avoid false system changing detection it is a good idea to test (bound != 0) before calling it.
  */
-void lmm_update_variable_bound(lmm_system_t sys, lmm_variable_t var, double bound)
+void s_lmm_system_t::update_variable_bound(lmm_variable_t var, double bound)
 {
 {
-  sys->modified = 1;
+  modified   = 1;
   var->bound = bound;
 
   if (not var->cnsts.empty())
   var->bound = bound;
 
   if (not var->cnsts.empty())
-    lmm_update_modified_set(sys, var->cnsts[0].constraint);
+    update_modified_set(var->cnsts[0].constraint);
 }
 
 int lmm_concurrency_slack(lmm_constraint_t cnstr)
 }
 
 int lmm_concurrency_slack(lmm_constraint_t cnstr)
@@ -890,41 +875,43 @@ int lmm_can_enable_var(lmm_variable_t var){
 }
 
 //Small remark: In this implementation of lmm_enable_var and lmm_disable_var, we will meet multiple times with var when
 }
 
 //Small remark: In this implementation of lmm_enable_var and lmm_disable_var, we will meet multiple times with var when
-// running lmm_update_modified_set.
-//A priori not a big performance issue, but we might do better by calling lmm_update_modified_set within the for loops
+// running sys->update_modified_set.
+// A priori not a big performance issue, but we might do better by calling sys->update_modified_set within the for loops
 // (after doing the first for enabling==1, and before doing the last for disabling==1)
 // (after doing the first for enabling==1, and before doing the last for disabling==1)
-void lmm_enable_var(lmm_system_t sys, lmm_variable_t var){
+void s_lmm_system_t::enable_var(lmm_variable_t var)
+{
   xbt_assert(not XBT_LOG_ISENABLED(surf_maxmin, xbt_log_priority_debug) || lmm_can_enable_var(var));
 
   var->sharing_weight = var->staged_weight;
   var->staged_weight = 0;
 
   xbt_assert(not XBT_LOG_ISENABLED(surf_maxmin, xbt_log_priority_debug) || lmm_can_enable_var(var));
 
   var->sharing_weight = var->staged_weight;
   var->staged_weight = 0;
 
-  // Enabling the variable, move to var to list head. Subtlety is: here, we need to call lmm_update_modified_set AFTER
+  // Enabling the variable, move to var to list head. Subtlety is: here, we need to call update_modified_set AFTER
   // moving at least one element of var.
 
   // moving at least one element of var.
 
-  xbt_swag_remove(var, &(sys->variable_set));
-  xbt_swag_insert_at_head(var, &(sys->variable_set));
+  xbt_swag_remove(var, &variable_set);
+  xbt_swag_insert_at_head(var, &variable_set);
   for (s_lmm_element_t& elem : var->cnsts) {
     xbt_swag_remove(&elem, &(elem.constraint->disabled_element_set));
     xbt_swag_insert_at_head(&elem, &(elem.constraint->enabled_element_set));
     lmm_increase_concurrency(&elem);
   }
   if (not var->cnsts.empty())
   for (s_lmm_element_t& elem : var->cnsts) {
     xbt_swag_remove(&elem, &(elem.constraint->disabled_element_set));
     xbt_swag_insert_at_head(&elem, &(elem.constraint->enabled_element_set));
     lmm_increase_concurrency(&elem);
   }
   if (not var->cnsts.empty())
-    lmm_update_modified_set(sys, var->cnsts[0].constraint);
+    update_modified_set(var->cnsts[0].constraint);
 
 
-  //When used within lmm_on_disabled_var, we would get an assertion fail, because transiently there can be variables
+  // When used within on_disabled_var, we would get an assertion fail, because transiently there can be variables
   // that are staged and could be activated.
   // that are staged and could be activated.
-  //Anyway, caller functions all call lmm_check_concurrency() in the end.
+  // Anyway, caller functions all call check_concurrency() in the end.
 }
 
 }
 
-void lmm_disable_var(lmm_system_t sys, lmm_variable_t var){
+void s_lmm_system_t::disable_var(lmm_variable_t var)
+{
   xbt_assert(not var->staged_weight, "Staged weight should have been cleared");
   xbt_assert(not var->staged_weight, "Staged weight should have been cleared");
-  // Disabling the variable, move to var to list tail. Subtlety is: here, we need to call lmm_update_modified_set BEFORE
-  // moving the last element of var.
-  xbt_swag_remove(var, &(sys->variable_set));
-  xbt_swag_insert_at_tail(var, &(sys->variable_set));
+  // Disabling the variable, move to var to list tail. Subtlety is: here, we need to call update_modified_set
+  // BEFORE moving the last element of var.
+  xbt_swag_remove(var, &variable_set);
+  xbt_swag_insert_at_tail(var, &variable_set);
   if (not var->cnsts.empty())
   if (not var->cnsts.empty())
-    lmm_update_modified_set(sys, var->cnsts[0].constraint);
+    update_modified_set(var->cnsts[0].constraint);
   for (s_lmm_element_t& elem : var->cnsts) {
     xbt_swag_remove(&elem, &(elem.constraint->enabled_element_set));
     xbt_swag_insert_at_tail(&elem, &(elem.constraint->disabled_element_set));
   for (s_lmm_element_t& elem : var->cnsts) {
     xbt_swag_remove(&elem, &(elem.constraint->enabled_element_set));
     xbt_swag_insert_at_tail(&elem, &(elem.constraint->disabled_element_set));
@@ -937,7 +924,7 @@ void lmm_disable_var(lmm_system_t sys, lmm_variable_t var){
   var->sharing_weight = 0.0;
   var->staged_weight=0.0;
   var->value = 0.0;
   var->sharing_weight = 0.0;
   var->staged_weight=0.0;
   var->value = 0.0;
-  lmm_check_concurrency(sys);
+  check_concurrency();
 }
 
 /* /brief Find variables that can be enabled and enable them.
 }
 
 /* /brief Find variables that can be enabled and enable them.
@@ -947,8 +934,8 @@ void lmm_disable_var(lmm_system_t sys, lmm_variable_t var){
  * If yes, check that none of the constraints that this variable is involved in is at the limit of its concurrency
  * And then add it to enabled variables
  */
  * If yes, check that none of the constraints that this variable is involved in is at the limit of its concurrency
  * And then add it to enabled variables
  */
-void lmm_on_disabled_var(lmm_system_t sys, lmm_constraint_t cnstr){
-
+void s_lmm_system_t::on_disabled_var(lmm_constraint_t cnstr)
+{
   if(cnstr->concurrency_limit<0)
     return;
 
   if(cnstr->concurrency_limit<0)
     return;
 
@@ -967,7 +954,7 @@ void lmm_on_disabled_var(lmm_system_t sys, lmm_constraint_t cnstr){
       //Found a staged variable
       //TODOLATER: Add random timing function to model reservation protocol fuzziness? Then how to make sure that
       //staged variables will eventually be called?
       //Found a staged variable
       //TODOLATER: Add random timing function to model reservation protocol fuzziness? Then how to make sure that
       //staged variables will eventually be called?
-      lmm_enable_var(sys, elem->variable);
+      enable_var(elem->variable);
     }
 
     xbt_assert(cnstr->concurrency_current<=cnstr->concurrency_limit,"Concurrency overflow!");
     }
 
     xbt_assert(cnstr->concurrency_current<=cnstr->concurrency_limit,"Concurrency overflow!");
@@ -979,13 +966,13 @@ void lmm_on_disabled_var(lmm_system_t sys, lmm_constraint_t cnstr){
 
   //We could get an assertion fail, because transiently there can be variables that are staged and could be activated.
   //And we need to go through all constraints of the disabled var before getting back a coherent state.
 
   //We could get an assertion fail, because transiently there can be variables that are staged and could be activated.
   //And we need to go through all constraints of the disabled var before getting back a coherent state.
-  //Anyway, caller functions all call lmm_check_concurrency() in the end.
+  // Anyway, caller functions all call check_concurrency() in the end.
 }
 
 /* \brief update the weight of a variable, and enable/disable it.
  * @return Returns whether a change was made
  */
 }
 
 /* \brief update the weight of a variable, and enable/disable it.
  * @return Returns whether a change was made
  */
-void lmm_update_variable_weight(lmm_system_t sys, lmm_variable_t var, double weight)
+void s_lmm_system_t::update_variable_weight(lmm_variable_t var, double weight)
 {
   xbt_assert(weight>=0,"Variable weight should not be negative!");
 
 {
   xbt_assert(weight>=0,"Variable weight should not be negative!");
 
@@ -995,9 +982,9 @@ void lmm_update_variable_weight(lmm_system_t sys, lmm_variable_t var, double wei
   int enabling_var  = (weight > 0 && var->sharing_weight <= 0);
   int disabling_var = (weight <= 0 && var->sharing_weight > 0);
 
   int enabling_var  = (weight > 0 && var->sharing_weight <= 0);
   int disabling_var = (weight <= 0 && var->sharing_weight > 0);
 
-  XBT_IN("(sys=%p, var=%p, weight=%f)", sys, var, weight);
+  XBT_IN("(sys=%p, var=%p, weight=%f)", this, var, weight);
 
 
-  sys->modified = 1;
+  modified = 1;
 
   //Are we enabling this variable?
   if (enabling_var){
 
   //Are we enabling this variable?
   if (enabling_var){
@@ -1009,15 +996,15 @@ void lmm_update_variable_weight(lmm_system_t sys, lmm_variable_t var, double wei
       return;
     }
     XBT_DEBUG("Enabling var with min concurrency slack %i", minslack);
       return;
     }
     XBT_DEBUG("Enabling var with min concurrency slack %i", minslack);
-    lmm_enable_var(sys,var);
+    enable_var(var);
   } else if (disabling_var){
     //Are we disabling this variable?
   } else if (disabling_var){
     //Are we disabling this variable?
-    lmm_disable_var(sys,var);
+    disable_var(var);
   } else {
     var->sharing_weight = weight;
   }
 
   } else {
     var->sharing_weight = weight;
   }
 
-  lmm_check_concurrency(sys);
+  check_concurrency();
 
   XBT_OUT();
 }
 
   XBT_OUT();
 }
@@ -1027,18 +1014,13 @@ double lmm_get_variable_weight(lmm_variable_t var)
   return var->sharing_weight;
 }
 
   return var->sharing_weight;
 }
 
-void lmm_update_constraint_bound(lmm_system_t sys, lmm_constraint_t cnst, double bound)
+void s_lmm_system_t::update_constraint_bound(lmm_constraint_t cnst, double bound)
 {
 {
-  sys->modified = 1;
-  lmm_update_modified_set(sys, cnst);
+  modified = 1;
+  update_modified_set(cnst);
   cnst->bound = bound;
 }
 
   cnst->bound = bound;
 }
 
-int lmm_constraint_used(lmm_system_t sys, lmm_constraint_t cnst)
-{
-  return xbt_swag_belongs(cnst, &(sys->active_constraint_set));
-}
-
 /** \brief Update the constraint set propagating recursively to other constraints so the system should not be entirely
  *  computed.
  *
 /** \brief Update the constraint set propagating recursively to other constraints so the system should not be entirely
  *  computed.
  *
@@ -1048,52 +1030,48 @@ int lmm_constraint_used(lmm_system_t sys, lmm_constraint_t cnst)
  *  A recursive algorithm to optimize the system recalculation selecting only constraints that have changed. Each
  *  constraint change is propagated to the list of constraints for each variable.
  */
  *  A recursive algorithm to optimize the system recalculation selecting only constraints that have changed. Each
  *  constraint change is propagated to the list of constraints for each variable.
  */
-static void lmm_update_modified_set_rec(lmm_system_t sys, lmm_constraint_t cnst)
+void s_lmm_system_t::update_modified_set_rec(lmm_constraint_t cnst)
 {
   void* _elem;
 
   xbt_swag_foreach(_elem, &cnst->enabled_element_set) {
     lmm_variable_t var = ((lmm_element_t)_elem)->variable;
     for (s_lmm_element_t const& elem : var->cnsts) {
 {
   void* _elem;
 
   xbt_swag_foreach(_elem, &cnst->enabled_element_set) {
     lmm_variable_t var = ((lmm_element_t)_elem)->variable;
     for (s_lmm_element_t const& elem : var->cnsts) {
-      if (var->visited == sys->visited_counter)
+      if (var->visited == visited_counter)
         break;
         break;
-      if (elem.constraint != cnst && not xbt_swag_belongs(elem.constraint, &sys->modified_constraint_set)) {
-        xbt_swag_insert(elem.constraint, &sys->modified_constraint_set);
-        lmm_update_modified_set_rec(sys, elem.constraint);
+      if (elem.constraint != cnst && not xbt_swag_belongs(elem.constraint, &modified_constraint_set)) {
+        xbt_swag_insert(elem.constraint, &modified_constraint_set);
+        update_modified_set_rec(elem.constraint);
       }
     }
     //var will be ignored in later visits as long as sys->visited_counter does not move
       }
     }
     //var will be ignored in later visits as long as sys->visited_counter does not move
-    var->visited = sys->visited_counter;
+    var->visited = visited_counter;
   }
 }
 
   }
 }
 
-static void lmm_update_modified_set(lmm_system_t sys, lmm_constraint_t cnst)
+void s_lmm_system_t::update_modified_set(lmm_constraint_t cnst)
 {
   /* nothing to do if selective update isn't active */
 {
   /* nothing to do if selective update isn't active */
-  if (sys->selective_update_active && not xbt_swag_belongs(cnst, &sys->modified_constraint_set)) {
-    xbt_swag_insert(cnst, &sys->modified_constraint_set);
-    lmm_update_modified_set_rec(sys, cnst);
+  if (selective_update_active && not xbt_swag_belongs(cnst, &modified_constraint_set)) {
+    xbt_swag_insert(cnst, &modified_constraint_set);
+    update_modified_set_rec(cnst);
   }
 }
 
   }
 }
 
-/** \brief Remove all constraints of the modified_constraint_set.
- *
- *  \param sys the lmm_system_t
- */
-static void lmm_remove_all_modified_set(lmm_system_t sys)
+void s_lmm_system_t::remove_all_modified_set()
 {
 {
-  // We cleverly un-flag all variables just by incrementing sys->visited_counter
-  // In effect, the var->visited value will no more be equal to sys->visited counter
+  // We cleverly un-flag all variables just by incrementing visited_counter
+  // In effect, the var->visited value will no more be equal to visited counter
   // To be clean, when visited counter has wrapped around, we force these var->visited values so that variables that
   // were in the modified a long long time ago are not wrongly skipped here, which would lead to very nasty bugs
   // (i.e. not readibily reproducible, and requiring a lot of run time before happening).
   // To be clean, when visited counter has wrapped around, we force these var->visited values so that variables that
   // were in the modified a long long time ago are not wrongly skipped here, which would lead to very nasty bugs
   // (i.e. not readibily reproducible, and requiring a lot of run time before happening).
-  if (++sys->visited_counter == 1) {
+  if (++visited_counter == 1) {
     /* the counter wrapped around, reset each variable->visited */
     /* the counter wrapped around, reset each variable->visited */
-  void *_var;
-    xbt_swag_foreach(_var, &sys->variable_set)
+    void *_var;
+    xbt_swag_foreach(_var, &variable_set)
       ((lmm_variable_t)_var)->visited = 0;
   }
       ((lmm_variable_t)_var)->visited = 0;
   }
-  xbt_swag_reset(&sys->modified_constraint_set);
+  xbt_swag_reset(&modified_constraint_set);
 }
 
 /**
 }
 
 /**
index 0350557..581e424 100644 (file)
@@ -112,52 +112,152 @@ struct s_lmm_variable_t {
 /** @ingroup SURF_lmm
  * @brief LMM system
  */
 /** @ingroup SURF_lmm
  * @brief LMM system
  */
-struct s_lmm_system_t {
+class s_lmm_system_t {
+public:
+  /**
+   * @brief Create a new Linear MaxMim system
+   * @param selective_update whether we should do lazy updates
+   */
+  s_lmm_system_t(bool selective_update);
+  /** @brief Free an existing Linear MaxMin system */
+  ~s_lmm_system_t();
+
+  /**
+   * @brief Create a new Linear MaxMin constraint
+   * @param id Data associated to the constraint (e.g.: a network link)
+   * @param bound_value The bound value of the constraint
+   */
+  lmm_constraint_t constraint_new(void* id, double bound_value);
+
+  /**
+   * @brief Create a new Linear MaxMin variable
+   * @param id Data associated to the variable (e.g.: a network communication)
+   * @param weight_value The weight of the variable (0.0 if not used)
+   * @param bound The maximum value of the variable (-1.0 if no maximum value)
+   * @param number_of_constraints The maximum number of constraint to associate to the variable
+   */
+  lmm_variable_t variable_new(simgrid::surf::Action* id, double weight_value, double bound, int number_of_constraints);
+
+  /**
+   * @brief Free a variable
+   * @param var The variable to free
+   */
+  void variable_free(lmm_variable_t var);
+
+  /**
+   * @brief Associate a variable to a constraint with a coefficient
+   * @param cnst A constraint
+   * @param var A variable
+   * @param value The coefficient associated to the variable in the constraint
+   */
+  void expand(lmm_constraint_t cnst, lmm_variable_t var, double value);
+
+  /**
+   * @brief Add value to the coefficient between a constraint and a variable or create one
+   * @param cnst A constraint
+   * @param var A variable
+   * @param value The value to add to the coefficient associated to the variable in the constraint
+   */
+  void expand_add(lmm_constraint_t cnst, lmm_variable_t var, double value);
+
+  /**
+   * @brief Update the bound of a variable
+   * @param var A constraint
+   * @param bound The new bound
+   */
+  void update_variable_bound(lmm_variable_t var, double bound);
+
+  /**
+   * @brief Update the weight of a variable
+   * @param var A variable
+   * @param weight The new weight of the variable
+   */
+  void update_variable_weight(lmm_variable_t var, double weight);
+
+  /**
+   * @brief Update a constraint bound
+   * @param cnst A constraint
+   * @param bound The new bound of the consrtaint
+   */
+  void update_constraint_bound(lmm_constraint_t cnst, double bound);
+
+  /**
+   * @brief [brief description]
+   * @param cnst A constraint
+   * @return [description]
+   */
+  int constraint_used(lmm_constraint_t cnst) { return xbt_swag_belongs(cnst, &active_constraint_set); }
+
+  /** @brief Print the lmm system */
+  void print();
+
+  /** @brief Solve the lmm system */
+  void solve();
+
+private:
+  static void* variable_mallocator_new_f();
+  static void variable_mallocator_free_f(void* var);
+
+  void var_free(lmm_variable_t var);
+  void cnst_free(lmm_constraint_t cnst);
+  lmm_variable_t extract_variable() { return static_cast<lmm_variable_t>(xbt_swag_extract(&variable_set)); }
+  lmm_constraint_t extract_constraint() { return static_cast<lmm_constraint_t>(xbt_swag_extract(&constraint_set)); }
+  void insert_constraint(lmm_constraint_t cnst) { xbt_swag_insert(cnst, &constraint_set); }
+  void remove_variable(lmm_variable_t var)
+  {
+    xbt_swag_remove(var, &variable_set);
+    xbt_swag_remove(var, &saturated_variable_set);
+  }
+  void remove_constraint(lmm_constraint_t cnst) // FIXME: unused
+  {
+    xbt_swag_remove(cnst, &constraint_set);
+    xbt_swag_remove(cnst, &saturated_constraint_set);
+  }
+  void make_constraint_active(lmm_constraint_t cnst) { xbt_swag_insert(cnst, &active_constraint_set); }
+  void make_constraint_inactive(lmm_constraint_t cnst)
+  {
+    xbt_swag_remove(cnst, &active_constraint_set);
+    xbt_swag_remove(cnst, &modified_constraint_set);
+  }
+
+  void enable_var(lmm_variable_t var);
+  void disable_var(lmm_variable_t var);
+  void on_disabled_var(lmm_constraint_t cnstr);
+
+  /**
+   * @brief Update the value of element linking the constraint and the variable
+   * @param cnst A constraint
+   * @param var A variable
+   * @param value The new value
+   */
+  void update(lmm_constraint_t cnst, lmm_variable_t var, double value);
+
+  void update_modified_set(lmm_constraint_t cnst);
+  void update_modified_set_rec(lmm_constraint_t cnst);
+
+  /** @brief Remove all constraints of the modified_constraint_set. */
+  void remove_all_modified_set();
+  void check_concurrency();
+
+public:
   int modified;
   int modified;
-  bool selective_update_active;  /* flag to update partially the system only selecting changed portions */
-  unsigned visited_counter;     /* used by lmm_update_modified_set  and lmm_remove_modified_set to cleverly (un-)flag the constraints (more details in these functions)*/
   s_xbt_swag_t variable_set;    /* a list of lmm_variable_t */
   s_xbt_swag_t variable_set;    /* a list of lmm_variable_t */
-  s_xbt_swag_t constraint_set;  /* a list of lmm_constraint_t */
-
   s_xbt_swag_t active_constraint_set;   /* a list of lmm_constraint_t */
   s_xbt_swag_t active_constraint_set;   /* a list of lmm_constraint_t */
-  s_xbt_swag_t modified_constraint_set; /* a list of modified lmm_constraint_t */
-
   s_xbt_swag_t saturated_variable_set;  /* a list of lmm_variable_t */
   s_xbt_swag_t saturated_constraint_set;        /* a list of lmm_constraint_t_t */
 
   simgrid::surf::ActionLmmListPtr keep_track;
 
   s_xbt_swag_t saturated_variable_set;  /* a list of lmm_variable_t */
   s_xbt_swag_t saturated_constraint_set;        /* a list of lmm_constraint_t_t */
 
   simgrid::surf::ActionLmmListPtr keep_track;
 
-  xbt_mallocator_t variable_mallocator;
-
   void (*solve_fun)(lmm_system_t self);
   void (*solve_fun)(lmm_system_t self);
-};
 
 
-#define extract_variable(sys) xbt_swag_extract(&((sys)->variable_set))
-#define extract_constraint(sys) xbt_swag_extract(&((sys)->constraint_set))
-#define insert_constraint(sys, cnst) xbt_swag_insert((cnst), &((sys)->constraint_set))
-#define remove_variable(sys, var)                                                                                      \
-  do {                                                                                                                 \
-    xbt_swag_remove(var, &((sys)->variable_set));                                                                      \
-    xbt_swag_remove(var, &((sys)->saturated_variable_set));                                                            \
-  } while (0)
-#define remove_constraint(sys, cnst)                                                                                   \
-  do {                                                                                                                 \
-    xbt_swag_remove((cnst), &((sys)->constraint_set));                                                                 \
-    xbt_swag_remove((cnst), &((sys)->saturated_constraint_set));                                                       \
-  } while (0)
-#define make_constraint_active(sys, cnst) xbt_swag_insert((cnst), &((sys)->active_constraint_set))
-#define make_constraint_inactive(sys, cnst)                                                                            \
-  do {                                                                                                                 \
-    xbt_swag_remove((cnst), &(sys)->active_constraint_set);                                                            \
-    xbt_swag_remove((cnst), &(sys)->modified_constraint_set);                                                          \
-  } while (0)
-
-/** @ingroup SURF_lmm
- * @brief Print information about a lmm system
- *
- * @param sys A lmm system
- */
-//XBT_PRIVATE void lmm_print(lmm_system_t sys);
+private:
+  bool selective_update_active; /* flag to update partially the system only selecting changed portions */
+  unsigned visited_counter;     /* used by lmm_update_modified_set and lmm_remove_modified_set to cleverly (un-)flag the
+                                 * constraints (more details in these functions) */
+  s_xbt_swag_t constraint_set;  /* a list of lmm_constraint_t */
+  s_xbt_swag_t modified_constraint_set; /* a list of modified lmm_constraint_t */
+  xbt_mallocator_t variable_mallocator;
+};
 
 extern XBT_PRIVATE double (*func_f_def) (lmm_variable_t, double);
 extern XBT_PRIVATE double (*func_fp_def) (lmm_variable_t, double);
 
 extern XBT_PRIVATE double (*func_f_def) (lmm_variable_t, double);
 extern XBT_PRIVATE double (*func_fp_def) (lmm_variable_t, double);
index 943acb8..9cd804c 100644 (file)
@@ -149,7 +149,7 @@ NetworkCm02Model::NetworkCm02Model()
     xbt_die("Unsupported optimization (%s) for this model. Accepted: Full, Lazy.", optim.c_str());
   }
 
     xbt_die("Unsupported optimization (%s) for this model. Accepted: Full, Lazy.", optim.c_str());
   }
 
-  maxminSystem_ = lmm_system_new(selectiveUpdate_);
+  maxminSystem_ = new s_lmm_system_t(selectiveUpdate_);
   loopback_     = NetworkCm02Model::createLink("__loopback__", 498000000, 0.000015, SURF_LINK_FATPIPE);
 
   if (getUpdateMechanism() == UM_LAZY) {
   loopback_     = NetworkCm02Model::createLink("__loopback__", 498000000, 0.000015, SURF_LINK_FATPIPE);
 
   if (getUpdateMechanism() == UM_LAZY) {
@@ -191,7 +191,7 @@ void NetworkCm02Model::updateActionsStateLazy(double now, double /*delta*/)
     // if I am wearing a latency hat
     if (action->getHat() == LATENCY) {
       XBT_DEBUG("Latency paid for action %p. Activating", action);
     // if I am wearing a latency hat
     if (action->getHat() == LATENCY) {
       XBT_DEBUG("Latency paid for action %p. Activating", action);
-      lmm_update_variable_weight(maxminSystem_, action->getVariable(), action->weight_);
+      maxminSystem_->update_variable_weight(action->getVariable(), action->weight_);
       action->heapRemove(getActionHeap());
       action->refreshLastUpdate();
 
       action->heapRemove(getActionHeap());
       action->refreshLastUpdate();
 
@@ -224,7 +224,7 @@ void NetworkCm02Model::updateActionsStateFull(double now, double delta)
         action.latency_ = 0.0;
       }
       if (action.latency_ <= 0.0 && not action.isSuspended())
         action.latency_ = 0.0;
       }
       if (action.latency_ <= 0.0 && not action.isSuspended())
-        lmm_update_variable_weight(maxminSystem_, action.getVariable(), action.weight_);
+        maxminSystem_->update_variable_weight(action.getVariable(), action.weight_);
     }
     if (TRACE_is_enabled()) {
       int n = lmm_get_number_of_cnst_from_var(maxminSystem_, action.getVariable());
     }
     if (TRACE_is_enabled()) {
       int n = lmm_get_number_of_cnst_from_var(maxminSystem_, action.getVariable());
@@ -307,28 +307,32 @@ Action* NetworkCm02Model::communicate(s4u::Host* src, s4u::Host* dst, double siz
   constraints_per_variable += back_route.size();
 
   if (action->latency_ > 0) {
   constraints_per_variable += back_route.size();
 
   if (action->latency_ > 0) {
-    action->setVariable(lmm_variable_new(maxminSystem_, action, 0.0, -1.0, constraints_per_variable));
+    action->setVariable(maxminSystem_->variable_new(action, 0.0, -1.0, constraints_per_variable));
     if (getUpdateMechanism() == UM_LAZY) {
       // add to the heap the event when the latency is payed
       XBT_DEBUG("Added action (%p) one latency event at date %f", action, action->latency_ + action->getLastUpdate());
       action->heapInsert(getActionHeap(), action->latency_ + action->getLastUpdate(), route.empty() ? NORMAL : LATENCY);
     }
   } else
     if (getUpdateMechanism() == UM_LAZY) {
       // add to the heap the event when the latency is payed
       XBT_DEBUG("Added action (%p) one latency event at date %f", action, action->latency_ + action->getLastUpdate());
       action->heapInsert(getActionHeap(), action->latency_ + action->getLastUpdate(), route.empty() ? NORMAL : LATENCY);
     }
   } else
-    action->setVariable(lmm_variable_new(maxminSystem_, action, 1.0, -1.0, constraints_per_variable));
+    action->setVariable(maxminSystem_->variable_new(action, 1.0, -1.0, constraints_per_variable));
 
   if (action->rate_ < 0) {
 
   if (action->rate_ < 0) {
-    lmm_update_variable_bound(maxminSystem_, action->getVariable(), (action->latCurrent_ > 0) ? sg_tcp_gamma / (2.0 * action->latCurrent_) : -1.0);
+    maxminSystem_->update_variable_bound(action->getVariable(),
+                                         (action->latCurrent_ > 0) ? sg_tcp_gamma / (2.0 * action->latCurrent_) : -1.0);
   } else {
   } else {
-    lmm_update_variable_bound(maxminSystem_, action->getVariable(), (action->latCurrent_ > 0) ? std::min(action->rate_, sg_tcp_gamma / (2.0 * action->latCurrent_)) : action->rate_);
+    maxminSystem_->update_variable_bound(action->getVariable(),
+                                         (action->latCurrent_ > 0)
+                                             ? std::min(action->rate_, sg_tcp_gamma / (2.0 * action->latCurrent_))
+                                             : action->rate_);
   }
 
   for (auto const& link : route)
   }
 
   for (auto const& link : route)
-    lmm_expand(maxminSystem_, link->constraint(), action->getVariable(), 1.0);
+    maxminSystem_->expand(link->constraint(), action->getVariable(), 1.0);
 
   if (not back_route.empty()) { //  sg_network_crosstraffic was activated
     XBT_DEBUG("Fullduplex active adding backward flow using 5%%");
     for (auto const& link : back_route)
 
   if (not back_route.empty()) { //  sg_network_crosstraffic was activated
     XBT_DEBUG("Fullduplex active adding backward flow using 5%%");
     for (auto const& link : back_route)
-      lmm_expand(maxminSystem_, link->constraint(), action->getVariable(), .05);
+      maxminSystem_->expand(link->constraint(), action->getVariable(), .05);
 
     //Change concurrency_share here, if you want that cross-traffic is included in the SURF concurrency
     //(You would also have to change lmm_element_concurrency())
 
     //Change concurrency_share here, if you want that cross-traffic is included in the SURF concurrency
     //(You would also have to change lmm_element_concurrency())
@@ -345,7 +349,7 @@ Action* NetworkCm02Model::communicate(s4u::Host* src, s4u::Host* dst, double siz
  ************/
 NetworkCm02Link::NetworkCm02Link(NetworkCm02Model* model, const std::string& name, double bandwidth, double latency,
                                  e_surf_link_sharing_policy_t policy, lmm_system_t system)
  ************/
 NetworkCm02Link::NetworkCm02Link(NetworkCm02Model* model, const std::string& name, double bandwidth, double latency,
                                  e_surf_link_sharing_policy_t policy, lmm_system_t system)
-    : LinkImpl(model, name, lmm_constraint_new(system, this, sg_bandwidth_factor * bandwidth))
+    : LinkImpl(model, name, system->constraint_new(this, sg_bandwidth_factor * bandwidth))
 {
   bandwidth_.scale = 1.0;
   bandwidth_.peak  = bandwidth;
 {
   bandwidth_.scale = 1.0;
   bandwidth_.peak  = bandwidth;
@@ -399,11 +403,10 @@ void NetworkCm02Link::apply_event(tmgr_trace_event_t triggered, double value)
 
 void NetworkCm02Link::setBandwidth(double value)
 {
 
 void NetworkCm02Link::setBandwidth(double value)
 {
-
   bandwidth_.peak = value;
 
   bandwidth_.peak = value;
 
-  lmm_update_constraint_bound(model()->getMaxminSystem(), constraint(),
-                              sg_bandwidth_factor * (bandwidth_.peak * bandwidth_.scale));
+  model()->getMaxminSystem()->update_constraint_bound(constraint(),
+                                                      sg_bandwidth_factor * (bandwidth_.peak * bandwidth_.scale));
   TRACE_surf_link_set_bandwidth(surf_get_clock(), getCname(), sg_bandwidth_factor * bandwidth_.peak * bandwidth_.scale);
 
   if (sg_weight_S_parameter > 0) {
   TRACE_surf_link_set_bandwidth(surf_get_clock(), getCname(), sg_bandwidth_factor * bandwidth_.peak * bandwidth_.scale);
 
   if (sg_weight_S_parameter > 0) {
@@ -417,7 +420,7 @@ void NetworkCm02Link::setBandwidth(double value)
       NetworkCm02Action *action = static_cast<NetworkCm02Action*>(lmm_variable_id(var));
       action->weight_ += delta;
       if (not action->isSuspended())
       NetworkCm02Action *action = static_cast<NetworkCm02Action*>(lmm_variable_id(var));
       action->weight_ += delta;
       if (not action->isSuspended())
-        lmm_update_variable_weight(model()->getMaxminSystem(), action->getVariable(), action->weight_);
+        model()->getMaxminSystem()->update_variable_weight(action->getVariable(), action->weight_);
     }
   }
 }
     }
   }
 }
@@ -437,11 +440,11 @@ void NetworkCm02Link::setLatency(double value)
     action->latCurrent_ += delta;
     action->weight_ += delta;
     if (action->rate_ < 0)
     action->latCurrent_ += delta;
     action->weight_ += delta;
     if (action->rate_ < 0)
-      lmm_update_variable_bound(model()->getMaxminSystem(), action->getVariable(),
-                                sg_tcp_gamma / (2.0 * action->latCurrent_));
+      model()->getMaxminSystem()->update_variable_bound(action->getVariable(),
+                                                        sg_tcp_gamma / (2.0 * action->latCurrent_));
     else {
     else {
-      lmm_update_variable_bound(model()->getMaxminSystem(), action->getVariable(),
-                                std::min(action->rate_, sg_tcp_gamma / (2.0 * action->latCurrent_)));
+      model()->getMaxminSystem()->update_variable_bound(
+          action->getVariable(), std::min(action->rate_, sg_tcp_gamma / (2.0 * action->latCurrent_)));
 
       if (action->rate_ < sg_tcp_gamma / (2.0 * action->latCurrent_)) {
         XBT_INFO("Flow is limited BYBANDWIDTH");
 
       if (action->rate_ < sg_tcp_gamma / (2.0 * action->latCurrent_)) {
         XBT_INFO("Flow is limited BYBANDWIDTH");
@@ -450,7 +453,7 @@ void NetworkCm02Link::setLatency(double value)
       }
     }
     if (not action->isSuspended())
       }
     }
     if (not action->isSuspended())
-      lmm_update_variable_weight(model()->getMaxminSystem(), action->getVariable(), action->weight_);
+      model()->getMaxminSystem()->update_variable_weight(action->getVariable(), action->weight_);
   }
 }
 
   }
 }
 
index 8a051ec..6b98ff8 100644 (file)
@@ -174,7 +174,7 @@ void NetworkIBModel::computeIBfactors(IBNode* root)
     if (not double_equals(penalized_bw, rate_before_update, sg_surf_precision)) {
       XBT_DEBUG("%d->%d action %p penalty updated : bw now %f, before %f , initial rate %f", root->id,
                 (*it)->destination->id, (*it)->action, penalized_bw, (*it)->action->getBound(), (*it)->init_rate);
     if (not double_equals(penalized_bw, rate_before_update, sg_surf_precision)) {
       XBT_DEBUG("%d->%d action %p penalty updated : bw now %f, before %f , initial rate %f", root->id,
                 (*it)->destination->id, (*it)->action, penalized_bw, (*it)->action->getBound(), (*it)->init_rate);
-      lmm_update_variable_bound(maxminSystem_, (*it)->action->getVariable(), penalized_bw);
+      maxminSystem_->update_variable_bound((*it)->action->getVariable(), penalized_bw);
     } else {
       XBT_DEBUG("%d->%d action %p penalty not updated : bw %f, initial rate %f", root->id, (*it)->destination->id,
                 (*it)->action, penalized_bw, (*it)->init_rate);
     } else {
       XBT_DEBUG("%d->%d action %p penalty not updated : bw %f, initial rate %f", root->id, (*it)->destination->id,
                 (*it)->action, penalized_bw, (*it)->init_rate);
index f88a72d..7cbef8e 100644 (file)
@@ -6,6 +6,7 @@
 
 #include <algorithm>
 
 
 #include <algorithm>
 
+#include "maxmin_private.hpp"
 #include "network_interface.hpp"
 #include "simgrid/sg_config.h"
 
 #include "network_interface.hpp"
 #include "simgrid/sg_config.h"
 
@@ -69,7 +70,7 @@ namespace simgrid {
 
     NetworkModel::~NetworkModel()
     {
 
     NetworkModel::~NetworkModel()
     {
-      lmm_system_free(maxminSystem_);
+      delete maxminSystem_;
       delete modifiedSet_;
     }
 
       delete modifiedSet_;
     }
 
@@ -138,7 +139,7 @@ namespace simgrid {
 
     bool LinkImpl::isUsed()
     {
 
     bool LinkImpl::isUsed()
     {
-      return lmm_constraint_used(model()->getMaxminSystem(), constraint());
+      return model()->getMaxminSystem()->constraint_used(constraint());
     }
 
     double LinkImpl::latency()
     }
 
     double LinkImpl::latency()
index 7a3c22b..17b1366 100644 (file)
@@ -34,7 +34,7 @@ namespace simgrid {
 namespace surf {
 
 HostL07Model::HostL07Model() : HostModel() {
 namespace surf {
 
 HostL07Model::HostL07Model() : HostModel() {
-  maxminSystem_ = lmm_system_new(true /* lazy */);
+  maxminSystem_            = new s_lmm_system_t(true /* lazy */);
   maxminSystem_->solve_fun = &bottleneck_solve;
   surf_network_model = new NetworkL07Model(this,maxminSystem_);
   surf_cpu_model_pm = new CpuL07Model(this,maxminSystem_);
   maxminSystem_->solve_fun = &bottleneck_solve;
   surf_network_model = new NetworkL07Model(this,maxminSystem_);
   surf_cpu_model_pm = new CpuL07Model(this,maxminSystem_);
@@ -42,7 +42,7 @@ HostL07Model::HostL07Model() : HostModel() {
 
 HostL07Model::~HostL07Model()
 {
 
 HostL07Model::~HostL07Model()
 {
-  lmm_system_free(maxminSystem_);
+  delete maxminSystem_;
   maxminSystem_ = nullptr;
   delete surf_network_model;
   delete surf_cpu_model_pm;
   maxminSystem_ = nullptr;
   delete surf_network_model;
   delete surf_cpu_model_pm;
@@ -101,7 +101,7 @@ void HostL07Model::updateActionsState(double /*now*/, double delta)
       }
       if ((action.latency_ <= 0.0) && (action.isSuspended() == 0)) {
         action.updateBound();
       }
       if ((action.latency_ <= 0.0) && (action.isSuspended() == 0)) {
         action.updateBound();
-        lmm_update_variable_weight(maxminSystem_, action.getVariable(), 1.0);
+        maxminSystem_->update_variable_weight(action.getVariable(), 1.0);
       }
     }
     XBT_DEBUG("Action (%p) : remains (%g) updated by %g.", &action, action.getRemains(),
       }
     }
     XBT_DEBUG("Action (%p) : remains (%g) updated by %g.", &action, action.getRemains(),
@@ -189,13 +189,13 @@ L07Action::L07Action(Model *model, int host_nb, sg_host_t *host_list,
   XBT_DEBUG("Creating a parallel task (%p) with %d hosts and %d unique links.", this, host_nb, nb_link);
   latency_ = latency;
 
   XBT_DEBUG("Creating a parallel task (%p) with %d hosts and %d unique links.", this, host_nb, nb_link);
   latency_ = latency;
 
-  setVariable(lmm_variable_new(model->getMaxminSystem(), this, 1.0, (rate > 0 ? rate : -1.0), host_nb + nb_link));
+  setVariable(model->getMaxminSystem()->variable_new(this, 1.0, (rate > 0 ? rate : -1.0), host_nb + nb_link));
 
   if (latency_ > 0)
 
   if (latency_ > 0)
-    lmm_update_variable_weight(model->getMaxminSystem(), getVariable(), 0.0);
+    model->getMaxminSystem()->update_variable_weight(getVariable(), 0.0);
 
   for (int i = 0; i < host_nb; i++)
 
   for (int i = 0; i < host_nb; i++)
-    lmm_expand(model->getMaxminSystem(), host_list[i]->pimpl_cpu->constraint(), getVariable(), flops_amount[i]);
+    model->getMaxminSystem()->expand(host_list[i]->pimpl_cpu->constraint(), getVariable(), flops_amount[i]);
 
   if(bytes_amount != nullptr) {
     for (int i = 0; i < host_nb; i++) {
 
   if(bytes_amount != nullptr) {
     for (int i = 0; i < host_nb; i++) {
@@ -205,8 +205,8 @@ L07Action::L07Action(Model *model, int host_nb, sg_host_t *host_list,
           hostList_->at(i)->routeTo(hostList_->at(j), route, nullptr);
 
           for (auto const& link : route)
           hostList_->at(i)->routeTo(hostList_->at(j), route, nullptr);
 
           for (auto const& link : route)
-            lmm_expand_add(model->getMaxminSystem(), link->constraint(), this->getVariable(),
-                           bytes_amount[i * host_nb + j]);
+            model->getMaxminSystem()->expand_add(link->constraint(), this->getVariable(),
+                                                 bytes_amount[i * host_nb + j]);
         }
       }
     }
         }
       }
     }
@@ -248,8 +248,7 @@ LinkImpl* NetworkL07Model::createLink(const std::string& name, double bandwidth,
  ************/
 
 CpuL07::CpuL07(CpuL07Model* model, simgrid::s4u::Host* host, std::vector<double>* speedPerPstate, int core)
  ************/
 
 CpuL07::CpuL07(CpuL07Model* model, simgrid::s4u::Host* host, std::vector<double>* speedPerPstate, int core)
-    : Cpu(model, host, lmm_constraint_new(model->getMaxminSystem(), this, speedPerPstate->front()), speedPerPstate,
-          core)
+    : Cpu(model, host, model->getMaxminSystem()->constraint_new(this, speedPerPstate->front()), speedPerPstate, core)
 {
 }
 
 {
 }
 
@@ -257,7 +256,7 @@ CpuL07::~CpuL07()=default;
 
 LinkL07::LinkL07(NetworkL07Model* model, const std::string& name, double bandwidth, double latency,
                  e_surf_link_sharing_policy_t policy)
 
 LinkL07::LinkL07(NetworkL07Model* model, const std::string& name, double bandwidth, double latency,
                  e_surf_link_sharing_policy_t policy)
-    : LinkImpl(model, name, lmm_constraint_new(model->getMaxminSystem(), this, bandwidth))
+    : LinkImpl(model, name, model->getMaxminSystem()->constraint_new(this, bandwidth))
 {
   bandwidth_.peak = bandwidth;
   latency_.peak   = latency;
 {
   bandwidth_.peak = bandwidth;
   latency_.peak   = latency;
@@ -284,13 +283,13 @@ Action *CpuL07::sleep(double duration)
   L07Action *action = static_cast<L07Action*>(execution_start(1.0));
   action->setMaxDuration(duration);
   action->suspended_ = 2;
   L07Action *action = static_cast<L07Action*>(execution_start(1.0));
   action->setMaxDuration(duration);
   action->suspended_ = 2;
-  lmm_update_variable_weight(model()->getMaxminSystem(), action->getVariable(), 0.0);
+  model()->getMaxminSystem()->update_variable_weight(action->getVariable(), 0.0);
 
   return action;
 }
 
 bool CpuL07::isUsed(){
 
   return action;
 }
 
 bool CpuL07::isUsed(){
-  return lmm_constraint_used(model()->getMaxminSystem(), constraint());
+  return model()->getMaxminSystem()->constraint_used(constraint());
 }
 
 /** @brief take into account changes of speed (either load or max) */
 }
 
 /** @brief take into account changes of speed (either load or max) */
@@ -298,11 +297,11 @@ void CpuL07::onSpeedChange() {
   lmm_variable_t var = nullptr;
   lmm_element_t elem = nullptr;
 
   lmm_variable_t var = nullptr;
   lmm_element_t elem = nullptr;
 
-  lmm_update_constraint_bound(model()->getMaxminSystem(), constraint(), speed_.peak * speed_.scale);
+  model()->getMaxminSystem()->update_constraint_bound(constraint(), speed_.peak * speed_.scale);
   while ((var = lmm_get_var_from_cnst(model()->getMaxminSystem(), constraint(), &elem))) {
     Action* action = static_cast<Action*>(lmm_variable_id(var));
 
   while ((var = lmm_get_var_from_cnst(model()->getMaxminSystem(), constraint(), &elem))) {
     Action* action = static_cast<Action*>(lmm_variable_id(var));
 
-    lmm_update_variable_bound(model()->getMaxminSystem(), action->getVariable(), speed_.scale * speed_.peak);
+    model()->getMaxminSystem()->update_variable_bound(action->getVariable(), speed_.scale * speed_.peak);
   }
 
   Cpu::onSpeedChange();
   }
 
   Cpu::onSpeedChange();
@@ -310,7 +309,7 @@ void CpuL07::onSpeedChange() {
 
 
 bool LinkL07::isUsed(){
 
 
 bool LinkL07::isUsed(){
-  return lmm_constraint_used(model()->getMaxminSystem(), constraint());
+  return model()->getMaxminSystem()->constraint_used(constraint());
 }
 
 void CpuL07::apply_event(tmgr_trace_event_t triggered, double value)
 }
 
 void CpuL07::apply_event(tmgr_trace_event_t triggered, double value)
@@ -359,7 +358,7 @@ void LinkL07::apply_event(tmgr_trace_event_t triggered, double value)
 void LinkL07::setBandwidth(double value)
 {
   bandwidth_.peak = value;
 void LinkL07::setBandwidth(double value)
 {
   bandwidth_.peak = value;
-  lmm_update_constraint_bound(model()->getMaxminSystem(), constraint(), bandwidth_.peak * bandwidth_.scale);
+  model()->getMaxminSystem()->update_constraint_bound(constraint(), bandwidth_.peak * bandwidth_.scale);
 }
 
 void LinkL07::setLatency(double value)
 }
 
 void LinkL07::setLatency(double value)
@@ -410,9 +409,9 @@ void L07Action::updateBound()
   XBT_DEBUG("action (%p) : lat_bound = %g", this, lat_bound);
   if ((latency_ <= 0.0) && (suspended_ == 0)) {
     if (rate_ < 0)
   XBT_DEBUG("action (%p) : lat_bound = %g", this, lat_bound);
   if ((latency_ <= 0.0) && (suspended_ == 0)) {
     if (rate_ < 0)
-      lmm_update_variable_bound(getModel()->getMaxminSystem(), getVariable(), lat_bound);
+      getModel()->getMaxminSystem()->update_variable_bound(getVariable(), lat_bound);
     else
     else
-      lmm_update_variable_bound(getModel()->getMaxminSystem(), getVariable(), std::min(rate_, lat_bound));
+      getModel()->getMaxminSystem()->update_variable_bound(getVariable(), std::min(rate_, lat_bound));
   }
 }
 
   }
 }
 
@@ -423,7 +422,7 @@ int L07Action::unref()
     if (action_hook.is_linked())
       stateSet_->erase(stateSet_->iterator_to(*this));
     if (getVariable())
     if (action_hook.is_linked())
       stateSet_->erase(stateSet_->iterator_to(*this));
     if (getVariable())
-      lmm_variable_free(getModel()->getMaxminSystem(), getVariable());
+      getModel()->getMaxminSystem()->variable_free(getVariable());
     delete this;
     return 1;
   }
     delete this;
     return 1;
   }
index 71ee41d..9bad4ae 100644 (file)
@@ -4,6 +4,7 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "storage_n11.hpp"
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "storage_n11.hpp"
+#include "maxmin_private.hpp"
 #include "simgrid/s4u/Engine.hpp"
 #include "src/kernel/routing/NetPoint.hpp"
 #include <cmath> /*ceil*/
 #include "simgrid/s4u/Engine.hpp"
 #include "src/kernel/routing/NetPoint.hpp"
 #include <cmath> /*ceil*/
@@ -118,18 +119,18 @@ StorageAction* StorageN11::write(sg_size_t size)
 
 StorageN11Action::StorageN11Action(Model* model, double cost, bool failed, StorageImpl* storage,
                                    e_surf_action_storage_type_t type)
 
 StorageN11Action::StorageN11Action(Model* model, double cost, bool failed, StorageImpl* storage,
                                    e_surf_action_storage_type_t type)
-    : StorageAction(model, cost, failed, lmm_variable_new(model->getMaxminSystem(), this, 1.0, -1.0, 3), storage, type)
+    : StorageAction(model, cost, failed, model->getMaxminSystem()->variable_new(this, 1.0, -1.0, 3), storage, type)
 {
   XBT_IN("(%s,%g", storage->getCname(), cost);
 
   // Must be less than the max bandwidth for all actions
 {
   XBT_IN("(%s,%g", storage->getCname(), cost);
 
   // Must be less than the max bandwidth for all actions
-  lmm_expand(model->getMaxminSystem(), storage->constraint(), getVariable(), 1.0);
+  model->getMaxminSystem()->expand(storage->constraint(), getVariable(), 1.0);
   switch(type) {
   case READ:
   switch(type) {
   case READ:
-    lmm_expand(model->getMaxminSystem(), storage->constraintRead_, getVariable(), 1.0);
+    model->getMaxminSystem()->expand(storage->constraintRead_, getVariable(), 1.0);
     break;
   case WRITE:
     break;
   case WRITE:
-    lmm_expand(model->getMaxminSystem(), storage->constraintWrite_, getVariable(), 1.0);
+    model->getMaxminSystem()->expand(storage->constraintWrite_, getVariable(), 1.0);
     break;
   default:
     THROW_UNIMPLEMENTED;
     break;
   default:
     THROW_UNIMPLEMENTED;
@@ -144,7 +145,7 @@ int StorageN11Action::unref()
     if (action_hook.is_linked())
       stateSet_->erase(stateSet_->iterator_to(*this));
     if (getVariable())
     if (action_hook.is_linked())
       stateSet_->erase(stateSet_->iterator_to(*this));
     if (getVariable())
-      lmm_variable_free(getModel()->getMaxminSystem(), getVariable());
+      getModel()->getMaxminSystem()->variable_free(getVariable());
     xbt_free(getCategory());
     delete this;
     return 1;
     xbt_free(getCategory());
     delete this;
     return 1;
@@ -161,7 +162,7 @@ void StorageN11Action::suspend()
 {
   XBT_IN("(%p)", this);
   if (suspended_ != 2) {
 {
   XBT_IN("(%p)", this);
   if (suspended_ != 2) {
-    lmm_update_variable_weight(getModel()->getMaxminSystem(), getVariable(), 0.0);
+    getModel()->getMaxminSystem()->update_variable_weight(getVariable(), 0.0);
     suspended_ = 1;
   }
   XBT_OUT();
     suspended_ = 1;
   }
   XBT_OUT();
index 67c6b6b..4381f7c 100644 (file)
@@ -653,7 +653,7 @@ void Action::setBound(double bound)
 {
   XBT_IN("(%p,%g)", this, bound);
   if (variable_)
 {
   XBT_IN("(%p,%g)", this, bound);
   if (variable_)
-    lmm_update_variable_bound(getModel()->getMaxminSystem(), variable_, bound);
+    getModel()->getMaxminSystem()->update_variable_bound(variable_, bound);
 
   if (getModel()->getUpdateMechanism() == UM_LAZY && getLastUpdate() != surf_get_clock())
     heapRemove(getModel()->getActionHeap());
 
   if (getModel()->getUpdateMechanism() == UM_LAZY && getLastUpdate() != surf_get_clock())
     heapRemove(getModel()->getActionHeap());
@@ -680,7 +680,7 @@ void Action::setSharingWeight(double weight)
 {
   XBT_IN("(%p,%g)", this, weight);
   sharingWeight_ = weight;
 {
   XBT_IN("(%p,%g)", this, weight);
   sharingWeight_ = weight;
-  lmm_update_variable_weight(getModel()->getMaxminSystem(), getVariable(), weight);
+  getModel()->getMaxminSystem()->update_variable_weight(getVariable(), weight);
 
   if (getModel()->getUpdateMechanism() == UM_LAZY)
     heapRemove(getModel()->getActionHeap());
 
   if (getModel()->getUpdateMechanism() == UM_LAZY)
     heapRemove(getModel()->getActionHeap());
@@ -702,7 +702,7 @@ int Action::unref(){
     if (action_hook.is_linked())
       stateSet_->erase(stateSet_->iterator_to(*this));
     if (getVariable())
     if (action_hook.is_linked())
       stateSet_->erase(stateSet_->iterator_to(*this));
     if (getVariable())
-      lmm_variable_free(getModel()->getMaxminSystem(), getVariable());
+      getModel()->getMaxminSystem()->variable_free(getVariable());
     if (getModel()->getUpdateMechanism() == UM_LAZY) {
       /* remove from heap */
       heapRemove(getModel()->getActionHeap());
     if (getModel()->getUpdateMechanism() == UM_LAZY) {
       /* remove from heap */
       heapRemove(getModel()->getActionHeap());
@@ -719,7 +719,7 @@ void Action::suspend()
 {
   XBT_IN("(%p)", this);
   if (suspended_ != 2) {
 {
   XBT_IN("(%p)", this);
   if (suspended_ != 2) {
-    lmm_update_variable_weight(getModel()->getMaxminSystem(), getVariable(), 0.0);
+    getModel()->getMaxminSystem()->update_variable_weight(getVariable(), 0.0);
     if (getModel()->getUpdateMechanism() == UM_LAZY){
       heapRemove(getModel()->getActionHeap());
       if (getModel()->getUpdateMechanism() == UM_LAZY && stateSet_ == getModel()->getRunningActionSet() &&
     if (getModel()->getUpdateMechanism() == UM_LAZY){
       heapRemove(getModel()->getActionHeap());
       if (getModel()->getUpdateMechanism() == UM_LAZY && stateSet_ == getModel()->getRunningActionSet() &&
@@ -737,7 +737,7 @@ void Action::resume()
 {
   XBT_IN("(%p)", this);
   if (suspended_ != 2) {
 {
   XBT_IN("(%p)", this);
   if (suspended_ != 2) {
-    lmm_update_variable_weight(getModel()->getMaxminSystem(), getVariable(), getPriority());
+    getModel()->getMaxminSystem()->update_variable_weight(getVariable(), getPriority());
     suspended_ = 0;
     if (getModel()->getUpdateMechanism() == UM_LAZY)
       heapRemove(getModel()->getActionHeap());
     suspended_ = 0;
     if (getModel()->getUpdateMechanism() == UM_LAZY)
       heapRemove(getModel()->getActionHeap());
index 71c2fd4..dc6ce16 100644 (file)
@@ -7,6 +7,7 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "simgrid/msg.h"
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "simgrid/msg.h"
+#include "src/surf/maxmin_private.hpp"
 #include "src/surf/surf_interface.hpp"
 #include "surf/maxmin.hpp"
 #include "xbt/log.h"
 #include "src/surf/surf_interface.hpp"
 #include "surf/maxmin.hpp"
 #include "xbt/log.h"
@@ -94,28 +95,28 @@ static void test1(method_t method)
   else if (method == LAGRANGE_RENO)
     lmm_set_default_protocol_function(func_reno_f, func_reno_fpi, func_reno_fpi);
 
   else if (method == LAGRANGE_RENO)
     lmm_set_default_protocol_function(func_reno_f, func_reno_fpi, func_reno_fpi);
 
-  lmm_system_t Sys = lmm_system_new(1);
-  lmm_constraint_t L1 = lmm_constraint_new(Sys, nullptr, a);
-  lmm_constraint_t L2 = lmm_constraint_new(Sys, nullptr, b);
-  lmm_constraint_t L3 = lmm_constraint_new(Sys, nullptr, a);
+  lmm_system_t Sys    = new s_lmm_system_t(true);
+  lmm_constraint_t L1 = Sys->constraint_new(nullptr, a);
+  lmm_constraint_t L2 = Sys->constraint_new(nullptr, b);
+  lmm_constraint_t L3 = Sys->constraint_new(nullptr, a);
 
 
-  lmm_variable_t R_1_2_3 = lmm_variable_new(Sys, nullptr, 1.0, -1.0, 3);
-  lmm_variable_t R_1 = lmm_variable_new(Sys, nullptr, 1.0, -1.0, 1);
-  lmm_variable_t R_2 = lmm_variable_new(Sys, nullptr, 1.0, -1.0, 1);
-  lmm_variable_t R_3 = lmm_variable_new(Sys, nullptr, 1.0, -1.0, 1);
+  lmm_variable_t R_1_2_3 = Sys->variable_new(nullptr, 1.0, -1.0, 3);
+  lmm_variable_t R_1     = Sys->variable_new(nullptr, 1.0, -1.0, 1);
+  lmm_variable_t R_2     = Sys->variable_new(nullptr, 1.0, -1.0, 1);
+  lmm_variable_t R_3     = Sys->variable_new(nullptr, 1.0, -1.0, 1);
 
 
-  lmm_update_variable_weight(Sys, R_1_2_3, 1.0);
-  lmm_update_variable_weight(Sys, R_1, 1.0);
-  lmm_update_variable_weight(Sys, R_2, 1.0);
-  lmm_update_variable_weight(Sys, R_3, 1.0);
+  Sys->update_variable_weight(R_1_2_3, 1.0);
+  Sys->update_variable_weight(R_1, 1.0);
+  Sys->update_variable_weight(R_2, 1.0);
+  Sys->update_variable_weight(R_3, 1.0);
 
 
-  lmm_expand(Sys, L1, R_1_2_3, 1.0);
-  lmm_expand(Sys, L2, R_1_2_3, 1.0);
-  lmm_expand(Sys, L3, R_1_2_3, 1.0);
+  Sys->expand(L1, R_1_2_3, 1.0);
+  Sys->expand(L2, R_1_2_3, 1.0);
+  Sys->expand(L3, R_1_2_3, 1.0);
 
 
-  lmm_expand(Sys, L1, R_1, 1.0);
-  lmm_expand(Sys, L2, R_2, 1.0);
-  lmm_expand(Sys, L3, R_3, 1.0);
+  Sys->expand(L1, R_1, 1.0);
+  Sys->expand(L2, R_2, 1.0);
+  Sys->expand(L3, R_3, 1.0);
 
   if (method == MAXMIN) {
     lmm_solve(Sys);
 
   if (method == MAXMIN) {
     lmm_solve(Sys);
@@ -168,11 +169,11 @@ static void test1(method_t method)
   PRINT_VAR(R_2);
   PRINT_VAR(R_3);
 
   PRINT_VAR(R_2);
   PRINT_VAR(R_3);
 
-  lmm_variable_free(Sys, R_1_2_3);
-  lmm_variable_free(Sys, R_1);
-  lmm_variable_free(Sys, R_2);
-  lmm_variable_free(Sys, R_3);
-  lmm_system_free(Sys);
+  Sys->variable_free(R_1_2_3);
+  Sys->variable_free(R_1);
+  Sys->variable_free(R_2);
+  Sys->variable_free(R_3);
+  delete Sys;
 }
 
 static void test2(method_t method)
 }
 
 static void test2(method_t method)
@@ -182,18 +183,18 @@ static void test2(method_t method)
   if (method == LAGRANGE_RENO)
     lmm_set_default_protocol_function(func_reno_f, func_reno_fp, func_reno_fpi);
 
   if (method == LAGRANGE_RENO)
     lmm_set_default_protocol_function(func_reno_f, func_reno_fp, func_reno_fpi);
 
-  lmm_system_t Sys = lmm_system_new(1);
-  lmm_constraint_t CPU1 = lmm_constraint_new(Sys, nullptr, 200.0);
-  lmm_constraint_t CPU2 = lmm_constraint_new(Sys, nullptr, 100.0);
+  lmm_system_t Sys      = new s_lmm_system_t(true);
+  lmm_constraint_t CPU1 = Sys->constraint_new(nullptr, 200.0);
+  lmm_constraint_t CPU2 = Sys->constraint_new(nullptr, 100.0);
 
 
-  lmm_variable_t T1 = lmm_variable_new(Sys, nullptr, 1.0, -1.0, 1);
-  lmm_variable_t T2 = lmm_variable_new(Sys, nullptr, 1.0, -1.0, 1);
+  lmm_variable_t T1 = Sys->variable_new(nullptr, 1.0, -1.0, 1);
+  lmm_variable_t T2 = Sys->variable_new(nullptr, 1.0, -1.0, 1);
 
 
-  lmm_update_variable_weight(Sys, T1, 1.0);
-  lmm_update_variable_weight(Sys, T2, 1.0);
+  Sys->update_variable_weight(T1, 1.0);
+  Sys->update_variable_weight(T2, 1.0);
 
 
-  lmm_expand(Sys, CPU1, T1, 1.0);
-  lmm_expand(Sys, CPU2, T2, 1.0);
+  Sys->expand(CPU1, T1, 1.0);
+  Sys->expand(CPU2, T2, 1.0);
 
   if (method == MAXMIN) {
     lmm_solve(Sys);
 
   if (method == MAXMIN) {
     lmm_solve(Sys);
@@ -206,9 +207,9 @@ static void test2(method_t method)
   PRINT_VAR(T1);
   PRINT_VAR(T2);
 
   PRINT_VAR(T1);
   PRINT_VAR(T2);
 
-  lmm_variable_free(Sys, T1);
-  lmm_variable_free(Sys, T2);
-  lmm_system_free(Sys);
+  Sys->variable_free(T1);
+  Sys->variable_free(T2);
+  delete Sys;
 }
 
 static void test3(method_t method)
 }
 
 static void test3(method_t method)
@@ -253,25 +254,25 @@ static void test3(method_t method)
   if (method == LAGRANGE_RENO)
     lmm_set_default_protocol_function(func_reno_f, func_reno_fp, func_reno_fpi);
 
   if (method == LAGRANGE_RENO)
     lmm_set_default_protocol_function(func_reno_f, func_reno_fp, func_reno_fpi);
 
-  lmm_system_t Sys = lmm_system_new(1);
+  lmm_system_t Sys = new s_lmm_system_t(true);
 
   /* Creates the constraints */
   lmm_constraint_t* tmp_cnst = new lmm_constraint_t[15];
   for (int i = 0; i < 15; i++)
 
   /* Creates the constraints */
   lmm_constraint_t* tmp_cnst = new lmm_constraint_t[15];
   for (int i = 0; i < 15; i++)
-    tmp_cnst[i] = lmm_constraint_new(Sys, nullptr, B[i]);
+    tmp_cnst[i] = Sys->constraint_new(nullptr, B[i]);
 
   /* Creates the variables */
   lmm_variable_t* tmp_var = new lmm_variable_t[16];
   for (int j = 0; j < 16; j++) {
 
   /* Creates the variables */
   lmm_variable_t* tmp_var = new lmm_variable_t[16];
   for (int j = 0; j < 16; j++) {
-    tmp_var[j] = lmm_variable_new(Sys, nullptr, 1.0, -1.0, 15);
-    lmm_update_variable_weight(Sys, tmp_var[j], 1.0);
+    tmp_var[j] = Sys->variable_new(nullptr, 1.0, -1.0, 15);
+    Sys->update_variable_weight(tmp_var[j], 1.0);
   }
 
   /* Link constraints and variables */
   for (int i = 0; i < 15; i++)
     for (int j = 0; j < 16; j++)
       if (A[i][j])
   }
 
   /* Link constraints and variables */
   for (int i = 0; i < 15; i++)
     for (int j = 0; j < 16; j++)
       if (A[i][j])
-        lmm_expand(Sys, tmp_cnst[i], tmp_var[j], 1.0);
+        Sys->expand(tmp_cnst[i], tmp_var[j], 1.0);
 
   if (method == MAXMIN) {
     lmm_solve(Sys);
 
   if (method == MAXMIN) {
     lmm_solve(Sys);
@@ -287,10 +288,10 @@ static void test3(method_t method)
     PRINT_VAR(tmp_var[j]);
 
   for (int j = 0; j < 16; j++)
     PRINT_VAR(tmp_var[j]);
 
   for (int j = 0; j < 16; j++)
-    lmm_variable_free(Sys, tmp_var[j]);
+    Sys->variable_free(tmp_var[j]);
   delete[] tmp_var;
   delete[] tmp_cnst;
   delete[] tmp_var;
   delete[] tmp_cnst;
-  lmm_system_free(Sys);
+  delete Sys;
   for (int i = 0; i < links + 5; i++)
     delete[] A[i];
   delete[] A;
   for (int i = 0; i < links + 5; i++)
     delete[] A[i];
   delete[] A;
index d3408b1..5cd623b 100644 (file)
@@ -8,6 +8,7 @@
 
 #include "surf/maxmin.hpp"
 #include "simgrid/msg.h"
 
 #include "surf/maxmin.hpp"
 #include "simgrid/msg.h"
+#include "src/surf/maxmin_private.hpp"
 #include "xbt/module.h"
 #include "xbt/sysdep.h" /* time manipulation for benchmarking */
 #include "xbt/xbt_os_time.h"
 #include "xbt/module.h"
 #include "xbt/sysdep.h" /* time manipulation for benchmarking */
 #include "xbt/xbt_os_time.h"
@@ -43,10 +44,10 @@ static void test(int nb_cnst, int nb_var, int nb_elem, unsigned int pw_base_limi
   lmm_variable_t var[nb_var];
   int used[nb_cnst];
 
   lmm_variable_t var[nb_var];
   int used[nb_cnst];
 
-  lmm_system_t Sys = lmm_system_new(1);
+  lmm_system_t Sys = new s_lmm_system_t(true);
 
   for (int i = 0; i < nb_cnst; i++) {
 
   for (int i = 0; i < nb_cnst; i++) {
-    cnst[i] = lmm_constraint_new(Sys, NULL, float_random(10.0));
+    cnst[i] = Sys->constraint_new(NULL, float_random(10.0));
     int l;
     if(rate_no_limit>float_random(1.0))
       //Look at what happens when there is no concurrency limit
     int l;
     if(rate_no_limit>float_random(1.0))
       //Look at what happens when there is no concurrency limit
@@ -59,7 +60,7 @@ static void test(int nb_cnst, int nb_var, int nb_elem, unsigned int pw_base_limi
   }
 
   for (int i = 0; i < nb_var; i++) {
   }
 
   for (int i = 0; i < nb_var; i++) {
-    var[i] = lmm_variable_new(Sys, NULL, 1.0, -1.0, nb_elem);
+    var[i] = Sys->variable_new(NULL, 1.0, -1.0, nb_elem);
     //Have a few variables with a concurrency share of two (e.g. cross-traffic in some cases)
     int concurrency_share = 1 + int_random(max_share);
     lmm_variable_concurrency_share_set(var[i],concurrency_share);
     //Have a few variables with a concurrency share of two (e.g. cross-traffic in some cases)
     int concurrency_share = 1 + int_random(max_share);
     lmm_variable_concurrency_share_set(var[i],concurrency_share);
@@ -72,8 +73,8 @@ static void test(int nb_cnst, int nb_var, int nb_elem, unsigned int pw_base_limi
         j--;
         continue;
       }
         j--;
         continue;
       }
-      lmm_expand(Sys, cnst[k], var[i], float_random(1.5));
-      lmm_expand_add(Sys, cnst[k], var[i], float_random(1.5));
+      Sys->expand(cnst[k], var[i], float_random(1.5));
+      Sys->expand_add(cnst[k], var[i], float_random(1.5));
       used[k]++;
     }
   }
       used[k]++;
     }
   }
@@ -100,12 +101,12 @@ static void test(int nb_cnst, int nb_var, int nb_elem, unsigned int pw_base_limi
     }
     fprintf(stderr,"\nTotal maximum concurrency is %i\n",l);
 
     }
     fprintf(stderr,"\nTotal maximum concurrency is %i\n",l);
 
-    lmm_print(Sys);
+    Sys->print();
   }
 
   for (int i = 0; i < nb_var; i++)
   }
 
   for (int i = 0; i < nb_var; i++)
-    lmm_variable_free(Sys, var[i]);
-  lmm_system_free(Sys);
+    Sys->variable_free(var[i]);
+  delete Sys;
 }
 
 unsigned int TestClasses [][4]=
 }
 
 unsigned int TestClasses [][4]=