forceBalance: Force Balance

Description Usage Arguments Value Examples

Description

This function takes values and their signs, as well as whether or not certain elements are fixed, and it forces the equation to be balanced (if possible). It does not consider any errors in the variables, as this result is simply meant to be an initial parameter in the feasability space for future optimization.

Usage

1
2
3
forceBalance(value, sign, fixed, lowerBound = rep(0, length(value)),
  upperBound = rep(Inf, length(value)), standardError = rep(1,
  length(value)))

Arguments

value

A vector of the values in the balancing equation.

sign

A vector of negative 1's and positive 1's indicating whether an element is negative or positive in the balance (or, on the left vs. on the right side of the balance).

fixed

A vector of logicals indicating whether values are fixed or adjustable.

lowerBound

A vector of lower bounds for each element.

upperBound

A vector of upper bounds for each element.

standardError

A vector of the same length as value, used to prioritize where deltas should be allocated. Differences will first be allocated to the variable with the largest variability down to the variable with the smallest variability. Defaults to all 1's, as the relative magnitude is all that matters for the sorting.

Value

A vector of the same length as value, with values updated to satisfy the balance.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
## Example of positive adjusted down
faoswsBalancing:::forceBalance(value = c(100, 10, 30, 60), sign = c(1, 1, -1, -1),
             fixed = c(FALSE, TRUE, TRUE, TRUE), lowerBound = c(0,0,0,0))
## Example of negative adjusted down
faoswsBalancing:::forceBalance(value = c(100, 10, 50, 80), sign = c(1, 1, -1, -1),
             fixed = c(TRUE, TRUE, FALSE, TRUE), lowerBound = c(0,0,0,0))
## Example of multiple adjustments
faoswsBalancing:::forceBalance(value = c(10, 10, 30, 50), sign = c(1, 1, -1, -1),
             fixed = c(TRUE, TRUE, FALSE, FALSE), lowerBound = c(0,0,0,0))
## Example of non-zero lower bound
faoswsBalancing:::forceBalance(value = c(10, 10, 30, 50), sign = c(1, 1, -1, -1),
             fixed = c(TRUE, TRUE, TRUE, FALSE), lowerBound = c(0,0,0,-Inf))

SWS-Methodology/faoswsBalancing documentation built on May 9, 2019, 11:47 a.m.