latteMin: Solve a Linear Program (Minimization)

Description Usage Arguments Value Examples

View source: R/latteMin.r

Description

latteMin uses LattE's minimize function to find the minimum 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
latteMin(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
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
## Not run: 

latteMin("-2 x + 3 y", c("x + y <= 10", "x >= 0", "y >= 0"))
latteMin("-2 x + 3 y", c("x + y <= 10", "x >= 0", "y >= 0"),
  method = "cones") # ??


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.min(df$val),]

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









latteMin("-2 x - 3 y - 4 z", c(
  "3 x + 2 y + z <= 10",
  "2 x + 5 y + 3 z <= 15",
  "x >= 0", "y >= 0", "z >= 0"
), "cones",quiet = FALSE)

df <- expand.grid(x = 0:10, y = 0:10, z = 0:10)
df <- subset(df,
  (3*x + 2*y + 1*z <= 10) &
  (2*x + 5*y + 3*z <= 15)
)

df$val <- apply(df, 1, function(v) -2*v[1] + -3*v[2] + -4*v[3])
df[which.min(df$val),]





## End(Not run)

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

Related to latteMin in algstat...