
Visualize the Canonicalization Pipeline of a CVXR Problem
Source:R/255_zzz_R_specific_visualize.R
visualize.RdDisplays the Smith form decomposition of a convex optimization problem, showing each stage of the DCP canonicalization pipeline: expression tree, Smith form, relaxed Smith form, conic form, and (optionally) standard cone form and solver data.
Usage
visualize(
problem,
output = c("text", "json", "html", "latex", "tikz"),
solver = NULL,
digits = 4L,
file = NULL,
open = interactive(),
doc_base = "https://cvxr.rbind.io/reference/"
)Arguments
- problem
A Problem object.
- output
Character: output format.
"text"Console display (default).
"json"JSON data model (for interop with HTML/Python).
"html"Interactive D3+KaTeX HTML (Phase 2).
"latex"LaTeX align* environments (Phase 3).
"tikz"TikZ forest tree diagrams (Phase 3).
- solver
Solver specification for matrix stuffing stages (4-5).
NULL(default) shows only Stages 0-3 with zero overhead.TRUEuses the default solver (same aspsolve()). A character string (e.g.,"Clarabel") uses that specific solver.- digits
Integer: significant digits for displaying scalar constants. Integer-valued constants (0, 1, -3) always display without decimals regardless of this setting. Defaults to 4.
- file
Character: path for HTML output file. If
NULL(default), a temporary file is used.- open
Logical: whether to open the HTML file in a browser. Defaults to
TRUEin interactive sessions.- doc_base
Character: base URL for atom documentation links. Defaults to the CVXR pkgdown site.
Value
For "text": invisible model list.
For "json": a JSON string (or list if jsonlite not available).
For "html": the file path (invisibly).
For other formats: the rendered output (Phase 2+).
Examples
if (FALSE) { # \dontrun{
x <- Variable(3, name = "x")
prob <- Problem(Minimize(p_norm(x, 2)), list(x >= 1))
visualize(prob) # Stages 0-3 only
visualize(prob, solver = TRUE) # Stages 0-5, default solver
visualize(prob, solver = "Clarabel") # Stages 0-5, specific solver
visualize(prob, output = "html", solver = TRUE)
} # }