ls.solve: Solves a LocalSolver problem on data passed.

Description Usage Arguments Details Value Examples

View source: R/00_api.R

Description

Prepares input and data for LocalSolver, runs the application and parses its output to get resulting values.

Usage

1
ls.solve(lsp, data)

Arguments

lsp

problem instance created with ls.problem.

data

named list of data items. Each element of the list should be indexed with the parameter name and should be a number, vector, matrix or array (of dimension 2 or 3) of numbers. The class of the numbers should be either integer (they will be then handled as integer by the LocalSolver) or numeric (LocalSolver will then treat them as elements of class double).

Details

Result of this function is named list of output expressions added to the problem (for description of R data structures form see add.output.expr). Parameters set with set.params are passed to LocalSolver by means of generation(or modification) of LocalSolver param function (see LocalSolver LSP language reference manual http://www.localsolver.com/lspreferencemanual.html for more details).

Make sure you pass integers in data if you want them to be ints in LocalSolver. Otherwise they will be considered doubles.

Errors occurred in model LSP code (passed while creating problem with ls.problem) are handled: They cause error containing original error message and error occurrence context to make it easier to detect potential errors in model LSP code. All other LocalSolver errors (e.g. in output expressions) and interaction errors (between localsolver package and LocalSolver process) are passed to caller without processing.

Value

named list of all output expression values on best solution found.

Examples

1
2
3
4
5
6
model.text.lsp <- lsp.model.example('extdata/knapsack.txt')
lsp <- ls.problem(model.text.lsp)
lsp <- set.params(lsp, lsTimeLimit=60)
lsp <- add.output.expr(lsp, "x", 4)
data <- list(nbItems=4L, itemWeights=c(1L,2L,3L,4L), itemValues=c(5,6,7,8), knapsackBound=40L)
result <- ls.solve(lsp, data)

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