expression-parts {CVXR}R Documentation

Parts of an Expression Leaf

Description

List the variables, parameters, constants, or atoms in a canonical expression.

Usage

variables(object)

parameters(object)

constants(object)

atoms(object)

Arguments

object

A Leaf object.

Value

A list of Variable, Parameter, Constant, or Atom objects.

Examples

set.seed(67)
m <- 50
n <- 10
beta <- Variable(n)
y <- matrix(rnorm(m), nrow = m)
X <- matrix(rnorm(m*n), nrow = m, ncol = n)
lambda <- Parameter()

expr <- sum_squares(y - X %*% beta) + lambda*p_norm(beta, 1)
variables(expr)
parameters(expr)
constants(expr)
lapply(constants(expr), function(c) { value(c) })

[Package CVXR version 1.0-14 Index]