constraints.realized {PortfolioProbe} | R Documentation

## Show Violations of Linear Constraints

### Description

Returns a list of matrices containing the bounds, the achieved level, plus the amount it violates the nearest bound or else the proximity to the nearest bound if it is not violated. Components of the list correspond to linear (and count) constraints, and distance constraints.

### Usage

    constraints.realized(portfol, lin.constraints, prices = portfol$prices,
            lin.bounds = portfol$lin.realized[, c("lower", "upper"),
            drop=FALSE], lin.trade = portfol$lin.trade,
            lin.abs = portfol$lin.abs, lin.style = portfol$lin.style,
            lin.direction = portfol$lin.direction, exclude.inf = FALSE,
            dist.value=portfol$dist.value, dist.utility=portfol$dist.utility,
            dist.bounds=portfol$dist.bounds)

### Arguments

`portfol` | required. An object of class `portfolBurSt` (or a similar object).
`lin.constraints` | required. matrix or data frame describing the linear constraints.
`prices` | named vector of prices containing (at least) all of the assets involved with the constraints.
`lin.bounds` | a two-column matrix giving the bounds for the constraints described by the input `lin.constraints`.
`lin.trade` | logical vector stating which columns of `lin.constraints` refer to constraints on the trade (as opposed to on the portfolio). This is replicated if necessary.
`lin.abs` | logical vector stating which columns of `lin.constraints` are absolute constraints (constraints on the gross as opposed to the net). This is replicated if necessary.
`lin.style` | character vector stating the style of each of the linear constraints.
`lin.direction` | numeric vector stating the direction of each of the linear constraints.
`exclude.inf` | logical value stating whether or not (sub)constraints whose bounds are both infinite should be dropped. If all bounds are infinite, this is effectively forced to be `FALSE`.
`dist.value` | numeric vector stating the value attained for the distances.
`dist.utility` | logical vector stating which distances are used in the utility rather than being constrained.
`dist.bounds` | numeric two-column matrix giving the bounds for the distances.

### Value

a list with zero, one or two components. The components correspond to linear (plus count) constraints, and to distance constraints.
Each component consists of: a matrix with columns that are the bounds, the realized level, the nearest bound if the constraint is not broken, and the distance to the nearest bound if the constraint is broken. Exactly one of the latter two columns is non-missing for each bound. Numbers that are negative mean that the lower bound is the reference, positive numbers mean the upper bound is involved.

### Details

If there are no bounds given explicitly or by default for the linear constraints, then infinite bounds are created for all of the constraints and `exclude.inf` is forced to be `FALSE`.

This function produces the `con.realized` component of the output of `trade.optimizer` – this component is part of the output of the `summary` for such objects.

### Revision

This help was last revised 2010 April 28.

### See Also

`build.constraints`, `summary.portfolBurSt`, `trade.optimizer`.

### Examples

    my.sc <- matrix(c("energy", "telecom", "energy", "Germany", "France",
            "France"), nrow=3, ncol=2, dimnames=list(c("Asset 1", "Asset 2",
            "Asset 3"), c("Sector", "Country")))
    my.constr <- build.constraints(my.sc)
    my.constr$bounds[,1] <- c(-.05, -.10, 0, .05)
    my.constr$bounds[,2] <- c(.15, .15, .20, .55)

    op <- trade.optimizer(prices, varian,
            lin.constraints=my.constr$lin.constraints,
            lin.bounds=my.constr$bounds, gross.value=1e6,
            net.value=c(-1e5, 6e5))

    constraints.realized(op, my.constr$lin.constraints,
            bounds=my.constr$bounds)

    op2 <- trade.optimizer(prices, varian, gross.value=1e6,
            net.value=c(-1e5, 6e5))

    # view values for unconstrained portfolio
    constraints.realized(op2, my.constr$lin.constraints)

[Package PortfolioProbe version 1.03 Index]