X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/ea74f5d95928a521a588737e81f1de94eef25d19..3bb5446e9de29764eb8d739753c101cbb90a7b21:/docs/source/tuto_network_calibration/dahu_platform_ckmeans.cpp diff --git a/docs/source/tuto_network_calibration/dahu_platform_ckmeans.cpp b/docs/source/tuto_network_calibration/dahu_platform_ckmeans.cpp index d47c52154d..2ac5db27d3 100644 --- a/docs/source/tuto_network_calibration/dahu_platform_ckmeans.cpp +++ b/docs/source/tuto_network_calibration/dahu_platform_ckmeans.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2006-2022. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2006-2023. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ @@ -8,7 +8,6 @@ #include #include #include -#include #include #include namespace sg4 = simgrid::s4u; @@ -19,13 +18,13 @@ class NormalMixture : public Sampler { std::mt19937& gen_; public: - NormalMixture(std::mt19937& gen) : gen_(gen) {} + explicit NormalMixture(std::mt19937& gen) : gen_(gen) {} void append(double mean, double stddev, double prob) { mixture_.push_back(std::normal_distribution(mean, stddev)); prob_.push_back(prob); } - double sample() + double sample() override { std::discrete_distribution<> d(prob_.begin(), prob_.end()); int index = d(gen_); @@ -40,7 +39,7 @@ public: * * @param latency_base The base latency for this calibration (user-defined) * @param seg Segmentation (user-defined) - * @param size Message size (simgrid) + * @param size Message size (SimGrid) */ static double latency_factor_cb(double latency_base, const SegmentedRegression& seg, double size, const sg4::Host* /*src*/, const sg4::Host* /*dst*/, @@ -58,7 +57,7 @@ static double latency_factor_cb(double latency_base, const SegmentedRegression& * * @param bw_base The base bandwidth for this calibration (user-defined) * @param seg Segmentation (user-defined) - * @param size Message size (simgrid) + * @param size Message size (SimGrid) */ static double bw_factor_cb(double bw_base, const SegmentedRegression& seg, double size, const sg4::Host* /*src*/, const sg4::Host* /*dst*/, const std::vector& /*links*/, @@ -88,7 +87,7 @@ static SegmentedRegression read_json_file(const std::string& jsonFile, std::mt19 double max = it.second.get_child("max_x").get_value(); coefs[max] = it.second.get_child("coefficient").get_value(); auto& mixture = mixtures[max]; - if (!mixture) + if (not mixture) mixture = std::make_shared(gen); mixture->append(it.second.get_child("mean").get_value(), it.second.get_child("sd").get_value(), it.second.get_child("prob").get_value()); @@ -119,14 +118,14 @@ void load_platform(const sg4::Engine& e) static std::mt19937 gen(42); // remove it from stack, since we need it after this this load_platform function is over /* setting network factors callbacks */ - simgrid::kernel::resource::NetworkModelIntf* model = e.get_netzone_root()->get_network_model(); + auto* zone = e.get_netzone_root(); SegmentedRegression seg = read_json_file("pingpong_ckmeans.json", gen, false); - model->set_lat_factor_cb(std::bind(&latency_factor_cb, lat_base, seg, std::placeholders::_1, std::placeholders::_2, - std::placeholders::_3, std::placeholders::_4, std::placeholders::_5)); + zone->set_latency_factor_cb(std::bind(&latency_factor_cb, lat_base, seg, std::placeholders::_1, std::placeholders::_2, + std::placeholders::_3, std::placeholders::_4, std::placeholders::_5)); - model->set_bw_factor_cb(std::bind(&bw_factor_cb, bw_base, seg, std::placeholders::_1, std::placeholders::_2, - std::placeholders::_3, std::placeholders::_4, std::placeholders::_5)); + zone->set_bandwidth_factor_cb(std::bind(&bw_factor_cb, bw_base, seg, std::placeholders::_1, std::placeholders::_2, + std::placeholders::_3, std::placeholders::_4, std::placeholders::_5)); seg = read_json_file("send_ckmeans.json", gen); smpi_register_op_cost_callback(SmpiOperation::SEND, std::bind(&smpi_cost_cb, seg, std::placeholders::_1, @@ -138,4 +137,4 @@ void load_platform(const sg4::Engine& e) seg = read_json_file("recv_ckmeans.json", gen); smpi_register_op_cost_callback(SmpiOperation::RECV, std::bind(&smpi_cost_cb, seg, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); -} \ No newline at end of file +}