flatten_constraints: Flatten constraint matrix

Description Usage Arguments Value Examples

Description

Given a matrix (described below), this will create a list of vectors which give the locations of unconstrained, constrant, positive, and negative elements.

Usage

1

Arguments

x

Numeric matrix with NA for unconstrained elements, a finite value for constrant entries, Inf for elements to be bound below at 0, and -Inf for elements to be bound above at 0.

Value

list with elements

var_n

Number of unstrained entries

var_i

Indices of unconstrained entries

const_n

Number of constant entries

const_val

Values of constant entries

const_i

Indices of constant entries

pos_n

Number of positive entries (truncated below at 0)

pos_i

Indices of positive entries

pos_n

Number of negative entries (truncated above at 0)

Examples

1
2
3
4
5
6
7
8
9
constraints <- matrix(NA, 4, 2)
# constants
constraints[1, 1] <- 1
constraints[1, 2] <- 0
# positive values
constraints[2, 1] <- Inf
# negative values
constraints[2, 2] <- -Inf
flatten_constraints(constraints)

jrnold/flatter documentation built on May 20, 2019, 1:01 a.m.