Nothing
#####
## DO NOT EDIT THIS FILE!! EDIT THE SOURCE INSTEAD: rsrc_tree/reductions/solvers/utilities.R
#####
## CVXPY SOURCE: reductions/solvers/utilities.py
## Utility functions for solver dual value extraction
# -- extract_dual_value --------------------------------------------
## CVXPY SOURCE: utilities.py lines 53-58
## Extracts a slice of the dual result vector for a constraint.
extract_dual_value <- function(result_vec, offset, constraint) {
sz <- constr_size(constraint)
value <- result_vec[(offset + 1L):(offset + sz)]
if (sz == 1L) value <- as.numeric(value)
new_offset <- offset + sz
list(value = value, new_offset = new_offset)
}
# -- get_dual_values ----------------------------------------------
## CVXPY SOURCE: utilities.py lines 61-87
## Iterates over constraints, calling parse_func to extract dual values.
# -- expcone_permutor ---------------------------------------------
## CVXPY SOURCE: utilities.py expcone_permutor()
## Creates a permutation vector for reordering ExpCone dual variables.
## ECOS expects ExpCone args in order (x, z, y) but CVXR standard is (x, y, z).
expcone_permutor <- function(n_cones, exp_cone_order) {
order <- rep(exp_cone_order, n_cones)
offsets <- rep(seq(0L, by = 3L, length.out = n_cones), each = 3L)
order + offsets + 1L # +1 for R 1-based indexing
}
# -- get_dual_values ----------------------------------------------
## CVXPY SOURCE: utilities.py lines 61-87
## Iterates over constraints, calling parse_func to extract dual values.
get_dual_values <- function(result_vec, parse_func, constraints) {
dual_vars <- list()
offset <- 0L
for (constr in constraints) {
result <- parse_func(result_vec, offset, constr)
dual_vars[[as.character(constr@id)]] <- result$value
offset <- result$new_offset
}
dual_vars
}
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.