#define SURF_MAXMIN_HPP
#include "src/internal_config.h"
-#include "surf/datatypes.h"
+#include "surf/surf.hpp"
#include "xbt/asserts.h"
#include "xbt/misc.h"
#include <cmath>
-namespace simgrid {
-namespace surf {
-class Action;
-}
-}
-
/** @addtogroup SURF_lmm
* @details
* A linear maxmin solver to resolve inequations systems.
XBT_PUBLIC_DATA(double) sg_surf_precision;
XBT_PUBLIC_DATA(int) sg_concurrency_limit;
-static inline void double_update(double *variable, double value, double precision)
+static 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);
+ // 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;
return (fabs(value1 - value2) < precision);
}
-extern "C" {
-
/** @{ @ingroup SURF_lmm */
/**
* @brief Create a new Linear MaxMim system
* @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);
+XBT_PUBLIC(lmm_constraint_t) lmm_constraint_new(lmm_system_t sys, void* id, double bound_value);
/**
* @brief Share a constraint
*/
XBT_PUBLIC(int) lmm_constraint_sharing_policy(lmm_constraint_t cnst);
-/**
- * @brief Free a constraint
- * @param sys The system associated to the constraint
- * @param cnst The constraint to free
- */
-XBT_PUBLIC(void) lmm_constraint_free(lmm_system_t sys, lmm_constraint_t cnst);
-
/**
* @brief Get the usage of the constraint after the last lmm solve
* @param cnst A constraint
*/
XBT_PUBLIC(void) lmm_variable_concurrency_share_set(lmm_variable_t var, short int concurrency_share);
-/**
- * @brief Remove a variable from a constraint
- * @param sys A system
- * @param cnst A constraint
- * @param var The variable to remove
- */
-XBT_PUBLIC(void) lmm_shrink(lmm_system_t sys, lmm_constraint_t cnst, lmm_variable_t var);
-
/**
* @brief Associate a variable to a constraint with a coefficient
* @param sys A system
* @param num The rank of constraint we want to get
* @return The numth constraint
*/
-XBT_PUBLIC(lmm_constraint_t) lmm_get_cnst_from_var(lmm_system_t sys, lmm_variable_t var, int num);
+XBT_PUBLIC(lmm_constraint_t) lmm_get_cnst_from_var(lmm_system_t sys, lmm_variable_t var, unsigned num);
/**
* @brief Get the weigth of the numth constraint associated to the variable
* @param num The rank of constraint we want to get
* @return The numth constraint
*/
-XBT_PUBLIC(double) lmm_get_cnst_weight_from_var(lmm_system_t sys, lmm_variable_t var, int num);
+XBT_PUBLIC(double) lmm_get_cnst_weight_from_var(lmm_system_t sys, lmm_variable_t var, unsigned num);
/**
* @brief Get the number of constraint associated to a variable
* @param elem A element of constraint of the constraint or NULL
* @return A variable associated to a constraint
*/
-XBT_PUBLIC(lmm_variable_t) lmm_get_var_from_cnst(lmm_system_t sys, lmm_constraint_t cnst, lmm_element_t * elem);
+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
*
* @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);
+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
* @param cnst A constraint
* @return The data associated to the constraint
*/
-XBT_PUBLIC(void *) lmm_constraint_id(lmm_constraint_t cnst);
+XBT_PUBLIC(void*) lmm_constraint_id(lmm_constraint_t cnst);
/**
* @brief Get the data associated to a variable
* @param var A variable
* @return The data associated to the variable
*/
-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
/** Default functions associated to the chosen protocol. When using the lagrangian approach. */
-XBT_PUBLIC(void) lmm_set_default_protocol_function(double (*func_f)(lmm_variable_t var,double x),
- double (*func_fp)(lmm_variable_t var,double x),
- double (*func_fpi)(lmm_variable_t var,double x));
+XBT_PUBLIC(void)
+lmm_set_default_protocol_function(double (*func_f)(lmm_variable_t var, double x),
+ double (*func_fp)(lmm_variable_t var, double x),
+ double (*func_fpi)(lmm_variable_t var, double x));
-XBT_PUBLIC(double func_reno_f) (lmm_variable_t var, double x);
-XBT_PUBLIC(double func_reno_fp) (lmm_variable_t var, double x);
-XBT_PUBLIC(double func_reno_fpi) (lmm_variable_t var, double x);
+XBT_PUBLIC(double) func_reno_f(lmm_variable_t var, double x);
+XBT_PUBLIC(double) func_reno_fp(lmm_variable_t var, double x);
+XBT_PUBLIC(double) func_reno_fpi(lmm_variable_t var, double x);
-XBT_PUBLIC(double func_reno2_f) (lmm_variable_t var, double x);
-XBT_PUBLIC(double func_reno2_fp) (lmm_variable_t var, double x);
-XBT_PUBLIC(double func_reno2_fpi) (lmm_variable_t var, double x);
+XBT_PUBLIC(double) func_reno2_f(lmm_variable_t var, double x);
+XBT_PUBLIC(double) func_reno2_fp(lmm_variable_t var, double x);
+XBT_PUBLIC(double) func_reno2_fpi(lmm_variable_t var, double x);
-XBT_PUBLIC(double func_vegas_f) (lmm_variable_t var, double x);
-XBT_PUBLIC(double func_vegas_fp) (lmm_variable_t var, double x);
-XBT_PUBLIC(double func_vegas_fpi) (lmm_variable_t var, double x);
+XBT_PUBLIC(double) func_vegas_f(lmm_variable_t var, double x);
+XBT_PUBLIC(double) func_vegas_fp(lmm_variable_t var, double x);
+XBT_PUBLIC(double) func_vegas_fpi(lmm_variable_t var, double x);
/** @} */
-}
#endif