add.output.expr: Add expression to output of ls.problem.

Description Usage Arguments Details Value Examples

View source: R/00_api.R

Description

Added expression will be printed out by the LocalSolver and added to ls.solve result.

Usage

1
add.output.expr(lsp, expr.text.lsp, dimensions = 1)

Arguments

lsp

problem instance created with ls.problem.

expr.text.lsp

text of expression in LSP language (an objective function, constraint or decision variable name).

dimensions

vector of variables expected dimensions. 1 for a number, length of a vector or dimensions of resulting matrix or array (see array dim parameter). The vector of the dimensions must be of length 1, 2 or 3, as the library does not maintain arrays of more than 3 dimensions.

Details

Each added expression is extracted out of LocalSolver output according to dimensions provided. Extracted values are converted into R data structures. If dimension is 1 the expression is considered to be a number. Otherwise the expression is converted to R array with dimensions passed as dim(see array).

All output expression values are exposed as numerics.

Currently errors in expression and inconsistency in dimensions passed are not detected properly. Handling such situations is planned to be implemented in next localsolver package version.

Value

Updated ls.problem instance.

Examples

1
2
3
4
5
6
model.text.lsp <- lsp.model.example('extdata/knapsack.txt')
lsp <- ls.problem(model.text.lsp)
lsp <- add.output.expr(lsp, "knapsackWeight")
# produces table x[i in 1..5][j in 1..10] in LocalSolver output
# and array with dims = c(5,10) under name x in output of ls.solve.
lsp <- add.output.expr(lsp, "x", c(5, 10))

localsolver documentation built on May 1, 2019, 8 p.m.