Repository navigation
CVXR 1.9.3
Changed results
These fix wrong answers, so code that relied on the old results will see
different numbers.
- GUROBI solved quadratic objectives with cross terms (e.g.
quad_form(w, Sigma)) with every cross term halved. Gurobi now receives
the full matrix, as in CVXPY. Present in 1.9.2. - CVXOPT returned wrong answers on problems with no inequality constraints
(feasible equality-constrained problems were reported infeasible) and
reported unbounded problems as optimal. These now solve correctly or fail
with a solver error, as in CVXPY. - GUROBI second-order-cone dual values had the wrong sign; they now agree
with CVXPY and with every other solver. cvxr_norm(X, p)andnorm(X, type)now agree with base R'snorm()and
CVXPY on matrices: with noaxis,p = 1,2andInfare the maximum
absolute column sum, the largest singular value and the maximum absolute
row sum. They were entrywise; usecvxr_norm(X, "fro")ornorm1(X)for
those.- A row vector is a 1 x n matrix, as in base R, so its 1- and Inf-norms
are the other way round from before. - Any other
pon a matrix or row vector is now an error, "Unsupported
matrix norm.", as in CVXPY; usep_norm(x, p)for the entrywise norm. norm()on an expression accepts every base R type ("O","M"and
"E"failed, and"I"was the largest absolute entry). With notype
it is the spectral norm ("2"), as in CVXPY.
- A row vector is a 1 x n matrix, as in base R, so its 1- and Inf-norms
gmatmul(A, X)with aParameterin bothAandXgave a wrong answer
undergp = TRUE, and parameter substitution rebuilt it withAandX
swapped. Both fixed (CVXPY 1.9.3 still has the swap).x / Awith a matrix or vectorAdivided every entry ofxbyA[1, 1].
It now divides entrywise, as in CVXPY. Division by a scalar is unchanged.
Present in 1.9.2.- Constants built from Matrix classes other than
dgCMatrixgave wrong
answers or errors: a unitDiagonal(n)was read as all zeros, so
quad_form(x, Diagonal(n))was unbounded, and symmetric, triangular,
triplet, pattern and logical sparse matrices failed in canonicalization.
Every sparse input is now stored as a general doubledgCMatrix, as in
CVXPY, and a logical matrix constant keeps its shape instead of becoming a
column. Present in 1.9.2. - A sparse
boundsmatrix was applied only at its stored entries, so a
symmetric (dsCMatrix) bound on a dense variable left half the entries
unbounded and a triplet matrix with repeated entries used the first copy.
As in CVXPY, a sparse bound is now accepted only on asparsityvariable
with the same pattern, and repeated entries are summed. Solvers that take
variable bounds natively (HiGHS, GUROBI, SCIP, XPRESS) now receive such
bounds as bounds rather than as constraints. Present in 1.9.2. - A warm re-solve with CLARABEL or OSQP after a parameter became zero (or
nonzero) pushed the new coefficients into the solver's old sparsity pattern,
returning the previous optimum with status optimal, or an OSQP error. Both
now start a fresh solver when the pattern changes, as PIQP already did.
Present in 1.9.2. - The cached DGP, DQCP and problem-level curvature queries ignored whether a
DPP check was running, so a DGP problem with parameters could be reported
DPP and solved with wrong solver data. All caches are now keyed on the DPP
scope, as CVXPY's are. perspective()of a function of asymmetric,PSDorNSDmatrix
variable of size 3 or more returned a wrong optimum.sum_entries(x, axis = 2)of a one-row expression gave wrong results or
crashed R. Present in 1.9.2.%*%with a scalar operand that does not conform (2 %*% xfor a 2 x 3
x) or a non-conforming 1 x 1 operand built a product that gave a scalar
product or crashed R. Both are now errors, as in base R; use*to
multiply by a scalar. A scalar operand that conforms (x %*% 2for a
3 x 1x) is a product, as in base R.x / dwith shapes that do not broadcast, such as a 2 x 3xand a
length-3d, recycled the divisor silently. It is now an error, as in
CVXPY; a row or column divisor still broadcasts.value()of a sum, a product or an index of a sparse-matrix constant failed
with "non-conformable arrays" or "subscript out of bounds", and a sum of two
sparse constants came back flattened to one column. These now evaluate; a
mixed sparse and dense result is a base matrix, a sparse one stays sparse.sum(),max(),min()andprod()of an expression now honoraxis
andkeepdims, as in CVXPY. A namedaxiswas taken as one more operand,
sosum(x, axis = 2)returnedsum(x + 2). Any other name labels an
operand, as inbase::sum(), sosum(a = x)anddo.call(sum, parts)
with a named list work as before.sum(),prod(),max()andmin()with more than one operand now mean
what they mean in base R: each operand is reduced on its own and the
results combined, sosum(x, 2)issum(x) + 2andmax(x, y)is one
scalar, the largest entry of either. They weresum(x + 2),prod(x * y)
and the elementwise maximum and minimum; usemax_elemwise()and
min_elemwise()for those.matrix_trace(A * B)returned the trace of the matrix product (CVXPY
1.9.3, #3492).cumsum(X)of a matrix expression is now column-wise, as in CVXPY and as
cumprod()andcummax()already were;value()and the solver used to
disagree.cumsum_axis(X, axis = NULL)gives all entries in column-major
order as a column.lambda_sum_largest(X, k)accepts a fractionalk, as CVXPY does;k
was silently truncated.- Bounds through
min_elemwise()andmax_elemwise()with operands of
different shapes now broadcast as NumPy does; a row operand was permuted. derivative()andbackward()through a Hermitian variable or parameter
of size 4 or more had imaginary entries transposed.backward()through asparsityvariable returned garbage, and on the NLP
path the bounds of asparsityvariable were dropped. A recovered
variable value is now projected onto its attribute (anonneg-1e-9 reads
back as 0), as in CVXPY.psolve(solver = "CLARABEL", warm_start = TRUE)re-solves from scratch
when the cones changed (e.g. a parametric power-cone exponent), instead of
returning the previous optimum. CVXPY 1.9.3 still has this defect.- A complex variable declared
PSD/NSDlost its cone (#3342), and one
declareddiagor with asparsitypattern solved as dense (CVXPY 1.9.3
still ignores those). Both are now enforced. conv(),cumsum()andkron()were treated as log-log affine, so a
geometric program containing them was accepted and could solve to a wrong
value. They are now not DGP, as in CVXPY, and such a problem is rejected.- Calling
problem_data()(orget_problem_data()) on a geometric program
between two solves made the next solve after a parameter change return the
previous optimum.problem_data()now goes through the same compile cache
aspsolve(), as in CVXPY. max_elemwise()andmin_elemwise()of a column and a row recycled
instead of broadcasting, sopsolve()returned a wrong objective and a
second solve failed.log(x, base)on an expression ignoredbaseand gave the natural log.
It now honorsbase, which must be a positive number other than 1.outer(x, y, FUN)on an expression ignoredFUNand gave the product. Any
FUNother than"*"is now an error.x[NULL, ]andx[NULL]on an expression returned all ofx. ANULL
subscript is now an error.x[c(TRUE, NA, FALSE), ]on an expression dropped theNA. AnNAor
character subscript is now a clear error instead of an obscure one.diag(x, nrow)on an expression ignorednrow.nrow,ncolandnames
are now errors there; the offset isk.log1p(x)on an expression is now thelog1patom instead oflog(x + 1),
so it is accurate near 0 and keeps the sign ofx.
New features
geo_mean()accepts an argument of any shape and gainsaxisand
keepdims(CVXPY 1.9.3, #3493).cvxr_var()supportsaxisandkeepdims, likecvxr_mean()and
cvxr_std()(#3496).cvxr_norm(X, "nuc")returns the nuclear norm (it errored).- Exact
geo_mean(x, approx = FALSE), and anyPowConeNDconstraint, now
solve on SCS and MOSEK, not just Clarabel.PowConeND()with a row-vector
z, or a 1 x nWwithaxis = 1, now works and has correct duals. perspective(f, s)wherefneeds a positive semidefinite cone (for
examplelambda_max()orsigma_max()) now solves on Clarabel, SCS and
MOSEK.grad()works forpartial_optimize()expressions and
lambda_sum_largest(), and is correct for complex arguments of
norm_nuc(),sigma_max(),quad_form(),quad_over_lin()and
matrix_frac().indicator()andpartial_optimize()expressions now have bounds, as in
CVXPY:(0, Inf)for an indicator and unbounded for a partial problem.- A quadratic objective over a
symmetric,PSD,NSD,diagor
sparsityvariable now solves on QP-capable solvers (#3384), and
quad_over_lin()/sum_squares()with anaxistake the QP path, so
OSQP accepts them. - DNLP (
psolve(..., nlp = TRUE)) now needssparsediff (>= 0.6.1)
and consequences thereof. It also acceptsNonNeg(),NonPos()and
Zero()constraints, which it used to abort on. - New
curvatures(),log_log_curvature()andis_diag(), as CVXPY's
Expression.curvatures,Expression.log_log_curvatureand
Leaf.is_diag(). curvature()now reports log-log and quasi curvature (e.g.
"LOG-LOG CONVEX","QUASILINEAR") instead of"UNKNOWN", as in CVXPY.
DPP, DGP and DQCP
psolve()now checks that everyParameterhas a value before it starts
any solve, as CVXPY does.psolve(gp = TRUE)now checks variable bounds when deciding whether a
parameterized problem is DPP, as CVXPY does, and requires a conic solver.is_dpp()is now one DCP pass inside the DPP scope, as in CVXPY, instead of
that pass plus a recursion over every argument.- These are no longer DPP, as in CVXPY:
quad_over_lin(x, p)with a
Parameterdenominator (#2433), aPowCone3D()/PowConeND()with a
Parameterexponent, anddotsort(x, W)with a non-affine parametric
W.gmatmul(A, X)requires a parametricAto be theParameter
itself.cumsum()of aParameteris DPP (#3398). psolve(requires_grad = TRUE)checks match CVXPY: a non-DPP problem is a
DPPError,qcp = TRUEis refused, andsolver = "SCS"routes to
DIFFCP.- DQCP bisection now follows CVXPY: no extra solve at the upper end of an
automatically found interval, sub-solve warnings reach the user, a failed
query point warns and bisection continues, and its aborts carry class
SolverError.
Solvers
- Solver selection now follows CVXPY 1.9: the solver is chosen from the
problem's structure first, and its interface (QP or conic) follows. The
commercial-first default covers QPs and mixed-integer QPs, SCIP solves
mixed-integer QPs, a named HiGHS, Gurobi, CPLEX or Xpress solves an LP
through its conic interface, and falling back to a non-default solver
warns. ECOS_BB is never chosen unless named. - When no installed (or non-excluded) solver can be used, the error now reads
"No installed solver could handle this problem.", as in CVXPY. psolve(solver_path = ...)forwards everypsolve()argument to each
attempt (enforce_dpp,ignore_dppandnlpwere dropped), and only a
SolverErrormoves on to the next solver, as in CVXPY. The conditions
CVXPY raises asSolverErrornow carry that class in R too.- MOSEK: the status comes from the solution status, as in CVXPY, so a
termination code such as an iteration or time limit is no longer an error
by itself. The simplex optimizers work, andbfs = TRUEand
save_file = <path>are accepted. - HiGHS: options may be nested in a
highs_optionslist, as in CVXPY, and
an option HiGHS rejects is an error instead of being dropped. A stop on
mip_max_improving_solsreturns the incumbent with statususer_limit. - Gurobi:
warm_start = TRUEseeds the start point from the variables'
values,save_filewrites the model, andenvis rejected, as in CVXPY.
solver_stats(prob)@num_itersis 0 instead ofNULLwhen presolve
finished the problem. - CPLEX:
reoptimize = TRUEre-solves with presolve off on "infeasible or
unbounded", as in CVXPY;solve_timeis set; unknown options abort. A
continuous problem with a second-order cone now returns dual values (all
were missing), as in CVXPY. - SCS: an infeasible solve exposes the infeasibility certificate through
dual_value()(#3197), andextra_statsis the full SCS result. solver_stats(prob)@extra_statsnow carries the raw solver result for
OSQP, ECOS, ECOS_BB, Gurobi, DIFFCP, HiGHS and PIQP, as CVXPY does, and
solution(prob)holds only the problem's own variables.- PIQP:
backend = "dense"builds a dense model (it was silently sparse). - XPRESS: a
write_mpspath that cannot be written is an error (it was
silently skipped), and a failed optimization reports the solver's message
as a warning before the solver-error status. - GLPK_MI: an infeasible mixed-integer problem has status
infeasible, as
in CVXPY; it failed with a solver error. GLPK's presolve is now on by
default (passpresolve = FALSEto turn it off). - Solving no longer advances R's random number stream. Compilation drew
from it (sixteen uniforms per expression node, for an internal debugging
label), so random draws afterpsolve()differed from the same draws
without the solve. Present in every earlier version.
Errors, warnings and other changes
diag()on an ordinary R matrix or vector now behaves exactly as base R's
diag():diag(nrow = 3)andnames = FALSEwork, andk(expressions
only) is an error instead of being ignored.norm(A)on an ordinary R matrix without atypenow uses base R's
default one-norm ("O"), not the spectral norm; expressions keep"2".convolve()on ordinary numeric vectors now returns exactly
stats::convolve()'s result, with itsconjandtypearguments, as the
1.9.2 NEWS promised; expressions still get the numpy-style convolution.sd()andvar()on an expression arecvxr_std()andcvxr_var()
(ddof 0, as in CVXPY);na.rm,useand a second variableynow give a
clear error instead of an obscure one.mean()on an expression iscvxr_mean();trimandna.rmnow give a
clear error, and an axis other than 1 or 2 (such as1.5) is an error
instead of being truncated.- A non-scalar constant exponent (
x^c(1, 2),power(x, c(1, 2))) is now a
clear error; withapprox = FALSEit was silently accepted. - New
cvxr_power(), the same function aspower().power()masks the
unrelatedstats::power(), aglm()link, so with CVXR attached write
stats::power()in aglm()family. - Variable
boundsaccept a 1-d array, asparseVectorand a sparse matrix
with unsorted row indices, whichConstant()already accepted. power(x, p)now takes its sign, curvature, domain, value and printed name
frompas written, as CVXPY does, rather than from the rational
approximation used to solve it.- Calling
NonPos(expr)explicitly now warns, once per session, that it is
deprecated in favor of operator overloading (expr <= 0) or
NonNeg(-expr), in CVXPY's words and with class
CvxpyDeprecationWarning. - Now errors, as in CVXPY: a negative
axis; anaxiswith
cvxr_norm(X, "fro")or"nuc"(#3501); a complex variable declared
nonneg,nonpos,pos,negor withbounds, which were silently
ignored (#3342);partial_optimize()of a complex inner problem. - Whether a constant matrix is symmetric, Hermitian or skew-symmetric is now
decided with NumPy'sallclosetolerance (relative 1e-5, absolute 1e-8), as
in CVXPY;quad_form(x, P)used to reject aPthat CVXPY accepts. - Smaller alignments with CVXPY 1.9.3 in
get_bounds(),grad()and
domain()of several atoms,dual_cone(),is_symmetric()ofRe(X),
constr_size(),is_dpp()with an unsupported context, interval
bounds of matrix products, andis_quadratic()ofx / ywith a
non-constanty(nowFALSE).value(constraint, tolerance = )exposes the
violation tolerance. visualize()no longer errors on a problem containingsqrt(),
inv_pos()or a fractionalpower()(broken in 1.9.2).cvxr_norm(x, p)with a stringpthat is not a norm name reports
"Unsupported norm option", as CVXPY does; it was an R internal error.
Assigning a sparse value containingInfto a sparsity variable works;
it was an R internal error.max_elemwise()andmin_elemwise()takena.rm, andhstack()and
vstack()takedeparse.level, aspmax()andrbind()do; neither has
an effect.max_elemwise(u, v, na.rm = TRUE)used to takeTRUEas a
third operand. Named operands, as fromdo.call(vstack, split(...)), are
accepted as before.residual()andviolation()of anSOCconstraint whose value is a
sparse matrix are right; they were garbage or an error. APowConeND
with a sparsealphakeeps one cone per column on solvers with native
N-dimensional power cones. A sparse constant prints as[n x m matrix].norm1()andlog_sum_exp()with anaxisevaluate on a sparse value;
they were an error. So dolength_expr()andlog_det(), and
visualize()shows a 1x1 sparse constant as its number.matrix_frac(x, P)with a non-square constantPreports the shape
error; it saidPwas singular.length_expr(),eye_minus_inv(),huber()anddotsort()reject a
complex argument, as CVXPY does; they accepted one.- Problems with no constraint rows no longer trigger the Matrix deprecation
warningas(<ngCMatrix>, "dgCMatrix") is deprecated, and Gurobi QPs no
longer trigger thedtCMatrixone. - Internal: a conic solver's
reduction_accepts()now refuses a
mixed-integer problem when the solver is not MIP-capable, as CVXPY's
ConicSolver.acceptsdoes.psolve()already refused such a solve while
choosing the solver, so no solve changes.constr_expr()returns
lhs - rhsfor==,<=and>=, as CVXPY's.exprdoes.
Performance
- The first solve of a parametric (DPP) problem compiles about twice as fast
and allocates a small fraction of the memory it did: at 500 variables with
CLARABEL,sum_squares(w - q)goes from 21 ms / 24 MB to 11 ms / 0.9 MB, an
SOC problem from 17.5 ms / 12.7 MB to 12 ms / 0.9 MB, an LP with a 100 x 500
dense matrix from 55 ms / 23 MB to 50 ms / 8 MB. - A DPP problem whose objective is quadratic in the variables and depends on
parameters (sum_squares(y - q),quad_form(y, P) + t(q) %*% y, ...) now
keeps its parameter program across solves, as in CVXPY. - The compiled-chain cache is keyed as CVXPY's is, on the solver,
gp,
ignore_dppanduse_quad_obj;enforce_dppno longer takes part. - DQCP bisections are 7 percent and medium LPs 4 percent faster than in
CVXR 1.9.2. - Bounds propagation keeps a sparse constant sparse, as CVXPY does; it
densified it, soabs(A %*% x)with a large sparseAon HiGHS, Gurobi,
SCIP or XPRESS allocated two dense copies ofA. psolve(nlp = TRUE)hands a dense constant matrix with at least 5 percent
nonzeros to the derivative engine as dense, as CVXPY does: 1.7 to 2.6 times
faster for a dense 1000 x 1000A. Pass a sparseMatrixto keep the
sparse form for a structured matrix.psolve(nlp = TRUE)no longer makes dense copies of a sparse constant
matrix while building the problem: a solve with a 3000 x 3000 one allocated
208 MB and now allocates 2 MB.