SCA Practice Questions
SCA Practice Questions
SCA Practice Questions
Demand 1000
Holding cost 0
# Costs
cost_regular = 20 # Cost per unit for regular production
cost_overtime = 25 # Cost per unit for overtime production
cost_holding = 3 # Holding cost per unit per month
# Monthly demands
demands = [1000, 800, 1200, 900] # Demands for January, February, March, and April
b_eq = demands
total_cost, production_plan
Feb March April
800 1200 900
600 0 0
(82100.0,
array([800., 200., 0., 800., 200., 200., 800., 200., 0., 800.,
0.]))
To solve the Linear Programming (LP) problem using Excel Solver, follow these steps:
2. **Input Data**:
- Enter the production capacity limits (800 for regular, 200 for overtime) in the respective rows.
- Input the costs (Rs. 20 for regular, Rs. 25 for overtime) in the 'Cost per Unit' rows.
- Enter the monthly demands (1000, 800, 1200, 900) in the 'Monthly Demand' row.
3. **Set Up Variables**:
- In the 'Regular Production' and 'Overtime Production' rows, input the initial guesses for production quantities. These will be
5. **Enable Solver**:
- Go to 'File' > 'Options' > 'Add-ins'.
- In the 'Manage' box, select 'Excel Add-ins' and click 'Go'.
- Check the box next to 'Solver Add-in' and click 'OK' to enable it.
7. **Run Solver**:
- Click 'Solve'. Solver will find the optimal solution based on your constraints.
- If Solver finds a solution, it will ask if you want to keep the solver solution or restore original values. Choose to keep the sol
8. **Review Results**:
- The cells for 'Regular Production' and 'Overtime Production' will be updated with the quantities that minimize the total cos
- Check the 'Total Cost' to see the minimum cost calculated by Solver.
, 200., 200., 800., 200., 0., 800., 100.,
line 1
line 2
Python code
pip install pulp
# Constraints
# Minimum number of consultants required for each shift
prob += ft_8_12 + pt_8_12 >= 4
prob += ft_12_4 + pt_12_4 >= 8
prob += ft_4_8 + pt_4_8 >= 10
prob += ft_8_12am + pt_8_12am >= 6
FT_12_4 = 6.0
FT_4_8 = 7.0
FT_8_12 = 3.0
FT_8_12AM = 4.0
PT_12_4 = 2.0
PT_4_8 = 3.0
PT_8_12 = 1.0
PT_8_12AM = 2.0
Total Cost = $ 2624.0
: 0.03
import numpy as np
from scipy.optimize import linear_sum_assignment
def solve_tsp(distance_matrix):
# Apply the linear_sum_assignment to find the minimum cost in the assignment problem
row_ind, col_ind = linear_sum_assignment(distance_matrix)
# Add the cost of returning to the office from the last client
total_cost += distance_matrix[col_ind[-1], col_ind[0]]
optimal_route.append(optimal_route[0]) # Append the office at the end to return
print(f"The optimal route is: {optimal_route} with a total distance of: {total_cost}")
The optimal route is: [3, 4, 1, 2, 6, 5, 3] wi
nment problem
1, 2, 6, 5, 3] with a total distance of: 74.0
import networkx as nx
# Find the maximum flow from the source (node 1) to the sink (node 7)
flow_value, flow_dict = nx.maximum_flow(G, '1', '7')
node}: {value}")
The maximum flow from node 1 to node 7 is: 55
The flow through the network is as follows:
Flow from node 1 to node 2: 20
Flow from node 1 to node 3: 35
Flow from node 2 to node 4: 10
Flow from node 2 to node 5: 10
Flow from node 3 to node 4: 15
Flow from node 3 to node 6: 20
Flow from node 4 to node 5: 15
Flow from node 4 to node 6: 0
Flow from node 4 to node 7: 10
Flow from node 5 to node 7: 25
Flow from node 6 to node 7: 20
REGIONAL ANALYSIS
# Regional Analysis
plt.figure(figsize=(12, 6))
# Sales by Region
ax1 = plt.subplot(121)
sales_plot = sns.barplot(x='Region', y='Sales', data=data, estimator=sum, ax=ax1)
plt.title('Total Sales by Region')
# Profit by Region
ax2 = plt.subplot(122)
profit_plot = sns.barplot(x='Region', y='Profit', data=data, estimator=sum, ax=ax2)
plt.title('Total Profit by Region')
plt.tight_layout()
plt.show()
import pandas as pd
import matplotlib.pyplot as plt
from statsmodels.tsa.seasonal import seasonal_decompose
from statsmodels.graphics.tsaplots import plot_acf, plot_pacf
from statsmodels.tsa.arima.model import ARIMA
import warnings
# Load dataset
file_path = "/Users/kaustubhrath/Downloads/Supermart Grocery Sales - Retail Analytics Dataset (2).csv" # Replace with the a
data = pd.read_csv(file_path)
# Parsing the 'Order Date' in the format "day, date month year"
data['Order Date'] = pd.to_datetime(data['Order Date'], format='%A, %d %B %Y')
data.set_index('Order Date', inplace=True)
# Forecasting
forecast_periods = 12
forecast_result = arima_result.get_forecast(steps=forecast_periods)
forecast_mean = forecast_result.predicted_mean
forecast_conf_int = forecast_result.conf_int()
# Plotting Forecast
plt.figure(figsize=(12, 6))
plt.plot(monthly_sales, label='Historical Monthly Sales')
plt.plot(forecast_mean, label='Forecasted Sales', color='red')
plt.fill_between(forecast_conf_int.index,
forecast_conf_int.iloc[:, 0],
forecast_conf_int.iloc[:, 1],
color='pink', alpha=0.3)
plt.title('Monthly Sales Forecast')
plt.xlabel('Date')
plt.ylabel('Sales')
plt.legend()
plt.show()
th the actual path