This function ensures that the base fit remains within defined vertical bounds by applying penalties if the left or right edge of the base segment exceeds limits.
Value
A numeric penalty value:
0if both edges are within the defined range.A squared penalty if the left or right edges exceed their respective bounds.
Details
The function applies constraints separately for the left and right edges of the base segment.
The left constraint ensures that the starting y-value remains within
[0, threshold].The right constraint ensures that the POI y-value is between
[min_y, threshold].If either constraint is violated, a squared penalty is applied to encourage corrections during optimization.
See also
objective_function where this function is used in the optimization process.
Examples
y_values <- c(0.5, 1.2, 2.0) # Example y-values for the base segment
min_y <- 0.1
poi_y <- 1.8
threshold <- 2.3
base_constraint(y_values, min_y, poi_y, threshold)
#> [1] 0