From 7cfc560f026d4b432b965eb58510366d49b2c2b7 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 14 Sep 2024 18:28:22 -0500 Subject: [PATCH] xo-process: bugfix: track xo::ref::rp -> xo::rp --- include/xo/process/AbstractRealization.hpp | 2 +- include/xo/process/BrownianMotion.hpp | 6 +++--- include/xo/process/ExpProcess.hpp | 4 ++-- include/xo/process/LogNormalProcess.hpp | 4 ++-- include/xo/process/Realizable2Process.hpp | 8 ++++---- include/xo/process/Realization.hpp | 4 ++-- include/xo/process/Realization2.hpp | 10 ++++----- include/xo/process/RealizationSource.hpp | 24 +++++++++++----------- include/xo/process/RealizationTracer.hpp | 8 ++++---- include/xo/process/UpxToConsole.hpp | 2 +- src/process/UpxToConsole.cpp | 2 +- utest/RealizationSource.test.cpp | 3 +-- 12 files changed, 38 insertions(+), 39 deletions(-) diff --git a/include/xo/process/AbstractRealization.hpp b/include/xo/process/AbstractRealization.hpp index e664bb0a..b87e20ac 100644 --- a/include/xo/process/AbstractRealization.hpp +++ b/include/xo/process/AbstractRealization.hpp @@ -12,7 +12,7 @@ namespace xo { namespace process { class AbstractRealization : public reflect::SelfTagging { public: - virtual ref::rp stochastic_process() const = 0; + virtual rp stochastic_process() const = 0; }; /*AbstractRealization*/ } /*namespace process*/ } /*namespace xo*/ diff --git a/include/xo/process/BrownianMotion.hpp b/include/xo/process/BrownianMotion.hpp index 317b7ec3..1ec1f5cf 100644 --- a/include/xo/process/BrownianMotion.hpp +++ b/include/xo/process/BrownianMotion.hpp @@ -36,7 +36,7 @@ namespace xo { // ----- needed by Realization2 ----- - virtual ref::rp> make_realization() override = 0; + virtual rp> make_realization() override = 0; // ----- inherited from StochasticProcess ----- @@ -83,7 +83,7 @@ namespace xo { * seed. initialize pseudorandom-number generator */ template - static ref::rp> make(utc_nanos t0, + static rp> make(utc_nanos t0, double sdev, Seed const & seed) { @@ -121,7 +121,7 @@ namespace xo { // ----- inherited from Realizable2Process<> ----- - virtual ref::rp> make_realization() override { + virtual rp> make_realization() override { rstate_type rs0 = std::make_pair(this->t0(), this->t0_value()); diff --git a/include/xo/process/ExpProcess.hpp b/include/xo/process/ExpProcess.hpp index a49313bb..8cf6f526 100644 --- a/include/xo/process/ExpProcess.hpp +++ b/include/xo/process/ExpProcess.hpp @@ -26,7 +26,7 @@ namespace xo { using TaggedRcptr = reflect::TaggedRcptr; public: - static ref::rp make(double scale, + static rp make(double scale, ref::brw> exp_proc) { return new ExpProcess(scale, exp_proc); } /*make*/ @@ -95,7 +95,7 @@ namespace xo { */ double scale_ = 1.0; /* exponentiate this process */ - ref::rp> exponent_process_; + rp> exponent_process_; }; /*ExpProcess*/ } /*namespace process*/ } /*namespace xo*/ diff --git a/include/xo/process/LogNormalProcess.hpp b/include/xo/process/LogNormalProcess.hpp index a7a3ae1a..36d6cf49 100644 --- a/include/xo/process/LogNormalProcess.hpp +++ b/include/xo/process/LogNormalProcess.hpp @@ -17,10 +17,10 @@ namespace xo { public: /* log-normal process starting at (t0, x0) */ template - static ref::rp make(utc_nanos t0, double x0, + static rp make(utc_nanos t0, double x0, double sdev, Seed const & seed) { - ref::rp> bm + rp> bm = BrownianMotion::make(t0, sdev, seed); return ExpProcess::make(x0 /*scale*/, bm); diff --git a/include/xo/process/Realizable2Process.hpp b/include/xo/process/Realizable2Process.hpp index b05e889f..5a3effd3 100644 --- a/include/xo/process/Realizable2Process.hpp +++ b/include/xo/process/Realizable2Process.hpp @@ -17,7 +17,7 @@ namespace xo { * one of its own paths * - p provides methods to implement such unfolding: * - .make_realization() :: Realization2 - * create new realization of p. + * create new realization of p. * - .rstate_sample(t1,rs0) :: time x Rstate -> Rstate * given runstate rs0 representing process state at some time t0, * sample process at time t1, with t0<=t1 @@ -28,7 +28,7 @@ namespace xo { * - .rstate_insample(t1,rs0,rs2) :: time x Rstate x Rstate -> Rstate * given runstates rs0, rs2 representing process state at two times t0 class Realizable2Process : public StochasticProcess { public: - virtual ref::rp> make_realization() = 0; + virtual rp> make_realization() = 0; /* make_rstate() will be used to establish nested state when a process is used * as input to a transforming process (ex: ExpProcess). * in that context the outer process' realization state will @@ -50,7 +50,7 @@ namespace xo { // Rstate rstate_init() const; // void rstate_sample_implace(utc_nanos t1, Rstate * p_rs0 const; }; /*Realizable2Process*/ - + } /*namespace process*/ } /*namespace xo*/ diff --git a/include/xo/process/Realization.hpp b/include/xo/process/Realization.hpp index 571b7b5a..35ced2df 100644 --- a/include/xo/process/Realization.hpp +++ b/include/xo/process/Realization.hpp @@ -33,7 +33,7 @@ namespace xo { using KnownRange = decltype(std::views::all(KnownMap())); public: - static ref::rp make(ref::brw> p) { + static rp make(ref::brw> p) { return new Realization(p); } /*make*/ @@ -58,7 +58,7 @@ namespace xo { private: /* stochastic process from which this realization is sampled */ - ref::rp> process_; + rp> process_; /* process value (for this realization) has been established (sampled) * at each time t in {.known_map[].first} diff --git a/include/xo/process/Realization2.hpp b/include/xo/process/Realization2.hpp index 499d815b..1edae93a 100644 --- a/include/xo/process/Realization2.hpp +++ b/include/xo/process/Realization2.hpp @@ -46,13 +46,13 @@ namespace xo { using nanos = xo::time::nanos; public: - ProcessRealization2(Rstate const & rstate, ref::rp const & process) + ProcessRealization2(Rstate const & rstate, rp const & process) : rstate_{rstate}, process_{process} {} - ProcessRealization2(Rstate && rstate, ref::rp const & process) + ProcessRealization2(Rstate && rstate, rp const & process) : rstate_{std::move(rstate)}, process_{process} {} Rstate const & rstate() const { return rstate_; } - ref::rp const & process() const { return process_; } + rp const & process() const { return process_; } /* sample process at point .rstate.tk + dt * Require: @@ -64,7 +64,7 @@ namespace xo { // ----- inherited from AbstractRealization ----- - virtual ref::rp stochastic_process() const override { + virtual rp stochastic_process() const override { return process_; } /*stochastic_process*/ @@ -81,7 +81,7 @@ namespace xo { /* process (set of paths + probability measure); * *this coordinates with .process to constructively samples one such path */ - ref::rp process_; + rp process_; }; /*ProcessRealization2*/ } /*namespace process*/ diff --git a/include/xo/process/RealizationSource.hpp b/include/xo/process/RealizationSource.hpp index f5087942..932da915 100644 --- a/include/xo/process/RealizationSource.hpp +++ b/include/xo/process/RealizationSource.hpp @@ -39,8 +39,8 @@ namespace xo { xtag("p", this)); } /*dtor*/ - static ref::rp - make(ref::rp> const & tracer, + static rp + make(rp> const & tracer, nanos ev_interval_dt, EventSink const & ev_sink) { @@ -60,7 +60,7 @@ namespace xo { } /*make*/ #ifdef NOT_IN_USE - static ref::rp make(ref::rp> tracer, + static rp make(rp> tracer, nanos ev_interval_dt, EventSink && ev_sink) { @@ -142,7 +142,7 @@ namespace xo { return 1; } /*deliver_one*/ - virtual CallbackId attach_sink(ref::rp const & /*sink*/) override { + virtual CallbackId attach_sink(rp const & /*sink*/) override { /* see RealizationSource */ assert(false); return CallbackId(); @@ -168,13 +168,13 @@ namespace xo { } protected: - RealizationSourceBase(ref::rp> const & tracer, + RealizationSourceBase(rp> const & tracer, nanos ev_interval_dt, EventSink const & ev_sink) : tracer_{tracer}, ev_sink_{std::move(ev_sink)}, ev_interval_dt_{ev_interval_dt} {} - RealizationSourceBase(ref::rp> const & tracer, + RealizationSourceBase(rp> const & tracer, nanos ev_interval_dt, EventSink && ev_sink) : tracer_{tracer}, @@ -192,7 +192,7 @@ namespace xo { /* counts lifetime #of events */ uint32_t n_out_ev_ = 0; /* produces events representing realized stochastic-process values */ - ref::rp> tracer_; + rp> tracer_; /* send stochastic-process events to this sink */ EventSink ev_sink_; /* discretize process using this interval: @@ -218,13 +218,13 @@ namespace xo { using nanos = xo::time::nanos; public: - static ref::rp> make(ref::rp> const & tracer, + static rp> make(rp> const & tracer, nanos ev_interval_dt) { return new RealizationSource(tracer, ev_interval_dt); } /*make*/ - CallbackId add_callback(ref::rp> const & cb) { + CallbackId add_callback(rp> const & cb) { return this->ev_sink_addr()->add_callback(cb); } /*add_callback*/ @@ -238,7 +238,7 @@ namespace xo { * .add_callback(sink) <--> .attach_sink(sink) * .remove_callback(sink) <--> .detach_sink(sink) */ - virtual CallbackId attach_sink(ref::rp const & sink) override { + virtual CallbackId attach_sink(rp const & sink) override { /* ------- * WARNING * ------- @@ -265,7 +265,7 @@ namespace xo { //scope lscope(c_self_name); //lscope.log(xtag("T", reflect::type_name())); - ref::rp> event_sink + rp> event_sink = reactor::Sink1::require_native(c_self_name, sink); return this->add_callback(event_sink); @@ -296,7 +296,7 @@ namespace xo { } /*visit_direct_consumers*/ private: - RealizationSource(ref::rp> const & tracer, + RealizationSource(rp> const & tracer, nanos ev_interval_dt) : RealizationSourceBase make(ref::rp const & p) { + static rp make(rp const & p) { return new RealizationTracer(p); } @@ -40,7 +40,7 @@ namespace xo { utc_nanos current_tm() const { return current_.first; } /* value of this path at time t */ T const & current_value() const { return current_.second; } - ref::rp const & process() const { return process_; } + rp const & process() const { return process_; } /* sample with fixed time: * - advance to time t+dt, where t=.current_tm() @@ -95,7 +95,7 @@ namespace xo { #endif private: - RealizationTracer(ref::rp const & p) + RealizationTracer(rp const & p) : current_(event_type(p->t0(), p->t0_value())), process_(p) {} private: @@ -103,7 +103,7 @@ namespace xo { event_type current_; /* develop a sampled realization of this stochastic process */ - ref::rp process_; + rp process_; }; /*RealizationTracer*/ } /*namespace process*/ diff --git a/include/xo/process/UpxToConsole.hpp b/include/xo/process/UpxToConsole.hpp index 50c259fd..650de79c 100644 --- a/include/xo/process/UpxToConsole.hpp +++ b/include/xo/process/UpxToConsole.hpp @@ -17,7 +17,7 @@ namespace xo { public: UpxToConsole(); - static ref::rp make(); + static rp make(); }; /*UpxToConsole*/ } /*namespace process*/ } /*namespace xo*/ diff --git a/src/process/UpxToConsole.cpp b/src/process/UpxToConsole.cpp index f78a3499..b6bf08ef 100644 --- a/src/process/UpxToConsole.cpp +++ b/src/process/UpxToConsole.cpp @@ -4,7 +4,7 @@ namespace xo { namespace process { - ref::rp + rp UpxToConsole::make() { return new UpxToConsole(); diff --git a/utest/RealizationSource.test.cpp b/utest/RealizationSource.test.cpp index 5d8e98c1..ae6aeb0c 100644 --- a/utest/RealizationSource.test.cpp +++ b/utest/RealizationSource.test.cpp @@ -20,7 +20,6 @@ namespace xo { using xo::process::BrownianMotion; using xo::rng::xoshiro256ss; using xo::reactor::SinkToConsole; - using xo::ref::rp; using xo::time::timeutil; using xo::time::seconds; using xo::time::utc_nanos; @@ -98,7 +97,7 @@ namespace xo { log && log("create brownian motion process 'bm'.."); - ref::rp> bm + rp> bm = BrownianMotion::make(t0, 0.30 /*sdev -- annualized volatility*/, 12345678UL /*seed*/);