Optimization

StatisticalProcessMonitoring.Phase2Type

Phase2 is a struct that holds the reference sample data and a sampling method, which is used to generate new observations from the reference data.

Arguments

  • samp::AbstractSampling: The sampling method to be used to generate new observations. Defaults to Bootstrap().
  • data: The data from which observations need to be resampled.

Examples

x = randn(500) PH2 = Phase2(data = x)

source
StatisticalProcessMonitoring.Phase2DistributionType
Phase2Distribution{T} <: AbstractPhase2

A struct that is used to generate and new data from a distribution. It contains a sampleable field dist of type T, which represents the underlying data-generating process.

Notes

A method rand(::T) is required to generate new data from dist.

Example

using Distributions
DGP = Phase2Distribution(Normal(0,1))
new_data(DGP)
source
StatisticalProcessMonitoring.optimize_designFunction
optimize_design(CH::ControlChart, rlsim_oc::Function, settings::OptSettings=OptSettings(CH); optimizer::Symbol = :LN_BOBYQA, solver::Symbol = :SACL, nsims_opt::Int = 1000, kw...)

Optimizes the design of a control chart using a specified optimization algorithm.

Arguments

  • CH::ControlChart: The control chart object to optimize.
  • rlsim_oc::Function: A function that simulates the out-of-control state of the control chart.
  • settings::OptSettings: The optimization settings that control the optimization routine (default: OptSettings(CH)).

Keyword Arguments

  • optimizer::Symbol: The optimization algorithm to use (default: :Grid).
  • solver::Symbol: The root-finding algorithm to use for control limit estimation (default: :Bootstrap).
  • hmax::Float64: The maximum value of the control limit, used only for the bisection algorithm (default: 100.0)
  • kw...: Additional keyword arguments to pass to the solver algorithm.

Returns

The optimized design parameters of the control chart.

source
StatisticalProcessMonitoring.optimize_design!Function
optimize_design!(CH::ControlChart, rlsim_oc::Function, settings::OptSettings=OptSettings(CH); optimizer = :LN_BOBYQA, solver = :Bootstrap, hmax::Float64 = 20.0, kw...)

Optimizes the design of a control chart CH using a specified optimization algorithm.

Arguments

  • CH::ControlChart: The control chart object to optimize.
  • rlsim_oc::Function: A function that simulates the out-of-control state of the control chart.
  • settings::OptSettings: The optimization settings that control the optimization routine (default: OptSettings(CH)).

Keyword Arguments

  • optimizer::Symbol: The optimization algorithm to use (default: :Grid).
  • solver::Symbol: The root-finding algorithm to use for control limit estimation (default: :Bootstrap).
  • hmax::Float64: The maximum value of the control limit, used only when the solver is set to :Bisection (default: 100.0)
  • kw...: Additional keyword arguments to pass to the solver algorithm.

Returns

The optimized design parameters of the control chart.

source
StatisticalProcessMonitoring.optimize_limitFunction
optimize_limit(CH::ControlChart, solver::Symbol = :Bootstrap; kw...)

Optimizes the control limit of a ControlChart object, without modifying the original ControlChart object.

Arguments

  • CH::ControlChart: The ControlChart object to optimize.
  • solver::Symbol: The solver algorithm to use (default: :Bootstrap).

Keyword Arguments

  • hmax::Float64: The maximum value of the control limit. Used only for the bisection algorithm (default: 100.0)
  • kw...: Additional keyword arguments to pass to the algorithm.

Returns

The optimized control limit value.

Raises

ValueError: If the optimization method specified in settings is unknown.

Example

optimize_limit(my_chart, settings=OptSettings(ic_solver=:SA))
source
StatisticalProcessMonitoring.optimize_limit!Function
optimize_limit(CH::ControlChart, solver = :Bootstrap; hmax = 20.0, kw...)

Optimizes the control limit of a ControlChart object.

Arguments

  • CH::ControlChart: The ControlChart object to optimize.
  • solver::Symbol: The solver algorithm to use (default: :Bootstrap).

Keyword Arguments

  • hmax::Float64: The maximum value of the control limit. Only used for the bisection algorithm (default: 100.0)
  • kw...: Additional keyword arguments to pass to the algorithm.

Returns

The optimized control limit value.

Raises

ValueError: If the optimization method specified in settings is unknown.
source
StatisticalProcessMonitoring.bisectionCL!Method
bisectionCL!(CH::ControlChart, hmax[; rlsim::Function, kw...])

