#include "xbt/sysdep.h"
#include <algorithm>
-#include <cstdlib>
-#ifndef MATH
#include <cmath>
-#endif
+#include <cstdlib>
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_lagrange, surf, "Logging specific to SURF (lagrange)");
XBT_LOG_NEW_SUBCATEGORY(surf_lagrange_dichotomy, surf_lagrange, "Logging specific to SURF (lagrange dichotomy)");
-#define SHOW_EXPR(expr) XBT_CDEBUG(surf_lagrange, #expr " = %g", expr);
-#define VEGAS_SCALING 1000.0
-#define RENO_SCALING 1.0
-#define RENO2_SCALING 1.0
+static constexpr double VEGAS_SCALING = 1000.0;
+static constexpr double RENO_SCALING = 1.0;
+static constexpr double RENO2_SCALING = 1.0;
namespace simgrid {
namespace kernel {
double (*func_fp_def)(const Variable&, double);
double (*func_fpi_def)(const Variable&, double);
+System* make_new_lagrange_system(bool selective_update)
+{
+ return new Lagrange(selective_update);
+}
+
/*
* Local prototypes to implement the Lagrangian optimization with optimal step, also called dichotomy.
*/
-// solves the proportional fairness using a Lagrangian optimization with dichotomy step
-void lagrange_solve(kernel::lmm::System* sys);
// computes the value of the dichotomy using a initial values, init, with a specific variable or constraint
static double dichotomy(double init, double diff(double, const Constraint&), const Constraint& cnst, double min_error);
// computes the value of the differential of constraint cnst applied to lambda
return obj;
}
-void lagrange_solve(kernel::lmm::System* sys)
+// solves the proportional fairness using a Lagrangian optimization with dichotomy step
+void Lagrange::lagrange_solve()
{
/* Lagrange Variables. */
int max_iterations = 100;
XBT_DEBUG("#### Minimum error tolerated (dichotomy) : %e", dichotomy_min_error);
if (XBT_LOG_ISENABLED(surf_lagrange, xbt_log_priority_debug)) {
- sys->print();
+ print();
}
- if (not sys->modified)
+ if (not modified)
return;
/* Initialize lambda. */
- auto& cnst_list = sys->active_constraint_set;
+ auto& cnst_list = active_constraint_set;
for (Constraint& cnst : cnst_list) {
cnst.lambda = 1.0;
cnst.new_lambda = 2.0;
/*
* Initialize the var_list variable with only the active variables. Initialize mu.
*/
- auto& var_list = sys->variable_set;
+ auto& var_list = variable_set;
for (Variable& var : var_list) {
if (not var.sharing_weight)
var.value = 0.0;
}
if (XBT_LOG_ISENABLED(surf_lagrange, xbt_log_priority_debug)) {
- sys->print();
+ print();
}
}