Nothing
#####
## DO NOT EDIT THIS FILE!! EDIT THE SOURCE INSTEAD: rsrc_tree/constraints/cones.R
#####
## CVXPY SOURCE: constraints/cones.py
## Cone -- base class for all conic constraints
##
## A thin subclass of Constraint that provides:
## - dual_cone() -- abstract, must be overridden by subclasses
## - dual_residual() -- computed from dual_cone + residual
Cone <- new_class("Cone", parent = Constraint, package = "CVXR")
# -- dual_cone: abstract on Cone ----------------------------------
## CVXPY SOURCE: cones.py lines 44-56 -- _dual_cone (raises NotImplementedError)
method(dual_cone, Cone) <- function(x, ...) {
cli_abort("{.fn dual_cone} not implemented for {.cls {class(x)[[1L]]}}.")
}
# -- explicit-args guard shared by the dual_cone methods ----------
## R-SPECIFIC helper (no single CVXPY counterpart). Every CVXPY `_dual_cone(*args)`
## asserts, on the explicit-args branch, that the args match the constraint's own
## args in count and shape -- exponential.py:159-163, power.py:149-153 and
## :323-327, second_order.py:190-194. The two asserts are hoisted here once and
## raised with cli_abort(). Claims-audit row C0334, ported 1.9.2.9137.
.dual_cone_check_args <- function(x, args) {
n <- length(x@args)
if (length(args) != n) {
cli_abort(
"{.fn dual_cone} expects {n} arguments for {.cls {class(x)[[1L]]}}, got {length(args)}."
)
}
same_shape <- mapply(
function(a, b) identical(as.integer(.shape(a)), as.integer(.shape(b))),
args, x@args
)
if (!all(same_shape)) {
cli_abort(
"{.fn dual_cone} arguments must have the shapes of the {.cls {class(x)[[1L]]}} arguments."
)
}
invisible(TRUE)
}
# -- dual_residual ------------------------------------------------
## CVXPY SOURCE: cones.py lines 58-66 -- dual_residual property
## Calls _dual_cone with dual variables, then returns residual of that cone.
method(dual_residual, Cone) <- function(x) {
dc <- do.call(dual_cone, c(list(x), x@dual_variables))
residual(dc)
}
# -- print --------------------------------------------------------
method(print, Cone) <- function(x, ...) {
cat(expr_name(x), "\n")
invisible(x)
}
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.