Package: CVXR 1.9.1

Anqi Fu

CVXR: Disciplined Convex Optimization

An object-oriented modeling language for disciplined convex programming (DCP) as described in Fu, Narasimhan, and Boyd (2020, <doi:10.18637/jss.v094.i14>). It allows the user to formulate convex optimization problems in a natural way following mathematical convention and DCP rules. The system analyzes the problem, verifies its convexity, converts it into a canonical form, and hands it off to an appropriate solver to obtain the solution. This version uses the S7 object system for improved performance and maintainability.

Authors:Anqi Fu [aut, cre], Balasubramanian Narasimhan [aut], Steven Diamond [aut], John Miller [aut], Stephen Boyd [ctb]

CVXR_1.9.1.tar.gz
CVXR_1.8.2.tar.gz(r-4.7-arm64)CVXR_1.8.2.tar.gz(r-4.7-x86_64)CVXR_1.9.1.tar.gz(r-4.6-arm64)CVXR_1.9.1.tar.gz(r-4.6-x86_64)
CVXR_1.9.1.tgz(r-4.6-emscripten)
manual.pdf |manual.html
card.svg |card.png
CVXR/json (API)
NEWS

# Install 'CVXR' in R:
install.packages('CVXR', repos = c('https://cran.r-universe.dev', 'https://cloud.r-project.org'))

Bug tracker:https://github.com/cvxgrp/cvxr/issues

Pkgdown/docs site:https://www.cvxgrp.org

Uses libs:
  • c++– GNU Standard C++ Library v3
  • openmp– GCC OpenMP (GOMP) support library
Datasets:
  • cdiac - Global Monthly and Annual Temperature Anomalies
  • dspop - Direct Standardization: Population
  • dssamp - Direct Standardization: Sample

On CRAN:

Conda:

cppopenmp

9.30 score 45 packages 1.2k scripts 14k downloads 3 mentions 248 exports 14 dependencies

Last updated from:cae37226e8. Checks:2 FAIL, 2 OK, 2 ERROR. Indexed: no.

TargetResultTimeFilesSyslog
linux-devel-arm64FAIL580
linux-devel-x86_64FAIL593
source / vignettesOK312
linux-release-arm64ERROR483
linux-release-x86_64ERROR431
wasm-releaseOK190

Exports:%<<%%>>%Andas_cvxr_expravailable_solversbackwardbmatCallbackParamceil_exprCLARABEL_SOLVERcondition_numberConstantconstantsconstraintsconvconvolveCOPT_SOLVERCPLEX_SOLVERcummax_exprcumsum_axiscurvaturecvarCVXOPT_SOLVERcvxr_diffcvxr_meancvxr_normcvxr_outercvxr_stdcvxr_vardeltadelta<-derivativediagDiagMatDiagVecdiff_posDIFFCP_SOLVERdist_ratiodotsortdual_valueECOS_BB_SOLVERECOS_SOLVERentrEqualityexclude_solversExpConeexpr_Hexpr_signeye_minus_invFiniteSetfloor_exprformat_labeledgen_lambda_maxgeo_meanget_boundsget_problem_dataGLPK_MI_SOLVERGLPK_SOLVERgmatmulgradientgradient<-GUROBI_SOLVERharmonic_meanHIGHS_SOLVERhstackhuberidiffimpliesinclude_solversindicatorInequalityINFEASIBLEINFEASIBLE_INACCURATEINFEASIBLE_OR_UNBOUNDEDinstalled_solversinv_posinv_prodIPOPT_SOLVERis_affineis_atom_smoothis_concaveis_constantis_convexis_dcpis_dgpis_dnlpis_dppis_dqcpis_linearizable_concaveis_linearizable_convexis_log_log_affineis_log_log_concaveis_log_log_convexis_lpis_matrixis_mixed_integeris_nonnegis_nonposis_nsdis_psdis_pwlis_qpis_quadraticis_quasiconcaveis_quasiconvexis_quasilinearis_scalaris_smoothis_symmetricis_vectoris_zerokl_divKNITRO_SOLVERkronlabellabel<-lambda_maxlambda_minlambda_sum_largestlambda_sum_smallestlength_exprlog_detlog_normcdflog_sum_explog1p_atomlog1p_exprloggammalogisticmatrix_fracmatrix_tracemax_elemwisemax_entriesMaximizemin_elemwisemin_entriesMinimizemixed_normMOSEK_SOLVERmultiplynamenegNonNegNonPosnormnorm_infnorm_nucnorm1norm2normcdfNotobjectiveone_minus_posOPTIMALOPTIMAL_INACCURATEOrOSQP_SOLVERouterp_normparam_backwardparam_dictparam_forwardparam_id_mapParameterparameterspartial_optimizepartial_tracepartial_transposePartialProblemperspectivepf_eigenvaluePIQP_SOLVERposPowCone3DPowConeNDpowerProblemproblem_dataproblem_solutionproblem_statusproblem_unpack_resultsprod_entriesPSDpsolveptpquad_formquad_over_linrel_entrreshape_exprresidualresolventsample_boundssample_bounds<-scalar_productscalarizescaleneSCIP_SOLVERSCS_SOLVERsdset_excluded_solversset_labelsigma_maxsizesize_metricsSizeMetricsSOCsolutionsolve_via_datasolver_default_paramSOLVER_ERRORsolver_optssolver_statssquarestatusstdsum_entriessum_largestsum_smallestsum_squaresto_latextotal_variationtr_invtvUNBOUNDEDUNBOUNDED_INACCURATEUNO_SOLVERunpack_resultsupper_triUSER_LIMITvaluevalue<-varvar_backwardvar_dictvar_forwardvar_id_mapVariablevariablesvdotvecvec_to_upper_triviolationvisualizevstackxexpXorXPRESS_SOLVERZero

