latteMax: Solve a Linear Program (Maximization)

Description Usage Arguments Value Examples

View source: R/latteMax.r

Description

latteMax uses LattE's maximize function to find the maximum of a linear objective function over the integers satisfying linearity constraints. This makes use of the digging algorithm; see the LattE manual at http://www.math.ucdavis.edu/~latte for details.

Usage

1
2
latteMax(objective, constraints, method = c("lp", "cones"), dir = tempdir(),
  opts = "", quiet = TRUE)

Arguments

objective

a linear polynomial to pass to mp, see examples

constraints

a collection of linear polynomial (in)equalities that define the feasibility region, the integers in the polytope

method

method LP or cones

dir

directory to place the files in, without an ending /

opts

options; see the LattE manual at http://www.math.ucdavis.edu/~latte

quiet

show latte output

Value

the count. if the count is a number has less than 10 digits, an integer is returned. if the number has 10 or more digits, an integer in a character string is returned. you may want to use the gmp package's as.bigz to parse it.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
## Not run: 

latteMax("-2 x + 3 y", c("x + y <= 10", "x >= 0", "y >= 0"))


df <- expand.grid(x = 0:10, y = 0:10)
df <- subset(df, x + y <= 10)
df$val <- apply(df, 1, function(v) -2*v[1] + 3*v[2])
df[which.max(df$val),]

library(ggplot2)
qplot(x, y, data = df, size = val)




## End(Not run)

algstat documentation built on May 29, 2017, 10:34 p.m.

Related to latteMax in algstat...