I'd like to start using {lpsolve} in R to solve some manufacturing- optimization problems.
I've set up a few examples but haven't been able to get them to work.
Here is an example I set up and the code I've been messing with: Any help or direction would be greatly appreciated. I'm generally confused when it comes to the constraint matrix.
Problem description: I'm trying to distribute the three different products across the three tools in order to minimize production time across all three.
library("lpSolve")
# Define problem data
products <- c("q1", "q2", "q3")
volumes <- c(20, 40, 1000)
tools <- c("A", "B", "C")
build_time <- c(15,20,25)
# Define objective function coefficients
obj_func <- c(build_time)
# matrix
const.mat <- rbind(
c(20, 40, 1000)
)
dir <- c(">=", ">=", ">=")
rhs <- c(sum(volumes))
result <- lp("min", obj_func, const.mat, dir, rhs, all.bin = TRUE)
# Print solution
print(result$solution)
# Calculate time required for each tool
time_required <- build_time * result$solution * volumes
names(time_required) <- tools
print(time_required)