# \donttest{
## Linear Programming via Regularized Least Squares (LPPinv)
## Underdetermined and potentially infeasible LP system
RNGkind("L'Ecuyer-CMRG")
set.seed(123456789)
# sample (dataset)
A_ub <- matrix(rnorm(50 * 500), nrow = 50L, ncol = 500L)
A_eq <- matrix(rnorm(25 * 500), nrow = 25L, ncol = 500L)
b_ub <- matrix(rnorm(50), ncol = 1L)
b_eq <- matrix(rnorm(25), ncol = 1L)
# model (no default non-negativity, unique MNBLUE solution)
model <- lppinv(
A_ub = A_ub,
A_eq = A_eq,
b_ub = b_ub,
b_eq = b_eq,
non_negative = FALSE,
final = TRUE,
alpha = 1.0 # unique MNBLUE estimator
)
# coefficients
print("x hat (x_M hat):")
print(round(model$x, 4))
# numerical stability (if available)
if (!is.null(model$kappaC)) {
cat("\nNumerical stability:\n")
cat(" kappaC :", round(model$kappaC, 4), "\n")
}
if (!is.null(model$kappaB)) {
cat(" kappaB :", round(model$kappaB, 4), "\n")
}
if (!is.null(model$kappaA)) {
cat(" kappaA :", round(model$kappaA, 4), "\n")
}
# goodness-of-fit diagnostics (if available)
if (!is.null(model$nrmse)) {
cat("\nGoodness-of-fit:\n")
cat(" NRMSE :", round(model$nrmse, 6), "\n")
}
if (!is.null(model$x_lower)) {
cat(" Diagnostic band (min):", round(min(model$x_lower), 4), "\n")
}
if (!is.null(model$x_upper)) {
cat(" Diagnostic band (max):", round(max(model$x_upper), 4), "\n")
}
# bootstrap NRMSE t-test (if supported by rclsp)
if ("ttest" %in% names(model)) {
cat("\nBootstrap t-test:\n")
tt <- model$ttest(sample_size = 30L,
seed = 123456789,
distribution = "normal")
for (nm in names(tt)) {
cat(" ", nm, ": ", round(tt[[nm]], 6), "\n", sep = "")
}
}
# }
Run the code above in your browser using DataLab