2 #include "creativity/state/StorageBackend.hpp" 3 #include "creativity/BookCopy.hpp" 4 #include "creativity/CreativitySettings.hpp" 5 #include <eris/learning/BayesianLinearRestricted.hpp> 6 #include <eris/types.hpp> 7 #include <eris/serialize/serializer.hpp> 8 #include <eris/serialize/Serialization.hpp> 10 #include <boost/detail/endian.hpp> 63 template <
typename... Args>
67 open(filename, mode, std::forward<Args>(args)...);
91 virtual std::shared_ptr<const State>
load(eris::eris_time_t t)
override;
94 virtual size_t size()
override;
123 uint64_t state_pointer_block_, readerlib_block_;
126 class lib_comp_less final {
128 using ref =
const std::pair<const eris::eris_id_t, BookCopy>&;
129 bool operator()(ref a, ref b)
const {
130 return a.second.acquired < b.second.acquired;
137 std::map<uint64_t, BookCopy> library;
139 std::multiset<std::reference_wrapper<std::pair<const uint64_t, BookCopy>>, lib_comp_less> library_acq_sorted;
144 std::map<eris::eris_id_t, std::pair<uint64_t, lib_data>> reader_lib_;
154 virtual uint32_t appFileVersion()
const override {
return 2; }
157 virtual std::string appName()
const override {
return "creativity"; }
160 virtual void thread_insert(std::shared_ptr<const State> &&s)
override;
170 void updateLibraries(
const std::map<eris::eris_id_t, ReaderState> &r);
186 std::shared_ptr<const State> readState();
189 void writeState(
const State &state);
225 std::pair<eris::eris_id_t, ReaderState> readReader(eris::eris_time_t t);
233 bool noninformative =
true;
234 Eigen::VectorXd beta;
237 Eigen::MatrixXd Vinv;
238 eris::learning::BayesianLinearRestricted::DrawMode last_draw_mode;
239 uint32_t draw_success_cumulative,
240 draw_discards_cumulative;
281 belief_data readBelief();
294 void writeBelief(
const eris::learning::BayesianLinear &belief);
319 std::pair<eris::eris_id_t, BookState> readBook();
333 std::unique_ptr<PublicTrackerState> readPublicTracker();
Records the various variables associated with a reader.
Definition: ReaderState.hpp:18
Primary namespace for all Creativity library code.
Definition: config.hpp:4
virtual size_t size() override
Returns the number of states currently stored in the file.
FileStorage(CreativitySettings &settings)
Constructs a FileStorage that stores file content in an in-memory buffer.
Definition: FileStorage.hpp:50
An array of books.
Definition: FileStorage.hpp:39
Class storing the state of the simulation at the end of a simulation period.
Definition: State.hpp:19
An array of readers.
Definition: FileStorage.hpp:38
Class for file-based storage.
Definition: FileStorage.hpp:33
void writeSettings() override
Calls updateHeaderFields() to rewrite settings.
A PublicTracker state.
Definition: FileStorage.hpp:40
virtual void storage_flush() override
Flushes the file stream.
virtual std::shared_ptr< const State > load(eris::eris_time_t t) override
Loads the requested state data from the open file into a State object and returns it (wrapped in a sh...
Psuedo-type indicating the end of the record list.
Definition: FileStorage.hpp:37
void writeExtraHeader() override
Adds a state pointer block to the end of the header.
Simulation parameters that are used to configure the simulation when calling setup().
Definition: CreativitySettings.hpp:10
Base class for state storage which accesses State values.
Definition: StorageBackend.hpp:26
void configureHeaderFields() override
Registers the various creativity parameters as header fields.
Records the various variables associated with a reader.
Definition: PublicTrackerState.hpp:11
void readExtraHeader() override
Stores the location of the state pointer block at the end of the head.
TYPE
The supported record types within a state.
Definition: FileStorage.hpp:36
FileStorage(CreativitySettings &settings, const std::string &filename, Mode mode, Args &&... args)
Constructs and returns a FileStorage object that uses the given file for reading and (optionally) wri...
Definition: FileStorage.hpp:64
void throwParseError(const std::string &message) const
Default move constructor.
Records the various variables associated with a book.
Definition: BookState.hpp:12