Serialize Action::State
This commit is contained in:
parent
a39c707282
commit
cb5eef07a6
@ -81,6 +81,15 @@ public:
|
||||
WellSet& intersect(const WellSet& other);
|
||||
WellSet& add(const WellSet& other);
|
||||
bool operator==(const WellSet& other) const;
|
||||
|
||||
template<class Serializer>
|
||||
void serializeOp(Serializer& serializer)
|
||||
{
|
||||
serializer.template set<std::unordered_set<std::string>, false>(this->well_set);
|
||||
}
|
||||
|
||||
static WellSet serializeObject();
|
||||
|
||||
private:
|
||||
std::unordered_set<std::string> well_set;
|
||||
};
|
||||
@ -89,6 +98,7 @@ private:
|
||||
|
||||
class Result {
|
||||
public:
|
||||
Result() = default;
|
||||
explicit Result(bool result_arg);
|
||||
Result(bool result_arg, const std::vector<std::string>& wells);
|
||||
Result(bool result_arg, const WellSet& wells);
|
||||
@ -104,6 +114,15 @@ public:
|
||||
Result& operator&=(const Result& other);
|
||||
bool operator==(const Result& other) const;
|
||||
|
||||
template<class Serializer>
|
||||
void serializeOp(Serializer& serializer)
|
||||
{
|
||||
serializer(this->result);
|
||||
serializer(this->matching_wells);
|
||||
}
|
||||
|
||||
static Result serializeObject();
|
||||
|
||||
private:
|
||||
void assign(bool value);
|
||||
bool result;
|
||||
|
@ -38,6 +38,8 @@ class Actions;
|
||||
class State {
|
||||
|
||||
struct RunState {
|
||||
RunState() = default;
|
||||
|
||||
RunState(std::time_t sim_time)
|
||||
: run_count(1)
|
||||
, last_run(sim_time)
|
||||
@ -48,16 +50,51 @@ struct RunState {
|
||||
this->run_count += 1;
|
||||
}
|
||||
|
||||
static RunState serializeObject()
|
||||
{
|
||||
RunState rs;
|
||||
rs.run_count = 100;
|
||||
rs.last_run = 123456;
|
||||
return rs;
|
||||
}
|
||||
|
||||
|
||||
bool operator==(const RunState& other) const {
|
||||
return this->run_count == other.run_count &&
|
||||
this->last_run == other.last_run;
|
||||
}
|
||||
|
||||
template<class Serializer>
|
||||
void serializeOp(Serializer& serializer)
|
||||
{
|
||||
serializer(this->run_count);
|
||||
serializer(this->last_run);
|
||||
}
|
||||
|
||||
std::size_t run_count;
|
||||
std::time_t last_run;
|
||||
};
|
||||
|
||||
|
||||
|
||||
public:
|
||||
void add_run(const ActionX& action, std::time_t sim_time, Result result);
|
||||
std::size_t run_count(const ActionX& action) const;
|
||||
std::time_t run_time(const ActionX& action) const;
|
||||
std::optional<Result> result(const std::string& action) const;
|
||||
void load_rst(const Actions& action_config, const RestartIO::RstState& rst_state);
|
||||
|
||||
template<class Serializer>
|
||||
void serializeOp(Serializer& serializer)
|
||||
{
|
||||
serializer.map(this->run_state);
|
||||
serializer.map(this->last_result);
|
||||
}
|
||||
|
||||
|
||||
static State serializeObject();
|
||||
bool operator==(const State& other) const;
|
||||
|
||||
private:
|
||||
using action_id = std::pair<std::string, std::size_t>;
|
||||
static action_id make_id(const ActionX& action);
|
||||
|
@ -155,5 +155,19 @@ bool WellSet::operator==(const WellSet& other) const {
|
||||
return this->well_set == other.well_set;
|
||||
}
|
||||
|
||||
WellSet WellSet::serializeObject() {
|
||||
WellSet ws;
|
||||
ws.well_set = {"W1", "W2", "W3"};
|
||||
return ws;
|
||||
}
|
||||
|
||||
|
||||
Result Result::serializeObject() {
|
||||
Result rs;
|
||||
rs.result = false;
|
||||
rs.matching_wells = WellSet::serializeObject();
|
||||
return rs;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -83,5 +83,19 @@ void State::load_rst(const Actions& action_config, const RestartIO::RstState& rs
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool State::operator==(const State& other) const {
|
||||
return this->run_state == other.run_state &&
|
||||
this->last_result == other.last_result;
|
||||
}
|
||||
|
||||
|
||||
State State::serializeObject() {
|
||||
State st;
|
||||
st.run_state.insert(std::make_pair( std::make_pair("ACTION", 100), RunState::serializeObject()));
|
||||
st.last_result.insert( std::make_pair("ACTION", Result::serializeObject()));
|
||||
return st;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user