Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update copyright notices
[simgrid.git] / src / include / surf / maxmin.h
index ba925ee..2239f4a 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2004-2014. The SimGrid Team.
+/* Copyright (c) 2004-2015. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -9,8 +9,10 @@
 
 #include "portable.h"
 #include "xbt/misc.h"
+#include "xbt/asserts.h"
 #include "surf/datatypes.h"
 #include <math.h>
+//#include <float.h>
 
 
 /** @addtogroup SURF_lmm 
 
 extern double sg_maxmin_precision;
 extern double sg_surf_precision;
-
 static XBT_INLINE void double_update(double *variable, double value, double precision)
 {
+  //printf("Updating %g -= %g +- %g\n",*variable,value,precision);
+  //xbt_assert(value==0  || value>precision);
+  //Check that precision is higher than the machine-dependent size of the mantissa. If not, brutal rounding  may happen, and the precision mechanism is not active... 
+  //xbt_assert(*variable< (2<<DBL_MANT_DIG)*precision && FLT_RADIX==2);
   *variable -= value;
   if (*variable < precision)
     *variable = 0.0;
@@ -278,6 +284,23 @@ XBT_PUBLIC(lmm_variable_t) lmm_get_var_from_cnst(lmm_system_t sys,
                                      lmm_constraint_t cnst,
                                      lmm_element_t * elem);
 
+/**
+ * @brief Get a var associated to a constraint
+ * @details Get the first variable of the next variable of elem if elem is not NULL
+ *
+ * @param cnst A constraint
+ * @param elem A element of constraint of the constraint or NULL
+ * @param nextelem A element of constraint of the constraint or NULL, the one after elem
+ * @param numelem parameter representing the number of elements to go
+ *
+ * @return A variable associated to a constraint
+ */
+XBT_PUBLIC(lmm_variable_t) lmm_get_var_from_cnst_safe(lmm_system_t /*sys*/,
+                                     lmm_constraint_t cnst,
+                                     lmm_element_t * elem,
+                                     lmm_element_t * nextelem,
+                                     int * numelem);
+
 /**
  * @brief Get the first active constraint of a system
  * 
@@ -342,7 +365,7 @@ XBT_PUBLIC(void) lmm_update_variable_bound(lmm_system_t sys, lmm_variable_t var,
  * @brief Update the weight of a variable
  * 
  * @param sys A system
- * @param var A variable
+ * @param var A variable
  * @param weight The new weight of the variable
  */
 XBT_PUBLIC(void) lmm_update_variable_weight(lmm_system_t sys,