1 /* Copyright (c) 2004-2022. 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. */
6 #include "src/kernel/resource/profile/StochasticDatedValue.hpp"
8 #include "xbt/random.hpp"
11 namespace simgrid::kernel::profile {
13 double StochasticDatedValue::draw(Distribution law, std::vector<double> params)
16 case Distribution::DET:
18 case Distribution::EXP:
19 return simgrid::xbt::random::exponential(params[0]);
20 case Distribution::UNIF:
21 return simgrid::xbt::random::uniform_real(params[0], params[1]);
22 case Distribution::NORM:
23 return simgrid::xbt::random::normal(params[0], params[1]);
25 xbt_die("Unimplemented distribution");
29 double StochasticDatedValue::get_value() const
31 return draw(value_law, value_params);
34 double StochasticDatedValue::get_date() const
36 return draw(date_law, date_params);
39 DatedValue StochasticDatedValue::get_datedvalue() const
42 event.date_ = get_date();
43 event.value_ = get_value();
47 bool StochasticDatedValue::operator==(StochasticDatedValue const& e2) const
49 return (e2.date_law == date_law) && (e2.value_law == value_law) && (e2.value_params == value_params) &&
50 (e2.date_params == date_params);
53 } // namespace simgrid::kernel::profile