algstat (version 0.0.2)

latteMin: Solve a Linear Program (Minimization)

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

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

Run this code
## 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)

Run the code above in your browser using DataLab