R/195_reductions_dgp2dcp_canonicalizers_constant_canon.R

Defines functions .dgp_constant_canon

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

## CVXPY SOURCE: reductions/dgp2dcp/canonicalizers/constant_canon.py
## DGP canonicalizer for Constant: log-transform the value

.dgp_constant_canon <- function(expr, args) {
  val <- value(expr)
  ## G10: validate positivity
  if (any(val <= 0)) {
    cli_abort("DGP requires strictly positive constants, but got non-positive value.")
  }
  list(Constant(log(val)), list())
}

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.