20#ifndef ACTION_STATE_HPP
21#define ACTION_STATE_HPP
32namespace Opm::RestartIO {
36namespace Opm::Action {
45namespace Opm::Action {
64 bool hasWell(
const std::string& well)
const;
82 template <
class Serializer>
85 serializer(this->wells_);
92 std::vector<std::string> wells_{};
103 void add_run(
const ActionX& action, std::time_t sim_time,
const Result&
result);
117 std::size_t
run_count(
const ActionX& action)
const;
127 std::time_t
run_time(
const ActionX& action)
const;
136 const MatchSet*
result(
const std::string& action)
const;
143 std::optional<bool>
python_result(
const std::string& action)
const;
151 void load_rst(
const Actions& action_config,
159 template<
class Serializer>
162 serializer(this->run_state);
163 serializer(this->last_result);
164 serializer(this->m_python_result);
183 RunState() =
default;
188 explicit RunState(
const std::time_t sim_time)
196 void add_run(
const std::time_t sim_time)
198 this->last_run = sim_time;
199 this->run_count += 1;
203 static RunState serializationTestObject()
208 rs.last_run = 123456;
219 bool operator==(
const RunState& other)
const
221 return (this->run_count == other.run_count)
222 && (this->last_run == other.last_run);
230 template <
class Serializer>
231 void serializeOp(Serializer& serializer)
233 serializer(this->run_count);
234 serializer(this->last_run);
238 std::size_t run_count{};
241 std::time_t last_run{};
248 using ActionID = std::pair<std::string, std::size_t>;
252 std::map<ActionID, RunState> run_state{};
256 std::map<std::string, MatchSet> last_result{};
259 std::map<std::string, bool> m_python_result{};
Matching entities from a successfully triggered ActionX object.
Definition State.hpp:55
bool operator==(const MatchSet &that) const
Equality predicate.
Definition State.cpp:68
static MatchSet serializationTestObject()
Create a serialisation test object.
Definition State.cpp:57
void serializeOp(Serializer &serializer)
Convert between byte array and object representation.
Definition State.hpp:83
bool hasWell(const std::string &well) const
Whether or not a particular well exists in the set of matching entities.
Definition State.cpp:49
Management information about the current run's ACTION system, especially concerning the number of tim...
Definition State.hpp:51
void add_run(const ActionX &action, std::time_t sim_time, const Result &result)
Record ActionX Run.
Definition State.cpp:95
std::size_t run_count(const ActionX &action) const
Retrieve number of times an action has run.
Definition State.cpp:75
std::time_t run_time(const ActionX &action) const
Retrieve timestamp of the last time an action ran.
Definition State.cpp:83
const MatchSet * result(const std::string &action) const
Retrieve set of matching entities from the last time an action ran.
Definition State.cpp:125
void serializeOp(Serializer &serializer)
Convert between byte array and object representation.
Definition State.hpp:160
void load_rst(const Actions &action_config, const RestartIO::RstState &rst_state)
Load action state from restart file.
Definition State.cpp:147
static State serializationTestObject()
Create a serialisation test object.
Definition State.cpp:169
std::optional< bool > python_result(const std::string &action) const
Query for the result of running a PyAction.
Definition State.cpp:134
bool operator==(const State &other) const
Equality predicate.
Definition State.cpp:161
Class for (de-)serializing.
Definition Serializer.hpp:94