Nothing
#####
## DO NOT EDIT THIS FILE!! EDIT THE SOURCE INSTEAD: rsrc_tree/reductions/cone2cone/cone_tree.R
#####
## CVXPY SOURCE: reductions/cone2cone/cone_tree.py
## Tree node types for balanced binary tree decomposition of cones.
## Used by ExactCone2Cone (PowNDConversion, reductions/cone2cone/exact.R).
## Upstream also uses them in SOCDim3, which CVXR does not implement
## (reductions/cone2cone/soc_dim3.R is a stub).
##
## Upstream nodes are frozen dataclasses. Here they are plain classed lists:
## they are bookkeeping for dual recovery, not Expression-tree nodes. Cone ids
## and variable indices are 1-based (upstream: 0-based).
## CVXPY SOURCE: cone_tree.py lines 26-30
## Leaf node: a single 3D cone with original variable indices.
LeafNode <- function(cone_id, var_indices) {
structure(list(cone_id = as.integer(cone_id),
var_indices = as.integer(var_indices)),
class = c("LeafNode", "TreeNode"))
}
## CVXPY SOURCE: cone_tree.py lines 33-38
## Internal node combining two subtrees with a 3D cone.
SplitNode <- function(cone_id, left, right) {
structure(list(cone_id = as.integer(cone_id), left = left, right = right),
class = c("SplitNode", "TreeNode"))
}
## CVXPY SOURCE: cone_tree.py lines 41-44
## A single variable with no associated cone (n = 1 base case).
SingleVarNode <- function(var_index) {
structure(list(var_index = as.integer(var_index)),
class = c("SingleVarNode", "TreeNode"))
}
## CVXPY SOURCE: cone_tree.py lines 47-53
## Node for special cases (e.g., SOC dim-1, dim-2, dim-4).
SpecialNode <- function(node_type, cone_ids, var_indices, metadata = list()) {
structure(list(node_type = node_type, cone_ids = as.integer(cone_ids),
var_indices = as.integer(var_indices), metadata = metadata),
class = c("SpecialNode", "TreeNode"))
}
## CVXPY SOURCE: cone_tree.py lines 59-72
## All constraint ids in a tree.
get_all_cone_ids <- function(node) {
if (inherits(node, "LeafNode")) return(node$cone_id)
if (inherits(node, "SplitNode")) {
return(sort(unique(c(node$cone_id, get_all_cone_ids(node$left),
get_all_cone_ids(node$right)))))
}
if (inherits(node, "SpecialNode")) return(sort(unique(node$cone_ids)))
integer(0)
}
## CVXPY SOURCE: cone_tree.py lines 75-85
## All leaf nodes, left to right.
get_leaf_nodes <- function(node) {
if (inherits(node, "LeafNode")) return(list(node))
if (inherits(node, "SplitNode")) {
return(c(get_leaf_nodes(node$left), get_leaf_nodes(node$right)))
}
list()
}
## CVXPY SOURCE: cone_tree.py lines 88-96
## The constraint id of the root cone, or NULL.
get_root_cone_id <- function(node) {
if (inherits(node, c("LeafNode", "SplitNode"))) return(node$cone_id)
if (inherits(node, "SpecialNode") && length(node$cone_ids) > 0L) {
return(node$cone_ids[[length(node$cone_ids)]])
}
NULL
}
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.