| Title: | Optimal Hyperrectangular Operating Regions |
|---|---|
| Description: | Computes optimal axis-aligned hyperrectangles for discrete binary arrays and continuous regions defined by quadratic response functions. The package provides methods for discrete optimization, grid classification, continuous refinement, and exact global extrema calculations. Applications include the identification of practical operating regions within multivariate design spaces, including pharmaceutical development settings related to ICH Q8. |
| Authors: | Christian Palmes [aut, cre], Bayer AG [cph], Raluca Ilinca Schmitt [ctb], Adrian Funke [ctb] |
| Maintainer: | Christian Palmes <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.0 |
| Built: | 2026-10-14 08:07:57 UTC |
| Source: | https://github.com/cran/OptOR |
Constructs a regular grid over a continuous factor region and classifies either the grid points or the associated axis-aligned subboxes according to one or more quadratic response-surface models and their specified lower and upper response limits.
calc_X(fcts, n, rg_ll, rg_ul, gmode = "conservative")calc_X(fcts, n, rg_ll, rg_ul, gmode = "conservative")
fcts |
A list of quadratic response-surface models. Each element must be a list with components:
At least one finite response limit must be active for each response. |
n |
Positive integer giving the grid resolution per coordinate. |
rg_ll |
A finite numeric vector of length |
rg_ul |
A finite numeric vector of length |
gmode |
Character scalar selecting the grid-classification mode:
|
For subbox-based classification, a value of 1 indicates that the complete
subbox satisfies all response constraints, whereas a value of 0 indicates
that the complete subbox is infeasible. A value of 2 identifies a boundary
subbox that contains both feasible and infeasible points. In conservative
mode, such boundary subboxes are treated as infeasible; in optimistic mode,
they are treated as feasible. In point mode, the classification is instead
performed directly at the grid points.
The resulting array provides a discrete inner or outer approximation of the continuous feasible region and can be passed to the optimization routines for identifying grid-aligned or continuously refined hyperrectangular operating regions.
A list with components:
Integer status code: 0 for success and -1 for an error
reported by the native implementation.
An integer array with dimensions rep(n, d) if code == 0;
otherwise NULL. Values are 0 for invalid, 1 for valid, and 2 for
indefinite grid elements.
The grid-classification mode used.
The grid resolution per coordinate.
The number of factor dimensions.
The number of quadratic functions used.
fcts <- list( list( c = 0, b = c(0, 0), Q = diag(2), lim_ll = 0.25, lim_ul = 1 ) ) calc_X( fcts = fcts, n = 20, rg_ll = c(-1, -1), rg_ul = c(1, 1), gmode = "conservative" )fcts <- list( list( c = 0, b = c(0, 0), Q = diag(2), lim_ll = 0.25, lim_ul = 1 ) ) calc_X( fcts = fcts, n = 20, rg_ll = c(-1, -1), rg_ul = c(1, 1), gmode = "conservative" )
Converts named regression coefficient vectors into the quadratic-function representation used by OptOR,
coef_to_cbQ(coefficients, factors)coef_to_cbQ(coefficients, factors)
coefficients |
A non-empty named list of named numeric coefficient
vectors. The list names identify the responses. Each coefficient vector
may contain an optional |
factors |
A non-empty character vector giving the factor names and their order in the returned linear vectors and quadratic matrices. Every supplied factor must occur in at least one coefficient vector. |
Interaction coefficients are split equally between the two symmetric
off-diagonal entries of Q. Thus, a fitted term with coefficient
for is represented by
, so that x' Q x reproduces the
original interaction coefficient.
Equivalent term labels are not allowed within the same coefficient vector.
For example, "A:B" and "B:A" denote the same interaction, while
"I(A^2)" and "I(A * A)" denote the same pure quadratic term.
A named list with one element per response. Each response element is a list with components:
The intercept as a numeric scalar. If no intercept was supplied,
0.
A named numeric vector of linear coefficients in the order given
by factors. Missing linear terms are represented by 0.
A named symmetric numeric matrix of quadratic coefficients with
rows and columns ordered according to factors. Missing terms are
represented by 0.
The factor vector is additionally stored as the "factors" attribute of
the returned list.
coefficients <- list( yield = c( "(Intercept)" = -254.0857, time = 8.993016, temp = -0.750000, "I(time^2)" = -0.06202356, "time:temp" = 0.01 ), viscosity = c( "(Intercept)" = -9954.86, time = -0.03105469, temp = 115.05, "I(temp * temp)" = -0.33 ) ) coef_to_cbQ( coefficients = coefficients, factors = c("time", "temp") )coefficients <- list( yield = c( "(Intercept)" = -254.0857, time = 8.993016, temp = -0.750000, "I(time^2)" = -0.06202356, "time:temp" = 0.01 ), viscosity = c( "(Intercept)" = -9954.86, time = -0.03105469, temp = 115.05, "I(temp * temp)" = -0.33 ) ) coef_to_cbQ( coefficients = coefficients, factors = c("time", "temp") )
Computes the global minimum and maximum of a quadratic function
over a continuous axis-aligned hyperrectangle.
find_extrema(fct, hr_ll, hr_ul)find_extrema(fct, hr_ll, hr_ul)
fct |
A list describing the quadratic function with components:
|
hr_ll |
A finite numeric vector of length |
hr_ul |
A finite numeric vector of length |
A list with components:
Integer status code: 0 for success and -1 for an error
reported by the native implementation.
The global minimum, or NA_real_ if no result was returned.
The global maximum, or NA_real_ if no result was returned.
A point at which the minimum is attained, or NULL.
A point at which the maximum is attained, or NULL.
fct <- list( c = 0, b = c(0, 0), Q = diag(2) ) find_extrema( fct = fct, hr_ll = c(-1, -2), hr_ul = c(1, 2) )fct <- list( c = 0, b = c(0, 0), Q = diag(2) ) find_extrema( fct = fct, hr_ll = c(-1, -2), hr_ul = c(1, 2) )
Converts a list of fitted lm models into the quadratic-function
representation used by OptOR,
lm_to_cbQ(models, factors)lm_to_cbQ(models, factors)
models |
A non-empty list of fitted objects inheriting from class
|
factors |
A non-empty character vector giving the factor names and their order in the returned linear vectors and quadratic matrices. Every supplied factor must occur in at least one fitted model. |
This function extracts the named coefficient vector from each model and
passes the resulting list to coef_to_cbQ(). Consequently, the fitted model
may contain only an optional intercept, untransformed linear terms, pure
quadratic terms written as I(A^2) or I(A * A), and two-factor
interactions written as A:B.
Models with aliased or otherwise non-finite coefficients are rejected. Categorical effects, transformations other than the supported pure quadratic terms, and interactions involving transformed variables are not supported.
A named list with one element per model. Each element contains the
components c, b, and Q describing the fitted response as
. See coef_to_cbQ() for the precise
structure. The factor vector is additionally stored as the "factors"
attribute of the returned list.
dat <- data.frame( yield = c(76.5, 77.0, 78.0, 79.5, 79.9, 80.3, 78.4, 75.6), viscosity = c(62, 60, 66, 59, 72, 69, 68, 71), time = c(80, 80, 90, 90, 85, 85, 92.07, 77.93), temp = c(170, 180, 170, 180, 175, 175, 175, 175) ) models <- list( yield = lm(yield ~ time + temp + I(time^2) + time:temp, data = dat), viscosity = lm(viscosity ~ time + temp + I(temp^2), data = dat) ) lm_to_cbQ( models = models, factors = c("time", "temp") )dat <- data.frame( yield = c(76.5, 77.0, 78.0, 79.5, 79.9, 80.3, 78.4, 75.6), viscosity = c(62, 60, 66, 59, 72, 69, 68, 71), time = c(80, 80, 90, 90, 85, 85, 92.07, 77.93), temp = c(170, 180, 170, 180, 175, 175, 175, 175) ) models <- list( yield = lm(yield ~ time + temp + I(time^2) + time:temp, data = dat), viscosity = lm(viscosity ~ time + temp + I(temp^2), data = dat) ) lm_to_cbQ( models = models, factors = c("time", "temp") )
Finds a grid-based continuous axis-aligned operating hyperrectangle for regions defined by quadratic response limits. In conservative mode, the function returns a guaranteed feasible hyperrectangle obtained from the globally optimal conservative grid hyperrectangle followed by continuous expansion. In optimistic mode, it returns an outer hyperrectangle whose volume provides a global upper bound on the unknown maximum feasible continuous volume.
optimal_cont_hr( fcts, n, rg_ll, rg_ul, ctype = NULL, cwidth = NULL, cll = NULL, cul = NULL, gmode = "conservative", verbose = TRUE )optimal_cont_hr( fcts, n, rg_ll, rg_ul, ctype = NULL, cwidth = NULL, cll = NULL, cul = NULL, gmode = "conservative", verbose = TRUE )
fcts |
A list of quadratic response-surface models. Each element must be a list with components:
At least one finite response limit must be active for each fct. |
n |
Positive integer giving the grid resolution per coordinate. |
rg_ll |
A finite numeric vector of length |
rg_ul |
A finite numeric vector of length |
ctype |
Optional character vector of length |
cwidth |
Optional finite numeric vector of length |
cll |
Optional finite numeric vector of length |
cul |
Optional finite numeric vector of length |
gmode |
Character scalar selecting the grid-classification mode:
|
verbose |
Logical scalar. If |
A list with components:
Integer status code: 0 if a hyperrectangle was found,
-1 if none was found, and -2 if an error occurred.
Continuous lower bounds of the returned hyperrectangle, or
NULL.
Continuous upper bounds of the returned hyperrectangle, or
NULL.
Continuous volume of the returned hyperrectangle, or
NA_real_.
The grid-classification mode used.
fcts <- list( list( c = 0, b = c(0, 0), Q = diag(2), lim_ll = 0.25, lim_ul = 1 ) ) optimal_cont_hr( fcts = fcts, n = 100, rg_ll = c(-1, -1), rg_ul = c(1, 1), verbose = FALSE )fcts <- list( list( c = 0, b = c(0, 0), Q = diag(2), lim_ll = 0.25, lim_ul = 1 ) ) optimal_cont_hr( fcts = fcts, n = 100, rg_ll = c(-1, -1), rg_ul = c(1, 1), verbose = FALSE )
Finds a maximum-volume axis-aligned hyperrectangle consisting entirely of feasible grid cells in a binary matrix or array. Optional constraints can require the returned hyperrectangle to contain a prescribed interval or to have a minimum width in selected dimensions.
optimal_grid_hr( X, ctype = NULL, cwidth = NULL, cll = NULL, cul = NULL, verbose = TRUE )optimal_grid_hr( X, ctype = NULL, cwidth = NULL, cll = NULL, cul = NULL, verbose = TRUE )
X |
A numeric, integer, or logical matrix or array containing only
|
ctype |
Optional character vector of length |
cwidth |
Optional numeric vector of length |
cll |
Optional numeric vector of length |
cul |
Optional numeric vector of length |
verbose |
Logical scalar. If |
X must be a binary array containing only the values 0 and 1, where
1 denotes a feasible grid cell and 0 an infeasible grid cell. The array
is expected to use column-major order, following the usual R convention.
A list with components:
Integer status code: 0 if a hyperrectangle was found,
-1 if none was found, and -2 if an error occurred.
One-based lower grid indices, or NULL if no solution was
returned.
One-based upper grid indices, or NULL if no solution was
returned.
Number of grid cells in the returned hyperrectangle, or
NA_integer_ if no solution was returned.
X <- matrix( c( 1, 1, 0, 1, 1, 0, 0, 1, 1 ), nrow = 3, byrow = TRUE ) optimal_grid_hr(X, verbose = FALSE)X <- matrix( c( 1, 1, 0, 1, 1, 0, 0, 1, 1 ), nrow = 3, byrow = TRUE ) optimal_grid_hr(X, verbose = FALSE)