Skip to content

Commit

Permalink
consistency in db, fix initialize order
Browse files Browse the repository at this point in the history
  • Loading branch information
nuclearkatie committed Oct 17, 2023
1 parent eacc34a commit f814283
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 23 deletions.
33 changes: 14 additions & 19 deletions src/context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,43 +22,43 @@ SimInfo::SimInfo()
m0(0),
dt(kDefaultTimeStepDur),
decay("manual"),
seed(kDefaultSeed),
stride(kDefaultStride),
branch_time(-1),
explicit_inventory(false),
explicit_inventory_compact(false),
parent_sim(boost::uuids::nil_uuid()),
parent_type("init") {}
parent_type("init"),
seed(kDefaultSeed),
stride(kDefaultStride) {}

SimInfo::SimInfo(int dur, int y0, int m0, std::string handle)
: duration(dur),
y0(y0),
m0(m0),
dt(kDefaultTimeStepDur),
decay("manual"),
seed(kDefaultSeed),
stride(kDefaultStride),
branch_time(-1),
handle(handle),
explicit_inventory(false),
explicit_inventory_compact(false),
parent_sim(boost::uuids::nil_uuid()),
parent_type("init") {}
parent_type("init"),
seed(kDefaultSeed),
stride(kDefaultStride) {}

SimInfo::SimInfo(int dur, int y0, int m0, std::string handle, std::string d)
: duration(dur),
y0(y0),
m0(m0),
dt(kDefaultTimeStepDur),
decay(d),
seed(kDefaultSeed),
stride(kDefaultStride),
branch_time(-1),
handle(handle),
explicit_inventory(false),
explicit_inventory_compact(false),
parent_sim(boost::uuids::nil_uuid()),
parent_type("init") {}
parent_type("init"),
seed(kDefaultSeed),
stride(kDefaultStride), {}

SimInfo::SimInfo(int dur, boost::uuids::uuid parent_sim,
int branch_time, std::string parent_type,
Expand All @@ -68,14 +68,14 @@ SimInfo::SimInfo(int dur, boost::uuids::uuid parent_sim,
m0(-1),
dt(kDefaultTimeStepDur),
decay("manual"),
seed(kDefaultSeed),
stride(kDefaultStride),
parent_sim(parent_sim),
parent_type(parent_type),
branch_time(branch_time),
explicit_inventory(false),
explicit_inventory_compact(false),
handle(handle) {}
handle(handle),
seed(kDefaultSeed),
stride(kDefaultStride) {}

Context::Context(Timer* ti, Recorder* rec)
: ti_(ti),
Expand Down Expand Up @@ -192,8 +192,8 @@ void Context::InitSim(SimInfo si) {
->AddVal("InitialYear", si.y0)
->AddVal("InitialMonth", si.m0)
->AddVal("Duration", si.duration)
->AddVal("Seed", si.seed)
->AddVal("Stride", si.stride)
->AddVal("Seed", static_cast<int>(si.seed))
->AddVal("Stride", static_cast<int>(si.stride))
->AddVal("ParentSimId", si.parent_sim)
->AddVal("ParentType", si.parent_type)
->AddVal("BranchTime", si.branch_time)
Expand Down Expand Up @@ -221,11 +221,6 @@ void Context::InitSim(SimInfo si) {
->AddVal("DurationSecs", static_cast<int>(si.dt))
->Record();

NewDatum("RNGInfo")
->AddVal("Seed", static_cast<int>(si.seed))
->AddVal("Stride", static_cast<int>(si.stride))
->Record();

NewDatum("Epsilon")
->AddVal("GenericEpsilon", si.eps)
->AddVal("ResourceEpsilon", si.eps_rsrc)
Expand Down
7 changes: 3 additions & 4 deletions src/sim_init.cc
Original file line number Diff line number Diff line change
Expand Up @@ -155,15 +155,14 @@ void SimInit::LoadInfo() {

si_.parent_sim = qr.GetVal<boost::uuids::uuid>("ParentSimId");

si_.seed = qr.GetVal<int>("Seed");
si_.stride = qr.GetVal<int>("Stride");

qr = b_->Query("TimeStepDur", NULL);
// TODO: when the backends support uint64_t, the int template here
// should be updated to uint64_t.
si_.dt = qr.GetVal<int>("DurationSecs");

qr = b_->Query("RNGInfo", NULL);
si_.seed = qr.GetVal<int>("Seed");
si_.stride = qr.GetVal<int>("Stride");

qr = b_->Query("Epsilon", NULL);
si_.eps = qr.GetVal<double>("GenericEpsilon");
si_.eps_rsrc = qr.GetVal<double>("ResourceEpsilon");
Expand Down

0 comments on commit f814283

Please sign in to comment.