diff --git a/include/arbitration_graphs/internal/random_arbitrator_io.hpp b/include/arbitration_graphs/internal/random_arbitrator_io.hpp new file mode 100644 index 00000000..587ba3e9 --- /dev/null +++ b/include/arbitration_graphs/internal/random_arbitrator_io.hpp @@ -0,0 +1,38 @@ +#pragma once + +#include "../random_arbitrator.hpp" + + +namespace arbitration_graphs { + + +////////////////////////////////////// +// RandomArbitrator::Option // +////////////////////////////////////// + +template +std::ostream& RandomArbitrator::Option::to_stream( + std::ostream& output, + const Time& time, + const int& option_index, + const std::string& prefix, + const std::string& suffix) const { + + output << std::fixed << std::setprecision(3) << "- (weight: " << weight_ << ") "; + ArbitratorBase::Option::to_stream(output, time, option_index, prefix, suffix); + return output; +} + + +////////////////////////////////////// +// RandomArbitrator // +////////////////////////////////////// + +template +YAML::Node RandomArbitrator::toYaml(const Time& time) const { + YAML::Node node = ArbitratorBase::toYaml(time); + node["type"] = "RandomArbitrator"; + return node; +} + +} // namespace arbitration_graphs diff --git a/include/arbitration_graphs/random_arbitrator.hpp b/include/arbitration_graphs/random_arbitrator.hpp new file mode 100644 index 00000000..918c41c4 --- /dev/null +++ b/include/arbitration_graphs/random_arbitrator.hpp @@ -0,0 +1,113 @@ +#pragma once + +#include +#include + +#include + +#include "arbitrator.hpp" + +namespace arbitration_graphs { + +template , + typename VerificationResultT = typename decltype(std::function{VerifierT::analyze})::result_type> +class RandomArbitrator : public Arbitrator { +public: + using ArbitratorBase = Arbitrator; + + using Ptr = std::shared_ptr; + using ConstPtr = std::shared_ptr; + + struct Option : public ArbitratorBase::Option { + public: + using Ptr = std::shared_ptr