1 /* Copyright (c) 2004-2020. 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"
15 double StochasticDatedValue::draw(Distribution law, std::vector<double> params)
18 case Distribution::DET:
20 case Distribution::EXP:
21 return simgrid::xbt::random::exponential(params[0]);
22 case Distribution::UNIF:
23 return simgrid::xbt::random::uniform_real(params[0], params[1]);
24 case Distribution::NORM:
25 return simgrid::xbt::random::normal(params[0], params[1]);
27 xbt_assert(false, "Unimplemented distribution");
31 double StochasticDatedValue::get_value()
33 return draw(value_law, value_params);
35 double StochasticDatedValue::get_date()
37 return draw(date_law, date_params);
39 DatedValue StochasticDatedValue::get_datedvalue()
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 profile
55 } // namespace simgrid