xo-process: bugfix: track xo::ref::rp -> xo::rp

This commit is contained in:
Roland Conybeare 2024-09-14 18:28:22 -05:00
commit 7cfc560f02
12 changed files with 38 additions and 39 deletions

View file

@ -12,7 +12,7 @@ namespace xo {
namespace process {
class AbstractRealization : public reflect::SelfTagging {
public:
virtual ref::rp<AbstractStochasticProcess> stochastic_process() const = 0;
virtual rp<AbstractStochasticProcess> stochastic_process() const = 0;
}; /*AbstractRealization*/
} /*namespace process*/
} /*namespace xo*/

View file

@ -36,7 +36,7 @@ namespace xo {
// ----- needed by Realization2<double> -----
virtual ref::rp<Realization2<double>> make_realization() override = 0;
virtual rp<Realization2<double>> make_realization() override = 0;
// ----- inherited from StochasticProcess<double> -----
@ -83,7 +83,7 @@ namespace xo {
* seed. initialize pseudorandom-number generator
*/
template<class Seed>
static ref::rp<BrownianMotion<RngEngine>> make(utc_nanos t0,
static rp<BrownianMotion<RngEngine>> make(utc_nanos t0,
double sdev,
Seed const & seed)
{
@ -121,7 +121,7 @@ namespace xo {
// ----- inherited from Realizable2Process<> -----
virtual ref::rp<Realization2<double>> make_realization() override {
virtual rp<Realization2<double>> make_realization() override {
rstate_type rs0 = std::make_pair(this->t0(),
this->t0_value());

View file

@ -26,7 +26,7 @@ namespace xo {
using TaggedRcptr = reflect::TaggedRcptr;
public:
static ref::rp<ExpProcess> make(double scale,
static rp<ExpProcess> make(double scale,
ref::brw<StochasticProcess<double>> exp_proc) {
return new ExpProcess(scale, exp_proc);
} /*make*/
@ -95,7 +95,7 @@ namespace xo {
*/
double scale_ = 1.0;
/* exponentiate this process */
ref::rp<StochasticProcess<double>> exponent_process_;
rp<StochasticProcess<double>> exponent_process_;
}; /*ExpProcess*/
} /*namespace process*/
} /*namespace xo*/

View file

@ -17,10 +17,10 @@ namespace xo {
public:
/* log-normal process starting at (t0, x0) */
template<typename RngEngine, typename Seed>
static ref::rp<ExpProcess> make(utc_nanos t0, double x0,
static rp<ExpProcess> make(utc_nanos t0, double x0,
double sdev, Seed const & seed) {
ref::rp<BrownianMotion<RngEngine>> bm
rp<BrownianMotion<RngEngine>> bm
= BrownianMotion<RngEngine>::make(t0, sdev, seed);
return ExpProcess::make(x0 /*scale*/, bm);

View file

@ -39,7 +39,7 @@ namespace xo {
template<typename T>
class Realizable2Process : public StochasticProcess<T> {
public:
virtual ref::rp<Realization2<T>> make_realization() = 0;
virtual rp<Realization2<T>> 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

View file

@ -33,7 +33,7 @@ namespace xo {
using KnownRange = decltype(std::views::all(KnownMap()));
public:
static ref::rp<Realization> make(ref::brw<StochasticProcess<T>> p) {
static rp<Realization> make(ref::brw<StochasticProcess<T>> p) {
return new Realization(p);
} /*make*/
@ -58,7 +58,7 @@ namespace xo {
private:
/* stochastic process from which this realization is sampled */
ref::rp<StochasticProcess<T>> process_;
rp<StochasticProcess<T>> process_;
/* process value (for this realization) has been established (sampled)
* at each time t in {.known_map[].first}

View file

@ -46,13 +46,13 @@ namespace xo {
using nanos = xo::time::nanos;
public:
ProcessRealization2(Rstate const & rstate, ref::rp<Process> const & process)
ProcessRealization2(Rstate const & rstate, rp<Process> const & process)
: rstate_{rstate}, process_{process} {}
ProcessRealization2(Rstate && rstate, ref::rp<Process> const & process)
ProcessRealization2(Rstate && rstate, rp<Process> const & process)
: rstate_{std::move(rstate)}, process_{process} {}
Rstate const & rstate() const { return rstate_; }
ref::rp<Process> const & process() const { return process_; }
rp<Process> 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<AbstractStochasticProcess> stochastic_process() const override {
virtual rp<AbstractStochasticProcess> 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> process_;
rp<Process> process_;
}; /*ProcessRealization2*/
} /*namespace process*/

View file

@ -39,8 +39,8 @@ namespace xo {
xtag("p", this));
} /*dtor*/
static ref::rp<RealizationSourceBase>
make(ref::rp<RealizationTracer<T>> const & tracer,
static rp<RealizationSourceBase>
make(rp<RealizationTracer<T>> const & tracer,
nanos ev_interval_dt,
EventSink const & ev_sink)
{
@ -60,7 +60,7 @@ namespace xo {
} /*make*/
#ifdef NOT_IN_USE
static ref::rp<RealizationSimSource> make(ref::rp<RealizationTracer<T>> tracer,
static rp<RealizationSimSource> make(rp<RealizationTracer<T>> tracer,
nanos ev_interval_dt,
EventSink && ev_sink)
{
@ -142,7 +142,7 @@ namespace xo {
return 1;
} /*deliver_one*/
virtual CallbackId attach_sink(ref::rp<reactor::AbstractSink> const & /*sink*/) override {
virtual CallbackId attach_sink(rp<reactor::AbstractSink> const & /*sink*/) override {
/* see RealizationSource */
assert(false);
return CallbackId();
@ -168,13 +168,13 @@ namespace xo {
}
protected:
RealizationSourceBase(ref::rp<RealizationTracer<T>> const & tracer,
RealizationSourceBase(rp<RealizationTracer<T>> 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<RealizationTracer<T>> const & tracer,
RealizationSourceBase(rp<RealizationTracer<T>> 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<RealizationTracer<T>> tracer_;
rp<RealizationTracer<T>> 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<RealizationSource<EventType, T>> make(ref::rp<RealizationTracer<T>> const & tracer,
static rp<RealizationSource<EventType, T>> make(rp<RealizationTracer<T>> const & tracer,
nanos ev_interval_dt)
{
return new RealizationSource<EventType, T>(tracer, ev_interval_dt);
} /*make*/
CallbackId add_callback(ref::rp<reactor::Sink1<EventType>> const & cb) {
CallbackId add_callback(rp<reactor::Sink1<EventType>> 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<reactor::AbstractSink> const & sink) override {
virtual CallbackId attach_sink(rp<reactor::AbstractSink> const & sink) override {
/* -------
* WARNING
* -------
@ -265,7 +265,7 @@ namespace xo {
//scope lscope(c_self_name);
//lscope.log(xtag("T", reflect::type_name<T>()));
ref::rp<reactor::Sink1<EventType>> event_sink
rp<reactor::Sink1<EventType>> event_sink
= reactor::Sink1<EventType>::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<RealizationTracer<T>> const & tracer,
RealizationSource(rp<RealizationTracer<T>> const & tracer,
nanos ev_interval_dt)
: RealizationSourceBase
<EventType, T,

View file

@ -32,7 +32,7 @@ namespace xo {
using nanos = xo::time::nanos;
public:
static ref::rp<RealizationTracer> make(ref::rp<Process> const & p) {
static rp<RealizationTracer> make(rp<Process> 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<Process> const & process() const { return process_; }
rp<Process> 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<Process> const & p)
RealizationTracer(rp<Process> 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> process_;
rp<Process> process_;
}; /*RealizationTracer*/
} /*namespace process*/

View file

@ -17,7 +17,7 @@ namespace xo {
public:
UpxToConsole();
static ref::rp<UpxToConsole> make();
static rp<UpxToConsole> make();
}; /*UpxToConsole*/
} /*namespace process*/
} /*namespace xo*/

View file

@ -4,7 +4,7 @@
namespace xo {
namespace process {
ref::rp<UpxToConsole>
rp<UpxToConsole>
UpxToConsole::make()
{
return new UpxToConsole();

View file

@ -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<BrownianMotion<xoshiro256ss>> bm
rp<BrownianMotion<xoshiro256ss>> bm
= BrownianMotion<xoshiro256ss>::make(t0,
0.30 /*sdev -- annualized volatility*/,
12345678UL /*seed*/);