% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/write.R
\name{write_cbf}
\alias{write_cbf}
\title{Write an ROI OP Object to a CBF File}
\usage{
write_cbf(op, file, ...)
}
\arguments{
\item{op}{An \code{\link[ROI]{OP}} object.}

\item{file}{Character string. Destination file path (created or
overwritten).}

\item{...}{Currently unused.}
}
\value{
Invisibly returns \code{file}.
}
\description{
Serialises an ROI optimisation problem (\code{\link[ROI]{OP}}) to a plain
text file in the Conic Benchmark Format (CBF version 4).
}
\details{
Supported OP components
\describe{
  \item{Objective}{Linear objectives (\code{\link[ROI]{L_objective}}).}
  \item{Constraints}{
    \code{\link[ROI]{L_constraint}} is mapped to \code{L+} (\code{">="}),
    \code{L-} (\code{"<="}), or \code{L=} (\code{"=="}) cone chunks.\cr
    \code{\link[ROI]{C_constraint}} is mapped to the appropriate CBF cone:
    \code{Q.}, \code{QR.}, \code{EXP.}, \code{EXP*.}, \code{SVECPSD.},
    \code{@k:POW}, or \code{@k:POW*}.}
  \item{Variable types}{Continuous (\code{"C"}) and integer (\code{"I"});
    integer variables are written to the INT section.}
  \item{Variable bounds}{Translated to \code{F.}, \code{L+}, \code{L-},
    or \code{L=} chunks in the VAR section.}
}
}
\section{Sign convention}{

CBF encodes \eqn{Ax + b \in K}.  ROI stores \eqn{Ax - \text{rhs} \in K}.
Therefore \code{write_cbf} writes \eqn{b = -\text{rhs}} to the BCOORD
section.
}

\examples{
## simple LP:  min x + y  s.t.  x + y >= 1,  x, y >= 0
op <- ROI::OP(
    objective   = ROI::L_objective(c(1, 1)),
    constraints = ROI::L_constraint(
        L   = matrix(c(1, 1), nrow = 1),
        dir = ">=",
        rhs = 1
    )
)
f <- file.path(tempdir(), "lp.cbf")
write_cbf(op, f)

}
\seealso{
\code{\link{read_cbf}}
}
