CS考试辅导 title: “Production Planning LP”

title: “Production Planning LP”
output: html_document

“`{r setup, include=FALSE}

Copyright By PowCoder代写 加微信 powcoder

knitr::opts_chunk$set(echo = TRUE)

PMG Corp is one of the leading industrial stampers in the city in which you operate a consulting firm for sales and operation planning optimization. PMG has contracted with you for assistance in planning their production schedule for the upcoming Quarter 1 (13 weeks). The company has orders for 15 different parts that can be both be produced on one of two production lines: line A or line B. Table 1 summarizes the orders for each part number that must be produced in the coming quarter along with their production rates and costs on each line, and the cost of subcontracting each order. Note that the first 4 orders can only be produced on line A. Assume that any portion of an order can be subcontracted.

PMG currently has 15 Line A machines and 80 Line B machines. Each machine operates 24 hours a day, 7 days a week, except for a scheduled downtime of 2 hours per week for maintenance.

**Table 1**

|Part Number|Q1 Sales Demand (parts) |Line A Parts/Hr|Line A Cost/Part|Line B Parts/Hr|Line B Cost/Part|Subcontract Cost/Part|
|:———:|:———————-:|:————-:|:————–:|:————-:|:————–:|:——————-:|
|1 |72,190 |4.510 |\\$2.66 |na |na |\\$2.77 |
|2 |235,765 |4.796 |\\$2.55 |na |na |\\$2.73 |
|3 |245,125 |4.629 |\\$2.64 |na |na |\\$2.85 |
|4 |242,565 |4.256 |\\$2.56 |na |na |\\$2.73 |
|5 |93,252 |5.145 |\\$1.61 |5.426 |\\$1.60 |\\$1.76 |
|6 |57,996 |3.806 |\\$1.62 |3.935 |\\$1.61 |\\$1.76 |
|7 |190,128 |4.168 |\\$1.64 |4.316 |\\$1.61 |\\$1.76 |
|8 |167,670 |5.251 |\\$1.48 |5.356 |\\$1.47 |\\$1.59 |
|9 |294,790 |5.223 |\\$1.50 |5.277 |\\$1.50 |\\$1.71 |
|10 |96,355 |5.216 |\\$1.44 |5.419 |\\$1.42 |\\$1.63 |
|11 |249,448 |3.744 |\\$1.64 |3.835 |\\$1.64 |\\$1.80 |
|12 |100,354 |4.157 |\\$1.57 |4.291 |\\$1.56 |\\$1.78 |
|13 |263,163 |4.422 |\\$1.49 |4.558 |\\$1.48 |\\$1.63 |
|14 |245,189 |5.281 |\\$1.31 |5.353 |\\$1.30 |\\$1.44 |
|15 |89,239 |4.222 |\\$1.51 |4.288 |\\$1.50 |\\$1.69 |

Create a linear optimization model to meet sales demand at the lowest possible cost and find the optimal production plan and associated cost.

How would the total cost be impacted if one of the Line A machines broke and could not be used for the entire quarter?

If all Part Numbers 5 – 15 all sell for the same amount, which part number should the salesforce of PMG try to sell more of? Why?

library(lpSolveAPI)

Prod <- read.csv(file.choose()) head(Prod) ## Add Hours/Part column Prod[, c('Parts_Per_Hour', 'Cost_Per_Part')] <- lapply(Prod[, c('Parts_Per_Hour', 'Cost_Per_Part')], as.numeric) Prod$Hours_Per_Part <- (as.numeric(Prod$Parts_Per_Hour))^-1 Prod <- replace(Prod,is.na(Prod),0) Demand <- read.csv(file.choose()) head(Demand) ## calculate hours available for each source Lines <- c(15, 80, 0) Prod_Hours_Day <- 24 Prod_Days_Week <- 7 Prod_Maint_Hours_Week <- 2 Prod_Weeks_Qtr <- 13 Hours_Qtr <- Prod_Weeks_Qtr*(Prod_Hours_Day * Prod_Days_Week - Prod_Maint_Hours_Week) Hours_Available <- Lines * Hours_Qtr Hours_Available sources <- unique(Prod$Source) parts <- unique(Prod$Part_Number) decision_variables <- data.frame(qty = apply(expand.grid(sources, parts), 1, paste, collapse="_"), source = rep(sources, length(parts)), part = rep(parts, each = length(sources))) decision_variables model <- make.lp(length(sources) + length(parts), length(sources) * length(parts)) column <- 0 for (part in 1:length(parts)){ for (source in 1:length(sources)){ column <- column + 1 set.column(model,column, c(Prod[Prod$Part_Number == parts[part] & Prod$Source == sources[source], "Hours_Per_Part"], 1), indices=c(source, length(sources) + part)) set.constr.type(model, c(rep("<=",length(sources)), rep("=", length(parts)))) set.constr.value(model, rhs = c(Hours_Available, Demand$Q1_Demand)) for (part in c('1', '2', '3', '4')){ add.constraint(model, 1, type = '=', rhs = 0, indices = which(decision_variables$part == part & decision_variables$source == 'LineB')) costs <- NULL for (part in parts){ for (source in sources){ costs <- c(costs, Prod[Prod$Part_Number == part & Prod$Source == source, 'Cost_Per_Part']) set.objfn(model,costs) dimnames(model)[[2]] <- decision_variables$qty write.lp(model, "model.lp", "lp") solve(model) total_cost <- get.objective(model) total_cost qty <- get.variables(model) names(qty) <- decision_variables$qty ## retrieve sensitivity values get.sensitivity.rhs(model) get.sensitivity.obj(model) constraints <- c(paste0('capacity_',sources), paste0('demand_', parts), c('LineB_1', 'LineB_2', 'LineB_3', 'LineB_4'), paste0('lower_',decision_variables$qty)) shadow_prices = data.frame(variable = constraints, shadow_price = get.sensitivity.rhs(model)$duals) shadow_prices How would the total cost be impacted if one of the Line A machines broke and could not be used for the entire quarter? Shadow price of Line A Capacity constraint = -.97209 If 2158 hours are lost on Line A, cost will increase by -1 * 2158 * -.97209 = $2,098. If all Part Numbers 5 - 15 all sell for the same amount, which part number should the salesforce of PMG try to sell more of? Why? Minimum shadow price for all parts = $1.44 for Part# 14. Relaxing the order constraint (i.e., taking more orders) for Part 14 will increase costs the least. 程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com