Added expression will be printed out by the LocalSolver and
added to ls.solve
result.
1  add.output.expr(lsp, expr.text.lsp, dimensions = 1)

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

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.
Updated ls.problem
instance.
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))

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.
Please suggest features or report bugs with the GitHub issue tracker.
All documentation is copyright its authors; we didn't write any of that.