Added expression will be printed out by the LocalSolver and
add.output.expr(lsp, expr.text.lsp, dimensions = 1)
problem instance created with
text of expression in LSP language (an objective function, constraint or decision variable name).
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
dimensions passed as dim(see
All output expression values are exposed as
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.
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))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.