Computes the control limit to satisfy the nominal properties of a control chart, using the bisection algorithm (see for instance Qiu, 2013)

Arguments

  • CH - A control chart.
  • hmax - The maximum value for the control limit.

Keyword arguments

  • rlsim - A function that generates a run length for the control chart with signature rlsim(CH; maxiter). If left unspecified, defaults to run_sim. See the help for run_sim for more information about the signature of the function.
  • nsims - The number of run lengths used to estimate the target nominal property (default: 10000).
  • hmin - The minimum value of the control limit, (default: sqrt(eps())).
  • maxiter - The maximum number of bisection iterations (default: 30).
  • maxrl - The value at which to maxrlate the run length, to avoid excessive computations (default: Inf, i.e. no maxrlation).
  • x_tol - Absolute tolerance for the algorithm, which is terminated if $h^{(k+1)} - h^{(k)} < x_{\text{tol}}$ (default: 1e-06)
  • f_tol - Absolute tolerance for the algorithm, which is terminated if $\text{target}(h^{(k+1)}) - \text{target}(h^{(k)}) < f_{\text{tol}}$ (default: 1.0)
  • verbose - Whether to print information to the user about the state of the optimization (default: false).
  • parallel::Bool - Whether the algorithm should be run in parallel, using available threads (default: false)

Returns

  • A NamedTuple containing the estimated control limit h, the total number of iterations iter, and information status about the convergence of the algorithm.

References

  • Qiu, P. (2013). Introduction to Statistical Process Control. Boca Raton: CRC Press.
source
StatisticalProcessMonitoring.bisectionCLMethod
bisectionCL(CH::ControlChart, hmax; kw...)

Applies the bisection algorithm to find the control limit of a control chart without modifying the control chart object CH.

Keyword arguments

See the documentation of bisectionCL! for more information about the algorithm and keyword arguments.

Returns

  • A NamedTuple containing the estimated control limit h, the total number of iterations iter, and information status about the convergence of the algorithm.

References

  • Qiu, P. (2013). Introduction to Statistical Process Control. Boca Raton: CRC Press.
source
StatisticalProcessMonitoring.combinedCL!Method
combinedCL!(CH::ControlChart[; rlsim::Function, kw...])

Computes the control limit to satisfy the nominal properties of a control chart, using the bisection algorithm (see for instance Qiu, 2013). The control limit upper bound hmax for the bisection algorithm is found using the stochastic approximation algorithm of Capizzi and Masarotto (2016)

Arguments

  • CH - A control chart.

Keyword arguments

  • inflate::Real - An inflation constant for the starting control limit value so that, on average, the first iteration will move the control limit to lower values. This usually saves computational time (default: 1.05).
  • parallel::Bool - Whether the algorithm should be run in parallel, using available threads (default: false)

Bisection algorithm

  • rlsim - A function that generates a run length for the control chart with signature rlsim(CH; maxiter). If left unspecified, defaults to run_sim. See the help for run_sim for more information about the signature of the function.
  • nsims - The number of run lengths used to estimate the target nominal property (default: 10000).
  • hmin - The minimum value of the control limit, (default: sqrt(eps())).
  • maxiter - The maximum number of bisection iterations (default: 30).
  • maxrl - The value at which to maxrlate the run length, to avoid excessive computations (default: Inf, i.e. no maxrlation).
  • x_tol - Absolute tolerance for the algorithm, which is terminated if $h^{(k+1)} - h^{(k)} < x_{\text{tol}}$ (default: 1e-06)
  • f_tol - Absolute tolerance for the algorithm, which is terminated if $\text{target}(h^{(k+1)}) - \text{target}(h^{(k)}) < f_{\text{tol}}$ (default: 1.0)

SA algorithm

  • Nfixed - The number of iterations for the gain estimation stage (default: 200).
  • Afixed - The fixed gain during the gain estimation stage (default: 0.1).
  • Amin - The minimum allowed value of gain (default: 0.1).
  • Amax - The maximum allowed value of gain (default: 100).
  • deltaSA - The shift in control limit used during the gain estimation stage (default: 0.1).
  • q - The power that controls the denominator in the Robbins-Monro algorithm (default: 0.55).
  • gamma - The precision parameter for the stopping criterion of the algorithm (default: 0.05).
  • Nmin - The minimum number of iterations required for the algorithm to end (default: 200).
  • z - The quantile of the Normal(0,1) that controls the probability of the stopping criterion being satisfied (default: 3.0).
  • Cmrl - The inflation factor for the maximum number of iterations the run length may run for (default: 10.0).
  • maxiter_sa - Maximum number of iterations before the algorithm is forcibly ended (default: 200).
  • verbose - Whether to print information to the user about the state of the optimization (default: false).

