add.output.expr {localsolver} | R Documentation |
Add expression to output of ls.problem.
Description
Added expression will be printed out by the LocalSolver and
added to ls.solve
result.
Usage
add.output.expr(lsp, expr.text.lsp, dimensions = 1)
Arguments
lsp |
problem instance created with
|
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
|
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
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))