% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/GRCFE.R
\name{generate_2fi_optimal_rowcol}
\alias{generate_2fi_optimal_rowcol}
\title{Generate a 2FI-optimal row-column factorial design}
\usage{
generate_2fi_optimal_rowcol(
  s,
  p,
  q,
  n = p + q,
  max_iter_nonprime = 5000,
  n_starts_nonprime = 5,
  verbose_nonprime = FALSE
)
}
\arguments{
\item{s}{Integer. Number of levels for each treatment factor. Must be at
least 2.}

\item{p}{Integer. Number of row blocking factors; rows are indexed by
\code{s^p} combinations.}

\item{q}{Integer. Number of column blocking factors; columns are indexed by
\code{s^q} combinations.}

\item{n}{Integer. Number of treatment factors. Defaults to \code{p + q}.}

\item{max_iter_nonprime}{Integer. Maximum coordinate-exchange iterations per
heuristic start for non-prime or unsupported cases.}

\item{n_starts_nonprime}{Integer. Number of random heuristic starts.}

\item{verbose_nonprime}{Logical. If \code{TRUE}, reports heuristic progress
using \code{message()}. The default is \code{FALSE}.}
}
\value{
A list with components \code{s}, \code{p}, \code{q}, \code{n},
\code{G}, \code{design}, and construction metadata. For theorem-based
designs, \code{G} is the generator matrix. For heuristic designs,
\code{G = NULL} and \code{D_opt_objective} is included.
}
\description{
Constructs a row-column design for estimating main effects and two-factor
interactions (2FIs). For prime \code{s}, theorem-based generator matrices are
used when available. For composite \code{s}, and for the full two-level case,
the function falls back to a D-optimality heuristic.
}
\details{
The function supports \code{p + q <= n}. The heuristic path currently supports
\code{k = n - (p + q)} in \code{0:3}. The theorem-based path supports prime
\code{s} when the corresponding generator-matrix construction is implemented.
}
\examples{
res <- generate_2fi_optimal_rowcol(s = 3, p = 1, q = 1, n = 2)
head(res$design)
stopifnot(nrow(res$design) == 3^(1 + 1))

}
\references{
Zhang, Y., Pan, J. and Shi, L. (2025).
Construction of 2fi-optimal row-column designs.
\emph{Journal of Statistical Planning and Inference}, 234, 106192.
ISSN 0378-3758.
\doi{10.1016/j.jspi.2024.106192}
}
\seealso{
\code{\link{generate_2fi_rowcol}}, \code{\link{build_G}}
}
