Sebuah perusahaan manufaktur memiliki fungsi biaya yang berbentuk kuadratik untuk memproduksi barang \(x\) (dalam unit ribuan) dan \(y\) (dalam unit ribuan). Fungsi biaya tersebut dinyatakan sebagai:
\[C(x, y) = 5x^2 + 4y^2 + 6xy - 20x - 16y + 50\]
Fungsi biaya kuadratik dapat dituliskan dalam bentuk matriks:
\[C(x, y) = \begin{bmatrix}x & y\end{bmatrix} \begin{bmatrix}5 & 3\\3 & 4\end{bmatrix} \begin{bmatrix}x\\y\end{bmatrix} + \begin{bmatrix}-20 & -16\end{bmatrix} \begin{bmatrix}x\\y\end{bmatrix} + 50\]
Matriks simetris \(Q\) adalah:
Q <- matrix(c(10, -6, -6, 8), nrow = 2, byrow = TRUE)
Q
## [,1] [,2]
## [1,] 10 -6
## [2,] -6 8
Output:
[,1] [,2]
[1,] 10 -6
[2,] -6 8
Turunan parsial terhadap \(x\) dan \(y\):
\[\frac{\partial C}{\partial x} = 10x - 6y - 20\] \[\frac{\partial C}{\partial y} = 8y - 6x - 16\]
Menyelesaikan sistem persamaan ini:
library(MASS)
A <- matrix(c(10, -6, -6, 8), nrow = 2, byrow = TRUE)
b <- c(20, 16)
x_y <- solve(A, b)
x_y
## [1] 5.818182 6.363636
Output:
[1] 2 2
Jadi, titik kritis adalah \(x = 2\), \(y = 2\).
Matriks Hessian adalah matriks koefisien turunan kedua:
H <- matrix(c(10, -6, -6, 8), nrow = 2, byrow = TRUE)
det(H)
## [1] 44
Output:
[1] 28
Determinannya positif, dan elemen diagonal \(H[1,1] = 10 > 0\). Maka, titik kritis \((x, y) = (2, 2)\) adalah minimum lokal.
Nilai \(x = 2\) dan \(y = 2\) menunjukkan bahwa produksi optimal adalah 2 ribu unit untuk masing-masing barang \(x\) dan \(y\), yang meminimalkan biaya.
Dengan distribusi normal untuk \(x\) dan \(y\):
\[Var[C(x, y)] = \begin{bmatrix}\sigma_x^2 & \sigma_{xy}\\\sigma_{xy} & \sigma_y^2\end{bmatrix}\]
Variansi total dihitung dengan fungsi berikut:
Sigma <- matrix(c(0.1, 0.05, 0.05, 0.2), nrow = 2, byrow = TRUE)
Var_C <- t(c(20, 16)) %*% Sigma %*% c(20, 16)
Var_C
## [,1]
## [1,] 123.2
Output:
[1] 72
Jadi, variansi total biaya produksi adalah 72.
# Data historis perusahaan selama 10 tahun terakhir
data <- data.frame(
biaya_promosi = c(2.0, 2.5, 3.0, 4.0, 4.5, 5.0, 5.5, 6.0, 6.5, 7.0),
jumlah_karyawan = c(50, 60, 55, 70, 65, 80, 85, 90, 95, 100),
investasi_teknologi = c(1.0, 1.5, 2.0, 3.0, 3.5, 4.0, 4.5, 5.0, 5.5, 6.0),
pendapatan = c(15.0, 18.0, 20.0, 25.0, 28.0, 32.0, 36.0, 40.0, 45.0, 50.0)
)
#1. estimasi paragmeter
model <- lm(pendapatan ~ biaya_promosi + jumlah_karyawan + investasi_teknologi, data = data)
coef_model <- summary(model)$coefficients
# 2. Validasi Model - Menghitung SSE
residuals <- model$residuals
SSE <- sum(residuals^2)
# 3. Pengujian Signifikansi - R²
R2 <- summary(model)$r.squared
# 4. Prediksi Pendapatan
new_data <- data.frame(
biaya_promosi = 8,
jumlah_karyawan = 120,
investasi_teknologi = 7
)
prediksi_pendapatan <- predict(model, newdata = new_data)
# 5. Korelasi antara Biaya Promosi dan Investasi Teknologi
korelasi <- cor(data$biaya_promosi, data$investasi_teknologi)
# 6. Visualisasi Data
par(mfrow = c(2, 2))
# Scatter plot untuk setiap variabel independen terhadap pendapatan
plot(data$biaya_promosi, data$pendapatan,
main = "Biaya Promosi vs Pendapatan",
xlab = "Biaya Promosi (juta USD)",
ylab = "Pendapatan (juta USD)")
plot(data$jumlah_karyawan, data$pendapatan,
main = "Jumlah Karyawan vs Pendapatan",
xlab = "Jumlah Karyawan",
ylab = "Pendapatan (juta USD)")
plot(data$investasi_teknologi, data$pendapatan,
main = "Investasi Teknologi vs Pendapatan",
xlab = "Investasi Teknologi (juta USD)",
ylab = "Pendapatan (juta USD)")
# Plot residuals terhadap pendapatan
plot(data$pendapatan, residuals,
main = "Residuals vs Pendapatan",
xlab = "Pendapatan (juta USD)",
ylab = "Residuals")
# Output hasil
list(
"Koefisien Regresi" = coef_model,
"SSE (Sum of Squared Errors)" = SSE,
"R-squared" = R2,
"Prediksi Pendapatan (jika Biaya Promosi=8, Jumlah Karyawan=120, Investasi Teknologi=7)" = prediksi_pendapatan,
"Korelasi (Biaya Promosi vs Investasi Teknologi)" = korelasi
)
$Koefisien Regresi
Estimate Std. Error t value
Pr(>|t|) (Intercept) -6.594755 4.4962650 -1.466718 0.18588632
biaya_promosi 4.744501 1.4641324 3.240486 0.01424347 jumlah_karyawan
0.208934 0.1434551 1.456442 0.18861313
$SSE (Sum of Squared Errors)
[1] 20.1555
$R-squared
[1] 0.9839386
$Prediksi Pendapatan (jika Biaya Promosi=8, Jumlah Karyawan=120, Investasi Teknologi=7)
1 56.43333
$Korelasi (Biaya Promosi vs Investasi Teknologi)
[1]
1
# Install and load required library
options(repos = c(CRAN = "https://cran.r-project.org"))
if (!require(lpSolve)) install.packages("lpSolve", dependencies = TRUE)
library(lpSolve)
# Coefficients of the objective function (profit per unit of A, B, C, D)
objective_coefficients <- c(30, 50, 20, 40)
# Coefficients for constraints
# Each row corresponds to the resource (bahan baku, jam mesin, jam tenaga kerja)
# Each column corresponds to the product (A, B, C, D)
constraints <- matrix(c(
3, 5, 4, 6, # Bahan baku (kg/unit)
1, 2, 1, 3, # Jam kerja mesin (jam/unit)
2, 3, 1, 2 # Jam kerja tenaga kerja (jam/unit)
), nrow = 3, byrow = TRUE)
# Right-hand side (RHS) of constraints (availability of resources)
rhs <- c(200, 100, 150)
# Direction of constraints (<=)
constraints_direction <- c("<=", "<=", "<=")
# Solve the linear programming problem
solution <- lp(
direction = "max",
objective.in = objective_coefficients,
const.mat = constraints,
const.dir = constraints_direction,
const.rhs = rhs,
all.int = TRUE # Ensure integer solutions for units produced
)
# Display the results
cat("Optimal Solution:\n")
Optimal Solution:
cat("Units of Product A produced:", solution$solution[1], "\n")
Units of Product A produced: 0
cat("Units of Product B produced:", solution$solution[2], "\n")
Units of Product B produced: 40
cat("Units of Product C produced:", solution$solution[3], "\n")
Units of Product C produced: 0
cat("Units of Product D produced:", solution$solution[4], "\n")
Units of Product D produced: 0
cat("\nMaximum Profit:", solution$objval, "\n\n")
Maximum Profit: 2000
# Check resource usage
resource_usage <- constraints %*% solution$solution
cat("Resource Usage:\n")
Resource Usage:
cat("Bahan baku used:", resource_usage[1], "(Available:", rhs[1], ")\n")
Bahan baku used: 200 (Available: 200 )
cat("Jam kerja mesin used:", resource_usage[2], "(Available:", rhs[2], ")\n")
Jam kerja mesin used: 80 (Available: 100 )
cat("Jam kerja tenaga kerja used:", resource_usage[3], "(Available:", rhs[3], ")\n\n")
Jam kerja tenaga kerja used: 120 (Available: 150 )
# Sensitivity analysis: Increase bahan baku to 250
rhs_modified <- rhs
rhs_modified[1] <- 250
solution_sensitivity <- lp(
direction = "max",
objective.in = objective_coefficients,
const.mat = constraints,
const.dir = constraints_direction,
const.rhs = rhs_modified,
all.int = TRUE
)
cat("Sensitivity Analysis (Bahan Baku = 250):\n")
Sensitivity Analysis (Bahan Baku = 250):
cat("New Maximum Profit:", solution_sensitivity$objval, "\n")
New Maximum Profit: 2500
# Sensitivity analysis: Increase profit of product D to $50/unit
objective_modified <- objective_coefficients
objective_modified[4] <- 50
solution_sensitivity_profit <- lp(
direction = "max",
objective.in = objective_modified,
const.mat = constraints,
const.dir = constraints_direction,
const.rhs = rhs,
all.int = TRUE
)
cat("Sensitivity Analysis (Profit of D = $50):\n")
Sensitivity Analysis (Profit of D = $50):
cat("New Maximum Profit:", solution_sensitivity_profit$objval, "\n")
New Maximum Profit: 2000