Returns

  • A NamedTuple containing the estimated control limit h, the total number of iterations iter, and information status about the convergence of the algorithm.

References

  • Qiu, P. (2013). Introduction to Statistical Process Control. Boca Raton: CRC Press.
  • Capizzi, G., & Masarotto, G. (2016). Efficient control chart calibration by simulated stochastic approximation. IIE Transactions, 48(1), 57-65. https://doi.org/10.1080/0740817X.2015.1055392
source
StatisticalProcessMonitoring.combinedCLMethod
combinedCL(CH::ControlChart; kw...)

Applies the bisection algorithm to find the control limit of a control chart without modifying the control chart object CH. The control limit upper bound hmax for the bisection algorithm is found using the stochastic approximation algorithm of Capizzi and Masarotto (2016). See the documentation of combinedCL! for more information about the algorithm and keyword arguments.

Keyword arguments

  • See the documentation of combinedCL! for a list of keyword arguments.

Returns

  • A NamedTuple containing the estimated control limit h, the total number of iterations iter, and information status about the convergence of the algorithm.

References

  • Qiu, P. (2013). Introduction to Statistical Process Control. Boca Raton: CRC Press.
  • Capizzi, G., & Masarotto, G. (2016). Efficient control chart calibration by simulated stochastic approximation. IIE Transactions, 48(1), 57-65. https://doi.org/10.1080/0740817X.2015.1055392
source
StatisticalProcessMonitoring.bootstrapCL!Method
bootstrapCL!(CH::ControlChart[; rlsim::Function, kw...])

Computes the control limit to satisfy the nominal properties of a control chart, using the bisection algorithm on bootstrapped paths (see for instance Qiu, 2013).

Arguments

  • CH - A control chart.

Keyword arguments

  • rlsim - A function that generates a path of the control chart statistic with signature rlsim(CH; maxiter). If left unspecified, defaults to run_path_sim. See the help for run_path_sim for more information about the signature of the function.
  • settings - An OptSettings objects which contains variables that control the behaviour of the algorithm. See the Accepted settings section below for information about the settings that control the behaviour of the algorithm. For more information about the specifics of each keyword argument, see for instance Qiu (2013).
  • maxiter - The maximum number of bisection iterations.
  • nsims - The number of run lengths used to estimate the target nominal property.
  • maxrl - The maximum run length after which the run length is truncated, to avoid excessive computations.
  • x_tol - Absolute tolerance for the algorithm, which is ended if $h^{(k+1)} - h^{(k)} < x_{\text{tol}}$
  • f_tol - Absolute tolerance for the algorithm, which is ended if $\text{target}(h^{(k+1)}) - \text{target}(h^{(k)}) < f_{\text{tol}}$

Returns

  • A NamedTuple containing the estimated control limit h, the total number of iterations iter, and information status about the convergence of the algorithm.

References

  • Qiu, P. (2013). Introduction to Statistical Process Control. Boca Raton: CRC Press.
source
StatisticalProcessMonitoring.bootstrapCLMethod
bootstrapCL(CH::ControlChart; kw...)

Applies the bisection algorithm on simulated run length paths to find the control limit of a control chart without modifying the control chart object CH.

Keyword arguments

See the documentation of bootstrapCL! for more information about the algorithm and keyword arguments.

Returns

  • A NamedTuple containing the estimated control limit h, the total number of iterations iter, and information status about the convergence of the algorithm.

References

  • Qiu, P. (2013). Introduction to Statistical Process Control. Boca Raton: CRC Press.
source
StatisticalProcessMonitoring.calculate_limit_gradientMethod
calculate_limit_gradient(CH::AbstractChart, rl::Real)
calculate_limit_gradient(nominal::ARL, rl)
calculate_limit_gradient(nominal::QRL, rl)

Calculate the gradient for the optimization of the control limit.

If the control chart nominal attribute is of type ARL, then the gradient is calculated according to Equation (9) of Capizzi and Masarotto (2016).

