Nothing
#####
## DO NOT EDIT THIS FILE!! EDIT THE SOURCE INSTEAD: rsrc_tree/reductions/dcp2cone/canonicalizers/quad/huber_canon.R
#####
## CVXPY SOURCE: reductions/dcp2cone/canonicalizers/quad/huber_canon.py
## huber(x, M) = n^2 + 2*M*|s| where x = s + n
## Uses power_quad_canon for n^2 (produces SymbolicQuadForm)
## and abs_canon for |s| (produces linear + constraints)
huber_quad_canon <- function(expr, args, solver_context = NULL) {
M <- expr@M
x <- args[[1L]]
shape <- expr@shape
n <- Variable(shape = shape)
s <- Variable(shape = shape)
## n^2 via power_quad_canon -> SymbolicQuadForm
power_expr <- power(n, 2)
n2_result <- power_quad_canon(power_expr, power_expr@args)
n2 <- n2_result[[1L]]
constr_sq <- n2_result[[2L]]
## |s| via abs_canon (linear + constraints)
abs_expr <- Abs(s)
abs_result <- abs_canon(abs_expr, abs_expr@args)
abs_s <- abs_result[[1L]]
constr_abs <- abs_result[[2L]]
obj <- n2 + 2 * M * abs_s
## x == s + n
constraints <- c(constr_sq, constr_abs, list(x == s + n))
list(obj, constraints)
}
method(quad_canonicalize, Huber) <- huber_quad_canon
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.