Dependencies:backportscheckmateclarabelcligmphighslatticeMatrixosqpRcppRcppEigenS7scsslam

Introduction to CVXR

Rendered fromcvxr_intro.Rmdusingknitr::rmarkdownon Jun 09 2026.

Last update: 2026-06-09
Started: 2017-11-20

What's New in CVXR

Rendered fromwhats_new.Rmdusingknitr::rmarkdownon Jun 09 2026.

Last update: 2026-06-09
Started: 2026-03-06

Readme and manuals

Help Manual

Help pageTopics
Negative Semidefinite Constraint Operator%<<%
Positive Semidefinite Constraint Operator%>>%
Logical ANDAnd
Convert a value to a CVXR Expressionas_cvxr_expr
List available solversavailable_solvers exclude_solvers include_solvers set_excluded_solvers
Compute the gradient of a solution with respect to Parametersbackward
Construct a Block Matrixbmat
Callback ParameterCallbackParam
Global Monthly and Annual Temperature Anomalies (degrees C), 1850-2015 (Relative to the 1961-1990 Mean) (May 2016)cdiac
Elementwise Ceilingceil_expr
Condition number of a PSD matrixcondition_number
Create a Constant ExpressionConstant
Get the Constants in an Expressionconstants
Get Problem Constraints (read-only)constraints
1D discrete convolutionconv
1D discrete convolution (numpy-style)convolve
Cumulative maximum along an axiscummax_expr
Cumulative sum along an axiscumsum_axis
Get Expression Curvaturecurvature
Conditional Value at Risk (CVaR)cvar
Compute kth Order Differences of an Expressioncvxr_diff
Mean of an expressioncvxr_mean
Compute a norm of an expressioncvxr_norm
Outer product of two vectorscvxr_outer
Standard deviation of an expressioncvxr_std std
Variance of an expressioncvxr_var
Access the perturbation 'delta' of a Variable or Parameterdelta delta<-
Apply the derivative of the solution map to perturbationsderivative
Extract Diagonal from a MatrixDiagMat
Vector to Diagonal MatrixDiagVec
The difference x - y with domain x > y > 0diff_pos
Distance ratiodist_ratio
Weighted sorted dot productdotsort
Direct Standardization: Populationdspop
Direct Standardization: Sampledssamp
Get the Dual Value of a Constraintdual_value
Create an entropy atom -x * log(x)entr
Create an Equality ConstraintEquality
Create an Exponential Cone ConstraintExpCone
Conjugate-Transpose of an Expressionexpr_H
Get the DCP Sign of an Expressionexpr_sign
Unity resolvent (I - X) inverse for positive square matrix Xeye_minus_inv
FiniteSet ConstraintFiniteSet
Elementwise Floorfloor_expr
Pretty-print an expression with labels substitutedformat_labeled
Maximum generalized eigenvaluegen_lambda_max
(Weighted) geometric mean of a vectorgeo_mean
Lower/Upper Bounds of a Leafget_bounds
Get Problem Data for a Solver (deprecated)get_problem_data
Geometric matrix multiplication A diamond Xgmatmul
Access the gradient of a Variable or Parametergradient gradient<-
Harmonic mean: n / sum(1/x_i)harmonic_mean
Horizontal concatenation of expressionshstack
Create a Huber loss atomhuber
Get Expression IDid
Logical Biconditionaliff
Logical Implicationimplies
Indicator function for constraintsindicator
Create an Inequality ConstraintInequality
List installed solversinstalled_solvers
Inverse position: x^{-1} (for x > 0)inv_pos
Reciprocal of product of entriesinv_prod
Check if an Expression is Affineis_affine
Check if an Atom is Smoothis_atom_smooth
Check if an Expression is Concaveis_concave
Check if an Expression is Constantis_constant
Check if an Expression is Convexis_convex
Check if an Expression is DCP-Compliantis_dcp
Check if a Constraint is DGP-Compliantis_dgp
Check if an Expression or Problem is DNLP-Compliantis_dnlp
Check DPP Complianceis_dpp
Check if Expression is DQCP-Compliantis_dqcp
Check if an Expression is Linearizable-Concaveis_linearizable_concave
Check if an Expression is Linearizable-Convexis_linearizable_convex
Check if Expression is Log-Log Affineis_log_log_affine
Check if Expression is Log-Log Concaveis_log_log_concave
Check if Expression is Log-Log Convexis_log_log_convex
Check if a Problem is a Linear Programis_lp
Is the Expression a Matrix?is_matrix
Check if a Problem is Mixed-Integeris_mixed_integer
Check if Expression is Non-Negativeis_nonneg
Check if Expression is Non-Positiveis_nonpos
Check if Expression is Negative Semidefiniteis_nsd
Check if Expression is Positive Semidefiniteis_psd
Check if Expression is Piecewise Linearis_pwl
Check if a Problem is a Quadratic Programis_qp
Check if an Expression is Quadraticis_quadratic
Check if Expression is Quasiconcaveis_quasiconcave
Check if Expression is Quasiconvexis_quasiconvex
Check if Expression is Quasilinearis_quasilinear
Is the Expression a Scalar?is_scalar
Check if an Expression is Smoothis_smooth
Check if Expression is Symmetricis_symmetric
Is the Expression a Vector?is_vector
Check if Expression is Zerois_zero
KL Divergence: x*log(x/y) - x + ykl_div
Kronecker product of two expressionskron
Get the label of an expressionlabel
Set the label of an expressionlabel<-
Maximum eigenvaluelambda_max
Minimum eigenvaluelambda_min
Sum of largest k eigenvalueslambda_sum_largest
Sum of smallest k eigenvalueslambda_sum_smallest
Length of a Vector (Last Nonzero Index)length_expr
Log-determinantlog_det
Elementwise log of the standard normal CDFlog_normcdf
Log-sum-exp: log(sum(exp(x)))log_sum_exp
Log(1 + x) - elementwiselog1p_atom log1p_expr
Elementwise log of the gamma functionloggamma
Logistic function: log(1 + exp(x)) - elementwiselogistic
Make a CSC sparse diagonal matrixmake_sparse_diagonal_matrix
Standard R Functions for CVXR Expressionsdiag math_atoms norm outer sd var
Matrix fractional functionmatrix_frac
Trace of a square matrix expressionmatrix_trace
Elementwise maximum of expressionsmax_elemwise
Maximum entry of an expressionmax_entries
Create a Maximization ObjectiveMaximize
Elementwise minimum of expressionsmin_elemwise
Minimum entry of an expressionmin_entries
Create a Minimization ObjectiveMinimize
Mixed norm (L_{p,q} norm): column-wise p-norm, then q-normmixed_norm
Elementwise multiplication (deprecated)multiply
Get Expression Namename
Negative part: -min(x, 0)neg
Create a Non-Negative ConstraintNonNeg
Create a Non-Positive ConstraintNonPos
L-infinity norm of an expressionnorm_inf
Nuclear norm (sum of singular values)norm_nuc
L1 norm of an expressionnorm1
Euclidean norm (deprecated alias)norm2
Standard Normal Cumulative Distribution Functionnormcdf
Logical NOTNot
Get Problem Objective (read-only)objective
The difference 1 - x with domain (0, 1)one_minus_pos
Logical OROr
General p-norm of an expressionp_norm
Get all Parameters of a Problem as a Named Listparam_dict
Create a ParameterParameter
Get the Parameters in an Expressionparameters
Partial optimization transformpartial_optimize
Partial trace of a tensor product expressionpartial_trace
Partial transpose of a tensor product expressionpartial_transpose
Perspective Transformperspective
Perron-Frobenius eigenvalue of a positive matrixpf_eigenvalue
Positive part: max(x, 0)pos
Create a 3D Power Cone ConstraintPowCone3D
Create an N-Dimensional Power Cone ConstraintPowConeND
Create a Power atompower
Create an Optimization ProblemProblem
Get Problem Data for a Solverproblem_data
Get the Raw Solution Object (deprecated)problem_solution
Get the Solution Status of a Problem (deprecated)problem_status
Unpack Solver Results into a Problemproblem_unpack_results
Product of entries along an axisprod_entries
Create a Positive Semidefinite ConstraintPSD
Solve a Convex Optimization Problempsolve
Peak-to-peak (range): max(x) - min(x)ptp
Quadratic form x^T P xquad_form
Sum of squares divided by a scalarquad_over_lin
Reduction chain-rule hooks (dict-in / dict-out)param_backward param_forward reduction-chain-rule var_backward var_forward
Reduction leaf-id mapsparam_id_map reduction-id-map var_id_map
Relative Entropy: x*log(x/y)rel_entr
Reshape an expression to a new shapereshape_expr
Get the Residual of a Constraintresidual
Resolvent inverse(sI - X)resolvent
Sampling Bounds for NLP Random Restartssample_bounds sample_bounds<-
Scalar product (alias for vdot)scalar_product
Scalarize multiple objectives into a single objectivescalarize
Scalene penalty: alpha * pos(x) + beta * neg(x)scalene
Attach a label to an expressionset_label
Maximum singular valuesigma_max
Get Expression Sizesize
Get Size Metrics for a Problemsize_metrics
Problem Size MetricsSizeMetrics
Create a Second-Order Cone ConstraintSOC
Get the Raw Solution Objectsolution
Solve via Raw Datasolve_via_data
Standard Solver Parameter Mappingssolver_default_param
Create Solver Optionssolver_opts
Get Solver Statisticssolver_stats
Solver Name ConstantsCLARABEL_SOLVER COPT_SOLVER CPLEX_SOLVER CVXOPT_SOLVER DIFFCP_SOLVER ECOS_BB_SOLVER ECOS_SOLVER GLPK_MI_SOLVER GLPK_SOLVER GUROBI_SOLVER HIGHS_SOLVER IPOPT_SOLVER KNITRO_SOLVER MOSEK_SOLVER OSQP_SOLVER PIQP_SOLVER SCIP_SOLVER SCS_SOLVER solver-constants UNO_SOLVER XPRESS_SOLVER
Square of an expression: x^2square
Get the Solution Status of a Problemstatus
Solution Status ConstantsINFEASIBLE INFEASIBLE_INACCURATE INFEASIBLE_OR_UNBOUNDED OPTIMAL OPTIMAL_INACCURATE SOLVER_ERROR status-constants UNBOUNDED UNBOUNDED_INACCURATE USER_LIMIT
Sum the entries of an expressionsum_entries
Sum of k largest entriessum_largest
Sum of k smallest entriessum_smallest
Sum of squares (= quad_over_lin(x, 1))sum_squares
Convert CVXR Object to LaTeXto_latex
Total variation of a vector or matrixtotal_variation
Trace of matrix inversetr_inv
Total variation (deprecated alias)tv
Unpack Results (backward-compatible alias)unpack_results
Extract strict upper triangle of a square matrixupper_tri
Get the Numeric Value of an Expressionvalue
Set the Value of a Leaf Expressionvalue<-
Get all Variables of a Problem as a Named Listvar_dict
Create an Optimization VariableVariable
Get the Variables in an Expressionvariables
Vector dot product (inner product)vdot
Vectorize an expression (column vector)vec
Reshape a vector into an upper triangular matrixvec_to_upper_tri
Get the Violation of a Constraintviolation
Visualize the Canonicalization Pipeline of a CVXR Problemvisualize
Vertical concatenation of expressionsvstack
x * exp(x) - elementwisexexp
Logical XORXor
Create a Zero ConstraintZero