1 /* Copyright (c) 2004-2019. 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"
7 #include "src/statmc/rng.hpp"
9 #include "xbt/random.hpp"
16 double StochasticDatedValue::draw(Distribution law, std::vector<double> params)
22 return simgrid::xbt::random::exponential(params[0]);
24 return simgrid::xbt::random::uniform_real(params[0], params[1]);
26 return simgrid::xbt::random::normal(params[0], params[1]);
28 xbt_assert(false, "Unimplemented distribution");
32 double StochasticDatedValue::get_value()
34 return draw(value_law, value_params);
36 double StochasticDatedValue::get_date()
38 return draw(date_law, date_params);
40 DatedValue StochasticDatedValue::get_datedvalue()
43 event.date_ = get_date();
44 event.value_ = get_value();
48 bool StochasticDatedValue::operator==(StochasticDatedValue const& e2) const
50 return (e2.date_law == date_law) && (e2.value_law == value_law) && (e2.value_params == value_params) &&
51 (e2.date_params == date_params);
54 std::ostream& operator<<(std::ostream& out, const StochasticDatedValue& e)
56 out << e.date_law << " (";
57 for (unsigned int i = 0; i < e.date_params.size(); i++) {
58 out << e.date_params[i];
59 if (i != e.date_params.size() - 1) {
63 out << ") " << e.value_law << " (";
64 for (unsigned int i = 0; i < e.value_params.size(); i++) {
65 out << e.value_params[i];
66 if (i != e.value_params.size() - 1) {
74 } // namespace profile
76 } // namespace simgrid