Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of https://framagit.org/simgrid/simgrid
[simgrid.git] / src / kernel / resource / profile / StochasticDatedValue.hpp
1 /* Copyright (c) 2004-2023. The SimGrid Team. All rights reserved.          */
2
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. */
5
6 #ifndef SIMGRID_KERNEL_PROFILE_STOCHASTICDATEDVALUE
7 #define SIMGRID_KERNEL_PROFILE_STOCHASTICDATEDVALUE
8
9 #include "simgrid/forward.h"
10 #include "simgrid/kernel/ProfileBuilder.hpp"
11 #include <vector>
12
13 namespace simgrid::kernel::profile {
14
15 enum class Distribution { EXP, NORM, UNIF, DET };
16
17 class XBT_PUBLIC StochasticDatedValue {
18 public:
19   Distribution date_law = Distribution::DET;
20   std::vector<double> date_params;
21   Distribution value_law = Distribution::DET;
22   std::vector<double> value_params;
23   DatedValue get_datedvalue() const;
24   double get_date() const;
25   double get_value() const;
26   explicit StochasticDatedValue() = default;
27   explicit StochasticDatedValue(double d, double v) : date_params({d}), value_params({v}) {}
28   explicit StochasticDatedValue(Distribution dl, const std::vector<double>& dp, Distribution vl,
29                                 const std::vector<double>& vp)
30       : date_law(dl), date_params(dp), value_law(vl), value_params(vp)
31   {
32   }
33   bool operator==(StochasticDatedValue const& e2) const;
34
35 private:
36   static double draw(Distribution law, std::vector<double> params);
37 };
38
39 } // namespace simgrid::kernel::profile
40
41 std::vector<simgrid::kernel::profile::StochasticDatedValue> trace2selist( const char* c_str );
42
43 #endif