BoundedIterativeProcess

abstract class BoundedIterativeProcess<T>(func: FunctionIfc, interval: Interval, initialPoint: Double = (interval.lowerLimit + interval.upperLimit) / 2.0, maxIterations: Int, desiredPrecision: Double = 1.0E-4) : IterativeProcess<T> (source)

Abstract base for root-finding algorithms operating within a bounded search interval. Parallel branch to RootFinder directly under IterativeProcess. Does not impose the sign-change (bracketing) constraint — concrete subclasses that require it assert it in their own init blocks via RootFinder.Companion.hasRoot.

Hierarchy

IterativeProcess<T>
└── FunctionalIterator (existing — untouched)
└── RootFinder (existing — untouched)
└── BoundedIterativeProcess<T> (this class)
└── StochasticApproximationRootFinder

Stopping

  • hasNextStep returns false once maxIterations is reached → COMPLETED_ALL_STEPS.

  • Convergence is signalled by calling stop in checkStoppingCondition → MET_STOPPING_CONDITION.

  • Degenerate boundary conditions call stop with a diagnostic message → same status.

Observability note

Concrete subclasses may supplement IterativeProcess's Observable notification with typed Emitter pairs via Kotlin interface delegation — one for per-step data, one for lifecycle transitions. See StochasticApproximationRootFinder.

Parameters

T

Step type for Observable.

func

Function whose root is sought.

interval

Bounded search interval. lowerLimit must be < upperLimit.

initialPoint

Starting candidate root. Must lie within interval.

maxIterations

Max iterations before termination. Must be > 0.

desiredPrecision

Convergence target. Must be > 0.

Inheritors

Constructors

Link copied to clipboard
constructor(func: FunctionIfc, interval: Interval, initialPoint: Double = (interval.lowerLimit + interval.upperLimit) / 2.0, maxIterations: Int, desiredPrecision: Double = 1.0E-4)

Properties

Link copied to clipboard

f(currentX). Always updated atomically with currentX via assignCandidateX.

Link copied to clipboard

Current candidate root. Always updated atomically with currentFOfX via assignCandidateX.

Link copied to clipboard
Link copied to clipboard
protected var func: FunctionIfc
Link copied to clipboard
Link copied to clipboard
protected var interval: Interval
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
protected fun assignCandidateX(x: Double)

Atomically advances the candidate root to x and recomputes currentFOfX = f(x). All subclass code that moves the candidate root must use this method.

Link copied to clipboard
open override fun hasNextStep(): Boolean

Returns true while not stopped and iteration count has not reached maxIterations.

Link copied to clipboard
fun hasRoot(anInterval: Interval): Boolean

Tests whether func has a bracketing sign-change root within anInterval. Delegates to RootFinder.Companion.hasRoot so subclasses do not need a direct RootFinder import for the bracketing check.

Link copied to clipboard
protected open override fun initializeIterations()

Resets process bookkeeping and re-seeds currentX/currentFOfX from initialPoint. Subclasses must call super.initializeIterations() first.

Link copied to clipboard
open override fun toString(): String