Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

Variable-class

The Variable class.


Description

This class represents an optimization variable.

Usage

Variable(rows = NULL, cols = NULL, name = NA_character_, ...)

## S4 method for signature 'Variable'
as.character(x)

## S4 method for signature 'Variable'
name(x)

## S4 method for signature 'Variable'
value(object)

## S4 method for signature 'Variable'
grad(object)

## S4 method for signature 'Variable'
variables(object)

## S4 method for signature 'Variable'
canonicalize(object)

Arguments

rows

The number of rows in the variable.

cols

The number of columns in the variable.

name

(Optional) A character string representing the name of the variable.

...

(Optional) Additional attribute arguments. See Leaf for details.

x, object

A Variable object.

Methods (by generic)

  • name: The name of the variable.

  • value: Get the value of the variable.

  • grad: The sub/super-gradient of the variable represented as a sparse matrix.

  • variables: Returns itself as a variable.

  • canonicalize: The canonical form of the variable.

Slots

dim

The dimensions of the variable.

name

(Optional) A character string representing the name of the variable.

Examples

x <- Variable(3, name = "x0") ## 3-int variable
y <- Variable(3, 3, name = "y0") # Matrix variable
as.character(y)
id(y)
is_nonneg(x)
is_nonpos(x)
size(y)
name(y)
value(y) <- matrix(1:9, nrow = 3)
value(y)
grad(y)
variables(y)
canonicalize(y)

CVXR

Disciplined Convex Optimization

v1.0-10
Apache License 2.0 | file LICENSE
Authors
Anqi Fu [aut, cre], Balasubramanian Narasimhan [aut], David W Kang [aut], Steven Diamond [aut], John Miller [aut], Stephen Boyd [ctb], Paul Kunsberg Rosenfield [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.