% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/GRCFE.R
\name{search_2fi_optimal_G_k23}
\alias{search_2fi_optimal_G_k23}
\title{Search for prime-level generator matrices for k = 2 or k = 3}
\usage{
search_2fi_optimal_G_k23(
  s,
  p,
  q,
  n,
  max_tries = 5000,
  N_max_runs = 10000,
  verbose = FALSE
)
}
\arguments{
\item{s}{Prime integer number of levels. The search is tuned for \code{s <= 7}.}

\item{p}{Integer. Number of row blocking factors.}

\item{q}{Integer. Number of column blocking factors.}

\item{n}{Integer. Number of treatment factors.}

\item{max_tries}{Integer. Maximum number of random generator matrices to try.}

\item{N_max_runs}{Integer. Maximum allowed number of runs \code{s^(p + q)}.}

\item{verbose}{Logical. If \code{TRUE}, reports improvements during search
using \code{message()}. The default is \code{FALSE}.}
}
\value{
A list containing the best generator matrix, design, number of
unconfounded two-factor interactions, and search metadata.
}
\description{
Performs a random search over generator matrices for prime-level designs when
\code{k = n - (p + q)} is 2 or 3, retaining the design with the largest number
of unconfounded two-factor interactions among candidates with unconfounded
main effects.
}
\examples{
# The search is random, so a deliberately small number of tries may or may
# not find a feasible design on every platform. The example is therefore
# written to be executable and checkable without requiring stochastic success.
set.seed(1)
res <- try(
  search_2fi_optimal_G_k23(
    s = 5, p = 1, q = 1, n = 4,
    max_tries = 25, N_max_runs = 25, verbose = FALSE
  ),
  silent = TRUE
)
stopifnot(is.list(res) || inherits(res, "try-error"))

}
