Core Module
-
class AggregatePayments
- #include <payments.h>
Represent the payment matrices of a subportfolio.
Public Functions
-
inline AggregatePayments(size_t size)
-
inline AggregatePayments(size_t size, const std::set<int> &_payment_types_used)
-
inline const std::set<int> &get_payment_types_used() const
-
inline int get_max_payment_index_used() const
-
inline void add_cond_state_payment(int state_index, int payment_type_index, double *payment_matrix, const int num_policies, const int num_timesteps)
Inject a payment matrix from python.
- Parameters
state_index –
payment_type_index –
payment_matrix –
num_policies –
num_timesteps –
-
inline void add_transition_payment(int state_index_from, int state_index_to, int payment_type_index, double *payment_matrix, const int num_policies, const int num_timesteps)
Inject a payment matrix from python.
- Parameters
state_index_from – State before the transition
state_index_to – State after the transition
payment_type_index –
payment_matrix –
num_policies –
num_timesteps –
-
inline void add_single_record_payments(shared_ptr<unordered_map<int, StateConditionalRecordPayout>> single_record_payments, size_t ind)
use internally in C++ when splitting the payments into groups (for the parallelization)
-
inline void add_single_record_transition_payments(shared_ptr<unordered_map<pair<int, int>, TransitionConditionalRecordPayout>> single_record_payments, size_t ind)
use internally in C++ when splitting the payments into groups (for the parallelization)
-
inline shared_ptr<unordered_map<int, StateConditionalRecordPayout>> get_single_record_payments(size_t index) const
-
inline shared_ptr<unordered_map<pair<int, int>, TransitionConditionalRecordPayout>> get_single_record_transition_payments(size_t index) const
Private Members
-
vector<shared_ptr<unordered_map<int, StateConditionalRecordPayout>>> state_payouts
-
vector<shared_ptr<unordered_map<pair<int, int>, TransitionConditionalRecordPayout>>> transition_payouts
-
int max_payment_type_index_used = -1
-
std::set<int> payment_types_used
-
size_t _size
-
inline AggregatePayments(size_t size)
-
class CAssumptionSet
- #include <assumption_sets.h>
Container to hold the providers required for a run of a policy or a portfolio, houses a matrix of providers.
Public Functions
-
inline CAssumptionSet(unsigned dim)
Construct a new CAssumptionSet object.
- Parameters
dim – Number of states in the State-Model
-
inline void clone_into(CAssumptionSet &other) const
Copy this assumption by making a deep copy of the underlying data.
-
inline void slice_into(const vector<int> &indices, CAssumptionSet &other) const
Perform a slicing operation on all provider objects contained in this object.
-
inline unsigned get_dimension() const
Returns the number of dimensions of the state model.
-
inline string get_provider_info(int r, int c) const
Returns a description of the provider in row r and column c.
-
inline void set_provider(int row, int col, PtrCBaseRateProvider prvdr)
-
inline void get_relevant_risk_factor_indexes(vector<bool> &relevant_risk_factors)
Return a bool vector of the length of the risk factors indicating if the assumptions set depends on the risk factor or not
-
inline void get_single_rateset(const vector<int> &rf_indexes, double *rates_ext) const
Populate the an external array with the matrix of rates selected by the index vector passed in.
-
inline CAssumptionSet(unsigned dim)
-
class CBaseAssumptions
Public Functions
-
inline CBaseAssumptions()
-
inline CBaseAssumptions &set_mortality(double *vec)
-
inline CBaseAssumptions &set_lapse(double *vec)
-
inline CBaseAssumptions &set_premium_rates(double *vec)
-
inline std::shared_ptr<std::vector<double>> get_mortality_rates(int age, double multiplier, int select_years) const
-
inline CBaseAssumptions()
-
class CBaseRateProvider
- #include <providers.h>
Abstract base class for the assumptions providers.
Subclassed by CConstantRateProvider, CStandardRateProvider
Public Functions
-
inline virtual ~CBaseRateProvider()
-
inline virtual void add_risk_factor(CRiskFactors rf)
-
inline virtual double get_rate(const vector<int> &indices) const
-
inline virtual void get_rates(double *out_array, size_t length, const vector<int*> &indices) const
-
inline const vector<CRiskFactors> &get_risk_factors() const
-
inline virtual string to_string() const
-
virtual shared_ptr<CBaseRateProvider> clone() const = 0
-
virtual void slice_into(const vector<int> &indices, CBaseRateProvider *other) const = 0
Protected Attributes
-
vector<CRiskFactors> risk_factors
-
inline virtual ~CBaseRateProvider()
-
class CConstantRateProvider : public CBaseRateProvider
Public Functions
-
inline CConstantRateProvider(double rate)
-
inline virtual ~CConstantRateProvider()
-
inline virtual double get_rate(const vector<int> &indices) const override
-
inline virtual void get_rates(double *out_array, size_t length, const vector<int*> &indices) const override
-
inline virtual string to_string() const override
-
inline virtual void slice_into(const vector<int> &indices, CBaseRateProvider *other) const override
-
inline virtual shared_ptr<CBaseRateProvider> clone() const override
Protected Attributes
-
double val = 0.0
-
inline CConstantRateProvider(double rate)
-
struct ConditionalPayout
Public Functions
-
inline string to_string()
Public Members
-
int payment_index
type of payment
-
vector<double> cond_payments
Sequence of conditonal payments.
-
inline string to_string()
-
class CPolicy
- #include <portfolio.h>
Represents a seriatim record.
Public Functions
-
inline int64_t get_cession_id() const
return the technical policy ID
-
inline const PeriodDate &get_issue_date() const
Return the issue date.
-
inline const PeriodDate &get_dob() const
Get date of birth.
-
inline bool has_disablement_date() const
Return if the policy had a disabled date.
-
inline CPolicy(int64_t cession_id, int64_t dob_long, int64_t issue_date_long, int64_t disablement_date_long, int32_t gender, int32_t smoker_status, double sum_insured, double reserving_rate, string product, int initial_state)
Construct a new CPolicy object.
- Parameters
cession_id – Technical ID of the record.
dob_long – Date of birth in the format YYYYMMDD
issue_date_long – Date of policy issue in the format YYYYMMDD
disablement_date_long – Date of disablement of the policy in format YYYYMMDD
gender – Value for the selector of the risk factor Gender.
smoker_status – Value for the selector of the risk factor SmokerStatus.
sum_insured – Insured amount.
reserving_rate – (Constant) reserving rate that shall be used for this policy.
product – Product code.
initial_state – State number (zero based) the policy is in at the start.
-
inline string to_string() const
Protected Attributes
-
int64_t cession_id
-
PeriodDate issue_date = PeriodDate(0, 0, 0)
-
PeriodDate dob = PeriodDate(0, 0, 0)
-
bool _has_disablement_date
-
PeriodDate date_dis = PeriodDate(0, 0, 0)
-
int gender
-
int smoker_status
-
double sum_insured
-
double reserving_rate
-
string product
-
int initial_state
-
inline int64_t get_cession_id() const
-
class CPolicyPortfolio
- #include <portfolio.h>
A portfolio of policies.
Public Functions
-
inline CPolicyPortfolio(short ptf_year, short ptf_month, short ptf_day)
Construct a new CPolicyPortfolio object.
- Parameters
ptf_year – Year of the portfolio date
ptf_month – Month of the portfolio date
ptf_day – Day of the portfolio date
-
inline CPolicyPortfolio(PeriodDate pd)
Construct a new CPolicyPortfolio object.
- Parameters
pd – The portfolio date
-
inline const PeriodDate &get_portfolio_date()
Return the portfolio date.
-
inline const vector<shared_ptr<CPolicy>> &get_policies()
Return the vector of policies.
-
inline size_t size() const
Return the size of the portfolio.
-
inline void add(shared_ptr<CPolicy> record_ptr)
Add a policy to the portfolio.
-
inline const CPolicy &at(size_t j) const
Get the policy at the given index.
Protected Functions
-
inline void reserve(size_t capa)
Protected Attributes
-
vector<shared_ptr<CPolicy>> _policies
-
size_t _num_policies = 0
-
PeriodDate _portfolio_date
Friends
- friend class CPortfolioBuilder
-
inline CPolicyPortfolio(short ptf_year, short ptf_month, short ptf_day)
-
class CPortfolio
Public Functions
-
inline CPortfolio()
-
inline void set_portfolio_name(std::string name)
-
inline std::vector<std::shared_ptr<CSeriatimRecord>> &get_records()
-
inline size_t len()
-
inline void add(const std::shared_ptr<CSeriatimRecord> &ref)
-
inline void reserve(size_t n)
-
inline const std::shared_ptr<CSeriatimRecord> get(int index)
-
inline CPortfolio()
-
class CPortfolioBuilder
- #include <portfolio.h>
Builder class that allows to create portfolios from a number of appropriately typed vectors.
Public Functions
-
inline CPortfolioBuilder(size_t s, string _product)
Construct a new CPortfolioBuilder object.
- Parameters
s – The required size (number of records) in the portfolio
_product – The product code applicable throughout the portfolio.
-
inline CPortfolioBuilder &set_portfolio_date(short ptf_year, short ptf_month, short ptf_day)
-
inline CPortfolioBuilder &set_cession_id(int64_t *ptr_cession_id)
-
inline CPortfolioBuilder &set_date_of_birth(int64_t *ptr_dob)
-
inline CPortfolioBuilder &set_issue_date(int64_t *ptr_issue_date)
-
inline CPortfolioBuilder &set_date_disablement(int64_t *ptr_disablement_date)
-
inline CPortfolioBuilder &set_gender(int32_t *ptr_gender)
-
inline CPortfolioBuilder &set_smoker_status(int32_t *ptr_smoker_status)
-
inline CPortfolioBuilder &set_sum_insured(double *ptr_sum_insured)
-
inline CPortfolioBuilder &set_reserving_rate(double *ptr_reserving_rate)
-
inline CPortfolioBuilder &set_initial_state(int16_t *ptr_initial_state)
-
shared_ptr<CPolicyPortfolio> build()
Create a new portfolio object from the given input vectors.
Private Members
-
size_t num_policies = 0
-
bool has_portfolio_date = false
-
short ptf_year
-
short ptf_month
-
short ptf_day
-
string product
-
bool has_cession_ids = false
-
int64_t *ptr_cession_id
-
bool has_dob = false
-
int64_t *ptr_dob
-
bool has_issue_dates = false
-
int64_t *ptr_issue_date
-
bool has_dis_dates = false
-
int64_t *ptr_disablement_date
-
bool has_gender = false
-
int32_t *ptr_gender
-
bool has_smoker_status = false
-
int32_t *ptr_smoker_status
-
bool has_sum_insured = false
-
double *ptr_sum_insured
-
bool has_reserving_rate = false
-
double *ptr_reserving_rate
-
bool has_initial_state = false
-
int16_t *ptr_initial_state
-
inline CPortfolioBuilder(size_t s, string _product)
-
class CRunConfig
- #include <run_config.h>
Container with configuration parameters.
Public Functions
-
inline CRunConfig(unsigned _dim, TimeStep time_step, int years_to_simulate, int num_cpus, bool use_multicore, shared_ptr<CAssumptionSet> _be_assumptions, int max_age)
Construct a new CRunConfig object.
- Parameters
_dim – Dimension of the state model
time_step – Time scale on which to calculate
years_to_simulate – Number of years to project into the future
num_cpus – Number of cpus to use if
use_multicore=true
use_multicore – Use multicore flag
_be_assumptions – Best estimate assumptions
-
inline void add_assumption_set(shared_ptr<CAssumptionSet> as)
Add an auxiliary assumption set.
-
inline const CAssumptionSet &get_be_assumptions() const
Get the main assumption set.
-
inline const vector<shared_ptr<CAssumptionSet>> &get_other_assumptions() const
Get the other auxilary assumption sets.
Private Members
-
unsigned int dimension
< dimension of the state model
Time scale on which to calculate
-
TimeStep _time_step
Time scale on which to calculate.
-
int _years_to_simulate
Number of cpus to use.
-
int _num_cpus
Use multicore flag.
-
bool _use_multicore
maximum age in projection in years
-
int _max_age
-
shared_ptr<CAssumptionSet> be_assumptions
-
shared_ptr<vector<shared_ptr<CAssumptionSet>>> other_assumptions = make_shared<vector<shared_ptr<CAssumptionSet>>>()
-
inline CRunConfig(unsigned _dim, TimeStep time_step, int years_to_simulate, int num_cpus, bool use_multicore, shared_ptr<CAssumptionSet> _be_assumptions, int max_age)
-
class CSeriatimRecord
Public Functions
-
inline int get_cession_id() const
-
inline std::string get_product() const
-
inline std::string get_gender() const
-
inline int get_issue_age() const
-
inline int get_issue_year() const
-
inline int get_issue_month() const
-
inline int get_issue_day() const
-
inline int get_dob_year() const
-
inline int get_dob_month() const
-
inline int get_dob_day() const
-
inline int get_coverage_years() const
-
inline double get_sum_insured() const
-
inline int get_portfolio_year() const
-
inline int get_portfolio_month() const
-
inline int get_portfolio_day() const
-
inline int get_age_projection_start() const
-
inline CSeriatimRecord()
-
inline CSeriatimRecord(int cession_id, const std::string &product, int gender, long dob_long, long issue_date_long, int coverage_years, long long sum_insured, long portfolio_date_long)
-
inline ~CSeriatimRecord()
-
inline std::string to_string() const
-
inline int get_cession_id() const
-
class CStandardRateProvider : public CBaseRateProvider
Public Functions
-
inline CStandardRateProvider()
-
inline virtual ~CStandardRateProvider()
-
virtual shared_ptr<CBaseRateProvider> clone() const override
-
inline int get_dimension() const
-
inline int get_capacity() const
-
inline int size() const
-
inline void get_values(double *ext_vals) const
-
void set_values(vector<int> &shape_vec_in, vector<int> &offsets_in, double *ext_vals)
-
inline virtual void add_risk_factor(CRiskFactors rf) override
-
virtual string to_string() const override
-
inline virtual double get_rate(const vector<int> &indices) const override
-
inline virtual void get_rates(double *out_array, size_t length, const vector<int*> &indices) const
-
virtual shared_ptr<CStandardRateProvider> slice(const vector<int> &indices) const
Given a vector of indexes take only the dimensions where the values is “-1” in full.
-
virtual void slice_into(const vector<int> &indices, CBaseRateProvider *other) const override
Protected Functions
-
void set_strides()
Protected Attributes
-
shared_ptr<double[]> values = nullptr
-
bool has_values = false
-
int number_values = 0
-
int capacity = 0
-
vector<int> shape_vec
-
vector<int> strides
-
vector<int> offsets
-
unsigned int dimensions = 0
-
inline CStandardRateProvider()
-
class FILELog : public Log<Output2FILE>
-
class GenericMortalityProduct
Subclassed by SimpleTermProduct
Public Functions
-
inline GenericMortalityProduct(CSeriatimRecord &rec)
-
inline virtual double get_benefit_if_died(int year, int month)
-
inline virtual double get_benefit_if_survived(int year, int month)
-
inline virtual double get_benefit_if_lapsed(int year, int month)
-
inline virtual bool is_premium_due(int year, int month)
Protected Attributes
-
CSeriatimRecord &_rec
-
inline GenericMortalityProduct(CSeriatimRecord &rec)
-
template<typename T>
class Log -
Public Static Functions
-
static TLogLevel &ReportingLevel()
Protected Attributes
-
std::ostringstream os
-
static TLogLevel &ReportingLevel()
-
class MetaRunner
- #include <runner.h>
The MetaRunner object. Splits the portfolio and triggers a (possibly) parallelized run by instantiating several runner objects, starting them and combining their results.
Public Functions
-
inline MetaRunner(const CRunConfig &run_config, const shared_ptr<CPolicyPortfolio> ptr_portfolio, const shared_ptr<TimeAxis> ta, const int num_state_payment_cols)
Construct a new Meta Runner object.
- Parameters
run_config – Run configutaion object
ptr_portfolio – Pointer to portfolio of policies.
ta – TimeAxis object to be used for the calculation.
-
int get_num_groups() const
Calculates into how many sub-portfolios the portfolio will be split into depending on the cpu_count/use_multicore settings in the config and the portfolio size.
-
void run(RunResult &run_result, const AggregatePayments &agg_payments) const
Calculate the result and store it in the reference passed in.
Protected Attributes
-
const CRunConfig &_run_config
-
const shared_ptr<CPolicyPortfolio> _ptr_portfolio
-
const shared_ptr<TimeAxis> _ta
-
const int _num_state_payment_cols
-
inline MetaRunner(const CRunConfig &run_config, const shared_ptr<CPolicyPortfolio> ptr_portfolio, const shared_ptr<TimeAxis> ta, const int num_state_payment_cols)
-
class MortalityProductDefinition
Protected Attributes
-
int premium_payment_mode
-
int lapse_possibilites
-
int lapse_benefit_type
-
int death_benefit_type
-
int maturity_benefit_type
-
int escalation_type
-
double fixed_escalation_perc
-
int premium_payment_mode
-
class Output2FILE
Public Static Functions
-
static inline FILE *&Stream()
-
static inline void Output(const std::string &msg)
-
static inline FILE *&Stream()
-
struct PeriodDate
- #include <time_axis.h>
A simple date structure.
Public Functions
-
inline PeriodDate(short y, short m, short d)
-
inline PeriodDate(const PeriodDate &o)
-
inline short get_year() const
-
inline short get_month() const
-
inline short get_day() const
-
inline string to_string() const
-
inline void set(short y, short m, short d)
-
inline PeriodDate &operator=(const PeriodDate &o)
-
inline bool is_leap_year() const
-
inline bool _before(short y, short m, short d) const
Return true of this date is strictly before the passed in date tuple.
-
inline bool operator<(const PeriodDate &o) const
-
inline bool operator==(const PeriodDate &o) const
-
inline bool operator<=(const PeriodDate &o) const
-
inline int set_next_day()
Update the value to the next day.
-
inline int set_next_end_of_month()
Update the value to the next end of a month.
-
inline int set_next_end_of_quarter()
Update the value to the next end of a quarter.
-
inline int set_next_end_of_year()
Update the value to the next end of a year.
-
inline void set_from_long(int64_t dt_lng)
Set the date long which is encoded as YYYYMMDD.
- Parameters
dt_lng –
Public Members
-
short year
-
short month
-
short day
-
inline PeriodDate(short y, short m, short d)
-
class ProjectionStateMatrix
- #include <record_projector.h>
Methods to calculate the policy state probabilities, data storage is managed externally.
Public Functions
-
inline ProjectionStateMatrix(int num_timesteps, int num_states)
Construct a new Projection State Matrix object.
- Parameters
num_timesteps – Number of timesteps
num_states – Number of possible states
-
ProjectionStateMatrix() = delete
-
ProjectionStateMatrix(const ProjectionStateMatrix&) = delete
-
ProjectionStateMatrix(ProjectionStateMatrix&&) = delete
-
inline void initialize_states(double *state_probs, double *state_vols, double *probs_mvms, double *vol_mvms, int start_state, double vol)
Set the data pointer in that method and reset the state matrix (fill with zero) and set the initial state in the first row.
- Parameters
state_probs – Pointer to the data array
start_state – Initial state the record is in
-
inline double *get_state_probs(int time_index)
-
inline double *get_probs_mvms(int time_index)
-
inline void update_state(int index_last, double *be_a_ts, double vol)
Calculate the probabilities of the next state.
- Parameters
index_last – Index (row) of the last valid assumption set
be_a_ts – (Dependent) assumptions to be applied for the current timestep
-
void trivial_runoff(int time_index)
Trivial completion of the projection without further movements.
- Parameters
time_index – First time index which is copied from the the one preceding it.
-
void print_state_probs(int time_index) const
Private Members
-
double *_state_probs = nullptr
-
double *_state_vols = nullptr
-
double *_probs_mvms = nullptr
-
double *_vol_mvms = nullptr
-
int _num_timesteps
-
int _num_states
-
int _size
-
inline ProjectionStateMatrix(int num_timesteps, int num_states)
-
class RecordProjector
- #include <record_projector.h>
Functionality to project cash flows for a single record at a time.
Public Functions
-
inline RecordProjector(const CRunConfig &run_config, const TimeAxis &ta)
-
void run(int runner_no, int record_count, const CPolicy &policy, RunResult &result, const PeriodDate &portfolio_date, const shared_ptr<unordered_map<int, StateConditionalRecordPayout>> &record_payments, const shared_ptr<unordered_map<pair<int, int>, TransitionConditionalRecordPayout>> &transition_payments)
Create the projection result for one policy.
- Parameters
runner_no – Number of the runner instance.
record_count – Number of record in batch for this runner.
policy – The record to project
result – Container for the result
portfolio_date – portfolio date
record_payments – the state conditional payments
Private Functions
-
void adjust_assumptions_simple(int days)
-
inline void set_relevant_risk_factors(vector<bool> &relevant_risk_factors)
Mark the relevant risk factors as true.
-
inline void clear()
-
inline void slice_assumptions(const CPolicy &policy)
-
inline void calculate_reserves(double reserving_interest, int time_index)
Calculation of the reserves.
- Parameters
reserving_interest –
time_index – Is the latest time index that is needed to calculate the reserves
Private Members
-
const CRunConfig &_run_config
-
const TimeAxis &_ta
-
const unsigned int _dimension
-
const vector<PeriodDate> &_start_dates = _ta.get_start_dates()
-
const vector<PeriodDate> &_end_dates = _ta.get_end_dates()
-
const vector<int> &_period_lengths = _ta.get_period_length_in_days()
-
CAssumptionSet _record_be_assumptions
-
vector<shared_ptr<CAssumptionSet>> _record_other_assumptions
-
unique_ptr<double[]> be_a_yearly
-
unique_ptr<double[]> be_a_time_step_dependent
-
unique_ptr<double[]> be_a_time_step_dependent_collect
-
vector<int> risk_factors_current = vector<int>(NUMBER_OF_RISK_FACTORS)
-
vector<int> risk_factors_last_used = vector<int>(NUMBER_OF_RISK_FACTORS, -1)
-
unique_ptr<ProjectionStateMatrix> _be_states
the best estimate states
-
unique_ptr<double[]> reserves_bom
-
unique_ptr<double[]> cfs_bom_per_state_for_res
-
unique_ptr<double[]> cf_eom_per_state_change_for_res
-
inline RecordProjector(const CRunConfig &run_config, const TimeAxis &ta)
-
class Runner
- #include <runner.h>
Provides an interface to the calculation functionality for a portfolio that will be made in one sequential batch.
Public Functions
-
inline Runner(int runner_no, const shared_ptr<CPolicyPortfolio> ptr_portfolio, const CRunConfig &run_config, const shared_ptr<TimeAxis> ta, int num_state_payment_cols)
Construct a new Runner object.
- Parameters
runner_no – Number of this runner.
ptr_portfolio – The (sub-)portfolio of type CPolicyPortfolio that shall be valued.
run_config – CRunConfig configuration object.
ta – Time axis to be used for the simulation.
-
void run(RunResult &run_result, const AggregatePayments &payments)
Starts the main loop over the policies in the portfolio and combines the results.
Private Members
-
int _runner_no
< Number of this runner.
Run configuration object.
-
const CRunConfig &_run_config
The (sub-)portfolio that shall be valued.
-
const shared_ptr<CPolicyPortfolio> _ptr_portfolio
Time axis to be used for the simulation.
-
const shared_ptr<TimeAxis> _ta
projection engine for single policy
-
RecordProjector _record_projector
the result of the single record
-
RunResult _record_result
-
const int _num_state_payment_cols
-
inline Runner(int runner_no, const shared_ptr<CPolicyPortfolio> ptr_portfolio, const CRunConfig &run_config, const shared_ptr<TimeAxis> ta, int num_state_payment_cols)
-
class RunnerInterface
- #include <runner.h>
RunnerInterface is the external run interface.
Public Functions
-
inline RunnerInterface(const CRunConfig &run_config, shared_ptr<CPolicyPortfolio> ptr_portfolio)
-
inline shared_ptr<TimeAxis> get_time_axis() const
-
inline void add_cond_state_payment(int state_index, int payment_type_index, double *payment_matrix)
-
inline void add_transition_payment(int state_index_from, int state_index_to, int payment_type_index, double *payment_matrix)
-
inline unique_ptr<RunResult> run() const
Start the calculation run.
- Returns
Pointer to result
Private Members
-
const CRunConfig &_run_config
-
const shared_ptr<CPolicyPortfolio> _ptr_portfolio
-
const shared_ptr<TimeAxis> _p_time_axis
-
AggregatePayments agg_payments
-
inline RunnerInterface(const CRunConfig &run_config, shared_ptr<CPolicyPortfolio> ptr_portfolio)
-
struct RunParametersTerm
Public Members
-
int steps_per_year
-
int shifted_age
-
int steps_per_year
-
class RunResult
- #include <run_result.h>
Result container that is used to store results at various granularities and provides for aggregation functinality of partial results.
Public Functions
-
inline RunResult(int num_states, shared_ptr<TimeAxis> p_time_axis, int num_state_payment_cols)
Construct a new Run Result object.
- Parameters
num_states – Number of states in states model
p_time_axis – Pointer to the time axis object
-
inline vector<string> get_result_header_names()
Return a list of strings containing the headers of the external results table.
-
inline double *get_be_state_probs_ptr()
Return a pointer to the space where to store the projected state probabilities.
-
inline double *get_be_state_vols_ptr()
Return a pointer to the space where to store the projected volume results.
-
inline double *get_be_prob_mvms_ptr()
Return a pointer to the space where to store the projected state probability movements.
-
inline double *get_be_vol_mvms_ptr()
Return a pointer to the space where to store the projected state volume movements.
-
inline double *get_state_cond_payments_ptr()
Return a pointer to the space where to store the cash flows.
-
inline void set_state_cond_payments(size_t time_index, size_t cf_type_index, double val)
Set the value for the state conditional payment.
- Parameters
time_index –
cf_type_index –
val –
-
void reset()
Reset the result, zeroises the allocated arrays.
-
void add_result(const RunResult &other_res)
Add another result to this one.
-
void copy_results(double *ext_result, int row_num, int col_num) const
Copy results to an external array.
-
inline int size() const
Return the number of rows in the result set.
Private Functions
-
void copy_time_axis(double *ext_result, int rows_num, int col_num, int start_col) const
Private Members
-
int _num_states
-
int _num_timesteps
-
shared_ptr<TimeAxis> _ta = nullptr
-
unique_ptr<double[]> _be_state_probs = nullptr
projected state probabilities and probability movements
-
unique_ptr<double[]> _be_prob_movements = nullptr
-
unique_ptr<double[]> _be_state_vols = nullptr
projected state volume and volume movements
-
unique_ptr<double[]> _be_vol_movements = nullptr
-
unique_ptr<double[]> _state_cond_payments = nullptr
state conditional payments
-
int _num_state_payment_cols
-
inline RunResult(int num_states, shared_ptr<TimeAxis> p_time_axis, int num_state_payment_cols)
-
class SimpleTermProduct : public GenericMortalityProduct
Public Functions
-
inline SimpleTermProduct(CSeriatimRecord &rec)
-
inline virtual double get_benefit_if_died(int year, int month)
-
inline virtual double get_benefit_if_survived(int year, int month)
-
inline virtual double get_benefit_if_lapsed(int year, int month)
-
inline virtual bool is_premium_due(int year, int month)
-
inline SimpleTermProduct(CSeriatimRecord &rec)
-
struct StateConditionalRecordPayout
- #include <payments.h>
Payments that are due when in a given state.
Public Functions
-
inline StateConditionalRecordPayout(int si)
-
inline StateConditionalRecordPayout(StateConditionalRecordPayout &&o)
-
inline string to_string()
-
inline StateConditionalRecordPayout(int si)
-
class TimeAxis
- #include <time_axis.h>
TimeAxis object, contains vectors with start and end of each discrete poeriod of time.
Public Functions
-
TimeAxis(TimeStep time_step, int years_to_simulate, short ptf_year, short ptf_month, short ptf_day)
Construct a new Time Axis object.
- Parameters
time_step – Which time step should be applied.
years_to_simulate – Number of years to project.
ptf_year – Year of the portfolio. inforce date.
ptf_month – Month of the portfolio inforce date.
ptf_day – Day of the portfolio inforce date.
-
inline int get_portfolio_year() const
-
inline int get_portfolio_month() const
-
inline int get_portfolio_day() const
-
inline const PeriodDate &end_at(int k) const
-
inline const PeriodDate &start_at(int k) const
-
inline int duration_at(int k) const
-
inline size_t get_length() const
-
inline const vector<PeriodDate> &get_start_dates() const
-
inline const vector<PeriodDate> &get_end_dates() const
-
inline const vector<int> &get_period_length_in_days() const
-
inline void get_years(int16_t *arr) const
-
inline void get_months(int16_t *arr) const
-
inline void get_days(int16_t *arr) const
-
inline void get_quarters(int16_t *arr) const
Private Members
-
TimeStep _time_step
-
int _years_to_simulate
-
short _ptf_year
-
short _ptf_month
-
short _ptf_day
-
vector<PeriodDate> the_start_dates
-
vector<PeriodDate> the_end_dates
-
vector<int> period_length_in_days
-
TimeAxis(TimeStep time_step, int years_to_simulate, short ptf_year, short ptf_month, short ptf_day)
-
struct TransitionConditionalRecordPayout
- #include <payments.h>
Payments that are due when a state transition occurs.
Public Functions
-
inline TransitionConditionalRecordPayout(int state_index_from, int state_index_to)
-
inline TransitionConditionalRecordPayout(TransitionConditionalRecordPayout &&o)
-
inline TransitionConditionalRecordPayout(int state_index_from, int state_index_to)
-
namespace std
- file cmain.cpp
- #include <iostream>#include <fstream>#include “modules/log.h”#include “modules/time_axis.h”#include “modules/providers.h”#include “modules/assumption_sets.h”#include “modules/portfolio.h”#include “modules/run_config.h”#include “modules/run_result.h”#include “modules/runner.h”
File is used during development to value a single policy.
- Author
M. Seehafer
- Version
0.2.0
- Date
2022-08-27
- Copyright
Copyright (c) 2022
Functions
-
void add_policies(CPolicyPortfolio &portfolio)
Adds a number of (hard-coded)policies to the portfolio.
- Parameters
portfolio –
-
void output_results(RunResult &run_result, string outfile_name = "cresults.csv", bool output_to_console = false)
Write the result matrix to a CSV file.
-
void run_calculation(void)
Encapsulate the calculation run. Creates test data, passes them to the runner for processing and outputs the results.
-
int main(void)
- file core_readme.md
- file assumption_sets.h
- #include <vector>#include <memory>#include <array>#include <iostream>#include <string>#include “risk_factors.h”#include “providers.h”
Implementation of the assumption providers.
- Author
M. Seehafer
- Version
0.1
- Date
2022-08-27
- Copyright
Copyright (c) 2022
Typedefs
-
typedef shared_ptr<CBaseRateProvider> PtrCBaseRateProvider
Pointer to a provider object.
-
typedef vector<vector<PtrCBaseRateProvider>> MatPtrCBaseRateProvider
“Matrix” of pointers to provider objects
- file c_valuation.cpp
- #include “c_valuation.h”#include “products.h”#include <string>#include <unordered_map>#include <cmath>
Functions
-
void get_simulation_duration(CSeriatimRecord &rec, int (&simul_duration)[2])
-
int project_record(CSeriatimRecord &rec, double *proj_premiums, double *proj_claims, double *reserve_lg_boy, double *sum_insured_boy, std::shared_ptr<std::vector<double>> p_mort_assump_be, std::shared_ptr<std::vector<double>> p_mort_assump_locgaap, std::shared_ptr<std::vector<double>> p_lapse_assump_be, std::shared_ptr<std::vector<double>> p_lapse_assump_locgaap, std::shared_ptr<std::vector<double>> p_prem_assump_be, std::shared_ptr<std::vector<double>> p_prem_assump_locgaap)
-
void _valuation(shared_ptr<double> output_in, int no_cols, vector<shared_ptr<CSeriatimRecord>> &pf, CBaseAssumptions *be_ass, CBaseAssumptions *locgaap_ass)
-
void valuation(double *output, const int no_cols, CPortfolio *pf, CBaseAssumptions *be_ass, CBaseAssumptions *locgaap_ass)
-
void get_simulation_duration(CSeriatimRecord &rec, int (&simul_duration)[2])
- file c_valuation.h
- #include <string>#include <cctype>#include <algorithm>#include <vector>#include <memory>#include <unordered_map>
Enums
-
enum Gender
Values:
-
enumerator GenderMale
-
enumerator GenderFemale
-
enumerator GenderUnknown
-
enumerator GenderMale
-
enum Product
Values:
-
enumerator ProdTerm
-
enumerator ProdEndowment
-
enumerator ProdOther
-
enumerator ProdTerm
Functions
-
int get_age_at_date(int dob_year, int dob_month, int dob_day, int dt_year, int dt_month, int dt_day)
Calculate the age in (completed) months for a given birthday and the date of interest, returns -1 if not born yet at the given date.
- Parameters
dob_year –
dob_month –
dob_day –
dt_year –
dt_month –
dt_day –
- Returns
int Age in (completed) months.
-
void valuation(double *output, int no_cols, CPortfolio *pf, CBaseAssumptions *be_ass, CBaseAssumptions *locgaap_ass)
-
void get_simulation_duration(CSeriatimRecord &rec, int (&simul_duration)[2])
-
enum Gender
- file log.h
- #include <sstream>#include <string>#include <stdio.h>#include <sys/time.h>
- Author
your name (you@domain.com)
- Version
0.1
- Date
2022-09-03
- Copyright
Found here: https://bitbucket.org/volkanozyilmaz/logcpp/src/master/log.h
Defines
-
FILELOG_DECLSPEC
-
FILELOG_MAX_LEVEL
-
FILE_LOG(level)
-
L_(level)
Enums
-
enum TLogLevel
Values:
-
enumerator lerror
-
enumerator lwarning
-
enumerator linfo
-
enumerator ldebug
-
enumerator ldebug1
-
enumerator ldebug2
-
enumerator ldebug3
-
enumerator ldebug4
-
enumerator lerror
- file payments.h
- #include <vector>#include <utility>#include <unordered_map>#include <memory>#include <iostream>#include <chrono>#include <set>#include “utils.h”
Data structures related to the payments.
- Author
M. Seehafer
- Version
0.2.0
- Date
2022-10-16
- Copyright
Copyright (c) 2022
- file portfolio.h
- #include <memory>#include <vector>#include <iostream>#include <string>#include <cstdint>#include “time_axis.h”
- Author
M. Seehafer
- Version
0.2.0
- Date
2022-08-27
- Copyright
Copyright (c) 2022
Functions
-
int get_age_at_date(int dob_year, int dob_month, int dob_day, int dt_year, int dt_month, int dt_day)
Calculate the age in (completed) months for a given birthday and the date of interest, returns -1 if not born yet at the given date.
- Parameters
dob_year –
dob_month –
dob_day –
dt_year –
dt_month –
dt_day –
- Returns
int Age in (completed) months.
-
inline int get_age_at_date(const PeriodDate &dob, const PeriodDate &date_at)
Calculate the age in (completed) months for a given birthday and the date of interest, returns -1 if not born yet at the given date.
- Parameters
dob – Date of Birthe
date_at – Date at which to calculate the age
- Returns
int Age in (completed) months.
- file products.h
- #include “c_valuation.h”
- file providers.h
- #include <vector>#include <string>#include <iostream>#include <memory>#include <algorithm>#include “risk_factors.h”
CPP implementation of the assumption providers.
- Author
M. Seehafer
- Version
0.1
- Date
2022-08-27
- Copyright
Copyright (c) 2022
Functions
-
template<typename T>
void print_vec(vector<T> v, string name) Convenience function that prints a vector to the console.
- file record_projector.h
- #include <vector>#include <string>#include <iostream>#include <memory>#include <cmath>#include <algorithm>#include <iomanip>#include “utils.h”#include “assumption_sets.h”#include “providers.h”#include “portfolio.h”#include “run_config.h”#include “time_axis.h”#include “run_result.h”#include “risk_factors.h”#include “payments.h”
Projection engine for one record.
- Author
M. Seehafer
- Version
0.1
- Date
2022-08-27
- Copyright
Copyright (c) 2022
- file risk_factors.h
Enums
-
enum class CRiskFactors : int
Values:
-
enumerator Age
-
enumerator Gender
-
enumerator CalendarYear
-
enumerator SmokerStatus
-
enumerator YearsDisabledIfDisabledAtStart
-
enumerator Age
Functions
-
const char *CRiskFactors_names(CRiskFactors rf)
Variables
-
const unsigned NUMBER_OF_RISK_FACTORS = 5
-
enum class CRiskFactors : int
- file run_config.h
- #include <vector>#include <string>#include <iostream>#include <memory>#include “time_axis.h”#include “assumption_sets.h”
Configuration object for a run. The settings stored here control the flow of the calculation and the parameters used.
- Author
M. Seehafer
- Version
0.1
- Date
2022-08-27
- Copyright
Copyright (c) 2022
- file run_result.h
- #include <vector>#include <string>#include “time_axis.h”
Stores the result of a calculation.
- Author
M. Seehafer
- Version
0.1
- Date
2022-08-27
- Copyright
Copyright (c) 2022
Functions
-
void insert_2dmatrix_as_submatrix(double *target_array, double *source_array, int source_col_num, int row_num, int target_col_num, int target_start_col)
Copy the results from one 2D array (internal) to another 2D (external) array. Both must have the same number of rows but the target matrix may have more columns.
- Parameters
target_array – Pointer to target 2D memory block (where to copy to).
source_array – Pointer to source 2D memory block (where to copy from).
source_col_num – Number of states, this is the number of columns in the source data.
row_num – Number of rows to be copied. Should conincide with the row-dimensions of source and target
target_col_num – Number of columns of the target Matrix.
target_start_col – Column index in the target where to start inserting from
Variables
-
const vector<string> time_axis_names = {"PERIOD_START_Y", "PERIOD_START_M", "PERIOD_START_D", "PERIOD_END_Y", "PERIOD_END_M", "PERIOD_END_D", "PERIOD_DAYS"}
Column meaning of the result array when an external array is populated.
- file runner.h
- #include <vector>#include <string>#include <iostream>#include <memory>#include “assumption_sets.h”#include “providers.h”#include “portfolio.h”#include “run_config.h”#include “record_projector.h”#include “time_axis.h”#include “run_result.h”#include “payments.h”
Runner objects that encapsulate the projection engine and provide an interface to the calculation functionality.
- Author
M. Seehafer
- Version
0.1
- Date
2022-08-27
- Copyright
Copyright (c) 2022
Functions
-
unique_ptr<RunResult> run_c_valuation(const CRunConfig &run_config, shared_ptr<CPolicyPortfolio> ptr_portfolio)
External interface function to the calculation engine.
- Parameters
run_config – Config object used for the run.
ptr_portfolio – Pointer to a portfolio object.
run_result – Container to store the results in.
- file time_axis.h
- #include <iostream>#include <vector>#include <string>
CPP implementation of the time axis and related objects.
Some read on 30/360 time count convention: https://sqlsunday.com/2014/08/17/30-360-day-count-convention/
- Author
M. Seehafer
- Version
0.1
- Date
2022-08-27
- Copyright
Copyright (c) 2022
Enums
-
enum class TimeStep : int
Flag to signal which timestep to use in the calculation.
Values:
-
enumerator MONTHLY
-
enumerator QUARTERLY
-
enumerator YEARLY
-
enumerator MONTHLY
Functions
-
inline int getdays_30U_360(const PeriodDate &date1, const PeriodDate &date2)
US 30/360 convention accoriding to https://sqlsunday.com/2014/08/17/30-360-day-count-convention/.
-
int getdays_30E_360(const PeriodDate &date1, const PeriodDate &date2)
European 30/360 convention accoriding to https://sqlsunday.com/2014/08/17/30-360-day-count-convention/.
-
std::ostream &operator<<(std::ostream &outs, const PeriodDate &ped)
Make the above date struct printable with cout.
Variables
-
const int _days_in_month[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
number of day in each month
- file utils.h
- #include <utility>#include <unordered_map>
Auxiliary helpers.
- Author
M. Seehafer
- Version
0.2.0
- Date
2023-04-01
- Copyright
Copyright (c) 2023
- dir docs
- dir modules
- page index
The core engine of
PyProtolinc
is written in C++ which is accessed from Python through a cython interface. This is the documentation of this engine.