If the control chart nominal attribute is of type QRL, then the gradient is calculated using the recursion on page 280 of Capizzi and Masarotto (2009)

References

Capizzi, G., & Masarotto, G. (2016). "Efficient Control Chart Calibration by Simulated Stochastic Approximation". IIE Transactions 48 (1). https://doi.org/10.1080/0740817X.2015.1055392.

Capizzi, G. & Masarotto, G. (2009) Bootstrap-based design of residual control charts, IIE Transactions, 41:4, 275-286, DOI: https://doi.org/10.1080/07408170802120059

source
StatisticalProcessMonitoring.saCL!Method
saCL!(CH::ControlChart[; rlsim::Function, kw...])

Computes the control limit to satisfy the nominal properties of a control chart, using the stochastic approximation algorithm described in Capizzi and Masarotto (2016).

Arguments

  • CH - A control chart.

Keyword arguments

  • rlsim - A function that generates new data with signature rlsim(CH; maxiter, delta). If left unspecified, defaults to run_sim_sa. See the help for run_sim_sa for more information about the requirements of the function.
  • settings - An OptSettings objects which contains variables that control the behaviour of the algorithm. See the Accepted settings section below for information about the settings that control the behaviour of the algorithm. For more information about the specifics of each keyword argument, see Capizzi and Masarotto (2016).
  • Nfixed - The number of iterations for the gain estimation stage (default: 500).
  • Afixed - The fixed gain during the gain estimation stage (default: 0.1).
  • Amin - The minimum allowed value of gain (default: 0.1).
  • Amax - The maximum allowed value of gain (default: 100.0).
  • delta_sa - The shift in control limit used during the gain estimation stage (default: 0.1).
  • q - The power that controls the denominator in the Robbins-Monro algorithm (default: 0.55).
  • gamma - The precision parameter for the stopping criterion of the algorithm (default: 0.02).
  • Nmin - The minimum number of iterations to avoid early terminations (default: 1000).
  • z - The quantile of the Normal(0,1) that controls the probability of the stopping criterion being satisfied (default: 3.0).
  • Cmrl - The inflation factor for the maximum number of iterations the run length may run for (default: 10.0).
  • maxiter - Maximum number of iterations before the algorithm is forcibly ended (default: 50000).
  • verbose - Whether to print information to the user about the state of the optimization (default: false).
  • parallel::Bool - Whether the algorithm should be run in parallel, using available threads (default: false). Parallelization is achieved by averaging Threads.nthreads independent replications of the algorithm, each with precision parameter gamma*sqrt(Threads.nthreads). See [Capizzi, 2016] for further discussion on parallelizing the SA algorithm.

Returns

  • A NamedTuple containing the estimated control limit h, the total number of iterations iter, and information status about the convergence of the algorithm.

References

  • Capizzi, G., & Masarotto, G. (2016). "Efficient Control Chart Calibration by Simulated Stochastic Approximation". IIE Transactions 48 (1). https://doi.org/10.1080/0740817X.2015.1055392.
source
StatisticalProcessMonitoring.saCLMethod
saCL(CH::ControlChart[; rlsim::Function, kw...])

Applies the stochastic approximation algorithm of Capizzi and Masarotto (2016) without modifying the control chart object CH.

Keyword arguments

See the documentation of saCL! for more information about the algorithm and the keyword arguments.

Returns

  • A NamedTuple containing the estimated control limit h, the total number of iterations iter, and information status about the convergence of the algorithm.

References

  • Capizzi, G., & Masarotto, G. (2016). "Efficient Control Chart Calibration by Simulated Stochastic Approximation". IIE Transactions 48 (1). https://doi.org/10.1080/0740817X.2015.1055392.
source
StatisticalProcessMonitoring.optimize_gridMethod
optimize_grid(CH::ControlChart, rlconstr::Function, settings::OptSettings)

Optimizes a control chart by finding the best set of parameters using a grid search.

Arguments

  • CH::ControlChart: The control chart object whose parameters must be optimized.
  • rlconstr::Functiom: The function that evaluates the OC performance of the control chart.
  • settings::OptSettings: The optimization settings.

Returns

  • par_current (Vector{Float64}): the optimal set of parameters found by the optimization algorithm.

References

Qiu, P. (2008). Distribution-Free Multivariate Process Control Based on Log-Linear Modeling. IIE Transactions, 40(7), 664-677. https://doi.org/10.1080/07408170701744843

source