AgeReplacementPolicy#

class relife.policy.AgeReplacementPolicy(lifetime_model, cf, cp, discounting_rate=0.0, a0=None, ar=None)[source]#

Age replacement policy.

Asset is replaced at a fixed age \(a_r\) with cost \(c_p\) or it is replaced upon failure with cost \(c_f\).

The object’s methods require the ar attribute to be set either at the instanciation or by calling the optimize method. Otherwise, an error will be raised.

Parameters:
lifetime_modelany lifetime distribution or frozen lifetime model

A lifetime model representing the durations between events.

cffloat or 1darray

Costs of failures

cpfloat or 1darray

Costs of preventive replacements

discounting_ratefloat, default is 0.

The discounting rate value used in the exponential discounting function

a0float or 1darray, optional

Current ages of the assets. If it is given, left truncations of a0 will be take into account for the first cycle.

arfloat or 1darray, optional

Ages of preventive replacements, by default None. If not given, one must call optimize to set ar values and access to the rest of the object interface.

Attributes:
cf

Cost of failure.

cp

Costs of preventive replacement.

ar

Preventive ages of replacement.

References

[1]

Mazzuchi, T. A., Van Noortwijk, J. M., & Kallen, M. J. (2007). Maintenance optimization. Encyclopedia of Statistics in Quality and Reliability, 1000-1008.

Methods

annual_number_of_replacements

The expected number of annual replacements.

asymptotic_expected_equivalent_annual_cost

The asymtotic expected equivalent annual cost.

asymptotic_expected_net_present_value

The asymtotic expected net present value.

expected_equivalent_annual_cost

The expected equivalent annual cost.

expected_net_present_value

The expected net present value.

generate_failure_data

Generate failure data

optimize

Optimize the policy according the costs, the discounting rate and the underlying lifetime model.

sample

Renewal data sampling.

property a0#

Current ages of the assets.

Returns:
np.ndarray
annual_number_of_replacements(nb_years, upon_failure=False, total=True)[source]#

The expected number of annual replacements.

Parameters:
nb_yearsint

The number of years on which the annual number of replacements are projected

upon_failurebool, default is False

If True, it also returns the annual number of replacements due to unexpected failures

totalbool, default is True

If True, the given numbers of replacements are the sum of all replacements without distinction between assets

property ar#

Preventive ages of replacement.

Returns:
np.ndarray
asymptotic_expected_equivalent_annual_cost(total_sum=False)[source]#

The asymtotic expected equivalent annual cost.

\[\lim_{t\to\infty} q(t)\]
Parameters:
total_sumbool, default False

If True, returns the total sum over the first axis of the result. If the policy data encodes several assets, this option allows to return the sum result on the flit rather than calling np.sum afterwards.

Returns:
ndarray

The asymptotic expected values.

asymptotic_expected_net_present_value(total_sum=False)[source]#

The asymtotic expected net present value.

\[\lim_{t\to\infty} z(t)\]
Parameters:
total_sumbool, default False

If True, returns the total sum over the first axis of the result. If the policy data encodes several assets, this option allows to return the sum result on the flit rather than calling np.sum afterwards.

Returns:
ndarray

The asymptotic expected values.

property cf#

Cost of failure.

Returns:
np.ndarray
property cp#

Costs of preventive replacement.

Returns:
np.ndarray
expected_equivalent_annual_cost(tf, nb_steps, total_sum=False)[source]#

The expected equivalent annual cost.

\[q(t) = \dfrac{\delta z(t)}{1 - e^{-\delta t}}\]

where :

  • \(t\) is the time.

  • \(z(t)\) is the expected net present value at time \(t\).

  • \(\delta\) is the discounting rate.

Parameters:
tffloat

The final time.

nb_stepsint

The number of steps used to discretized the time.

total_sumbool, default False

If True, returns the total sum over the first axis of the result. If the policy data encodes several assets, this option allows to return the sum result on the flit rather than calling np.sum afterwards.

Returns:
tuple of two ndarrays

A tuple containing the timeline and the computed values.

expected_net_present_value(tf, nb_steps, total_sum=False)[source]#

The expected net present value.

\[z(t) = \mathbb{E}(Z_t) = \int_{0}^{\infty}\mathbb{E}(Z_t~|~X_1 = x)dF(x)\]

where :

  • \(t\) is the time

  • \(X_1 \sim F\) is the random lifetime of the first asset

  • \(Z_t\) are the random costs at each time \(t\)

  • \(\delta\) is the discounting rate

It is computed by solving the renewal equation.

Parameters:
tffloat

The final time.

nb_stepsint

The number of steps used to discretized the time.

total_sumbool, default False

If True, returns the total sum over the first axis of the result. If the policy data encodes several assets, this option allows to return the sum result on the flit rather than calling np.sum afterwards.

Returns:
tuple of two ndarrays

A tuple containing the timeline and the computed values.

generate_failure_data(size, tf, t0=0.0, seed=None)[source]#

Generate failure data

This function will generate failure data that can be used to fit a lifetime model.

Parameters:
sizeint

The size of the desired sample.

tffloat

Time at the end of the observation.

t0float, default 0

Time at the beginning of the observation.

seedint, optional

Random seed, by default None.

Returns:
A dict of time, event, entry and args (covariates)
optimize()[source]#

Optimize the policy according the costs, the discounting rate and the underlying lifetime model.

Returns:
Self

Optimized policy.

sample(size, time_window, seed=None)[source]#

Renewal data sampling.

This function will sample data and encapsulate them in an object.

Parameters:
sizeint

The size of the desired sample.

time_windowtuple of two floats

Time window in which data are sampled

seedint, optional

Random seed, by default None.

property tr1#

Times before the first replacements.

Returns:
np.ndarray