1 /* Copyright (c) 2006-2023. The SimGrid Team. All rights reserved. */
3 /* This program is free software; you can redistribute it and/or modify it
4 * under the terms of the license (GNU LGPL) which comes with this package. */
8 #include <simgrid/s4u.hpp>
11 /** @brief Creates a platform based on dahu cluster in Grid'5000 */
12 void load_dahu_platform(const simgrid::s4u::Engine& e, double bw, double lat);
14 /** @brief Noise generation interface */
17 virtual double sample() = 0;
20 /** @brief Segmented noise generation. Use different sampler for each message size */
21 class SegmentedRegression {
22 std::map<double, std::shared_ptr<Sampler>> segments_;
23 std::map<double, double> coef_;
25 std::shared_ptr<Sampler> get_sampler(double x) const
27 auto sampler = segments_.upper_bound(x);
28 if (sampler->first >= x)
29 return sampler->second;
34 explicit SegmentedRegression(bool use = true) : use_coef_(use) {}
35 void append(double max, double coef, std::shared_ptr<Sampler> sampler)
38 segments_[max] = std::move(sampler);
41 double sample(double x) const
43 double value = get_sampler(x)->sample();
45 value += x * coef_.upper_bound(x)->second;
49 double get_coef(double x) const { return coef_.upper_bound(x)->second; }