R/150_reductions_dcp2cone_canonicalizers_entr_canon.R

Defines functions entr_canon

#####
## DO NOT EDIT THIS FILE!! EDIT THE SOURCE INSTEAD: rsrc_tree/reductions/dcp2cone/canonicalizers/entr_canon.R
#####

## CVXPY SOURCE: reductions/dcp2cone/canonicalizers/entr_canon.py
## -x*log(x) >= t iff ExpCone(t, x, 1)


entr_canon <- function(expr, args, solver_context = NULL) {
  x <- args[[1L]]
  shape <- expr@shape
  t <- Variable(shape = shape)
  ones <- Constant(matrix(1, nrow = shape[1L], ncol = shape[2L]))
  constraints <- list(ExpCone(t, x, ones))
  list(t, constraints)
}

method(dcp_canonicalize, Entr) <- entr_canon
method(has_dcp_canon, Entr) <- function(expr) TRUE

Try the CVXR package in your browser

Any scripts or data that you put into this service are public.

CVXR documentation built on March 6, 2026, 9:10 a.m.