Python Forum
Time Series Production Process Problem
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Time Series Production Process Problem
#2
Yes, this is a time series problem with multiple variables. Specifically, it is a multivariate time series problem since you have multiple time series (one for each drink type) and multiple variables affecting the production process (equipment availability, batch ID, etc.).

To predict demand, you can use various time series forecasting techniques such as ARIMA, SARIMA, or Prophet. You would need historical data of demand for each drink type to train the model and then use it to predict demand for future months.

To decide what drink type to produce next based on equipment availability and predicted demand, you can use optimization algorithms such as linear programming or integer programming. The objective function would be to maximize profit or minimize cost, and the constraints would include the availability of equipment, production time, and demand.

There are several examples of similar problems online, such as demand forecasting for manufacturing companies or inventory optimization in supply chain management. You can also refer to textbooks on time series analysis or operations research for more guidance.


Here is a high-level algorithm to decide what drink type to produce next given available equipment and predicted demand:

Obtain the predicted demand for each drink type for the next month or year.
Calculate the production capacity for each equipment by taking into account the duration of each stage and the size of the equipment.
Calculate the total production capacity for each drink type by multiplying the predicted demand by the production duration for each stage.
Create a decision matrix with the rows representing drink types and the columns representing equipment availability.
For each row, calculate the total production capacity by adding up the production capacities of each equipment that can be used for that drink type.
Choose the drink type with the highest total production capacity.
If there are multiple drink types with the same highest production capacity, choose the one with the highest profit margin or lowest production cost.
Produce the chosen drink type using the available equipment and update the inventory accordingly.
This algorithm can be further optimized by considering factors such as equipment maintenance, equipment preference, and production scheduling. Additionally, the algorithm can be modified to incorporate real-time data on demand and equipment availability, allowing for more dynamic decision-making.


Here is a sample Python code that implements the algorithm to decide what drink type to produce next given available equipment and predicted demand:

import pandas as pd
import numpy as np

# Define equipment capacity
equipment_capacity = {
    'Equip1': 5000,
    'Equip2': 900,
    'Equip3': 700,
    'Equip4': 900,
    'Equip5': 800,
    'Equip6': 600,
    'Equip7': 900,
    'Equip8': 700,
    'Equip9': 700,
    'Equip10': 800
}

# Define drink types and their production duration (in days)
drink_types = ['A', 'B', 'C']
production_duration = {
    'A': {'S1': 2, 'S2': 28, 'S3': 14, 'S4': 4},
    'B': {'S1': 2, 'S2': 28, 'S3': 14, 'S4': 4},
    'C': {'S1': 2, 'S2': 28, 'S3': 14, 'S4': 4}
}

# Define predicted demand for the next month or year
predicted_demand = {
    'A': 1000,
    'B': 2000,
    'C': 3000
}

# Define profit margin for each drink type
profit_margin = {
    'A': 0.3,
    'B': 0.2,
    'C': 0.1
}

# Define the inventory for each drink type
inventory = {
    'A': 500,
    'B': 1000,
    'C': 1500
}

# Calculate the total production capacity for each drink type and equipment
total_capacity = pd.DataFrame(index=drink_types, columns=list(equipment_capacity.keys()))

for drink_type in drink_types:
    for equip, capacity in equipment_capacity.items():
        if equip == 'Equip1':
            total_capacity.loc[drink_type, equip] = capacity / production_duration[drink_type]['S1']
        else:
            total_capacity.loc[drink_type, equip] = capacity / (production_duration[drink_type]['S2'] + production_duration[drink_type]['S3'] + production_duration[drink_type]['S4'])

total_capacity = total_capacity.astype(float)

# Calculate the total production capacity for each drink type
total_production_capacity = pd.DataFrame(index=drink_types, columns=['Total Capacity'])

for drink_type in drink_types:
    total_production_capacity.loc[drink_type, 'Total Capacity'] = np.sum(total_capacity.loc[drink_type, :] * list(equipment_capacity.values()))

total_production_capacity = total_production_capacity.astype(float)

# Create decision matrix
decision_matrix = pd.DataFrame(index=drink_types, columns=list(equipment_capacity.keys()))

for drink_type in drink_types:
    for equip in equipment_capacity.keys():
        if equip == 'Equip1':
            decision_matrix.loc[drink_type, equip] = min(predicted_demand[drink_type], total_capacity.loc[drink_type, equip])
        else:
            decision_matrix.loc[drink_type, equip] = min(predicted_demand[drink_type], total_capacity.loc[drink_type, equip]) * (production_duration[drink_type]['S2'] + production_duration[drink_type]['S3'] + production_duration[drink_type]['S4'])

decision_matrix = decision_matrix.astype(float)

# Choose the drink type with the highest production capacity
chosen_drink_type = total_production_capacity.idxmax()[0]

# If there are multiple drink types with the same highest production capacity, choose the one with the highest profit margin
Here is a sample Python code that implements a function to predict demand for a given drink type in a month or year in the future, based on historical sales data:

import pandas as pd
from datetime import datetime

def predict_demand(drink_type, future_date, sales_data):
"""
Predicts the demand for a given drink type in a month or year in the future, based on historical sales data.

Parameters:
drink_type (str): The drink type for which to predict demand.
future_date (str): A string representation of the future date in the format 'YYYY-MM' for a month or 'YYYY' for a year.
sales_data (pandas.DataFrame): A DataFrame containing historical sales data.

Returns:
demand (int): The predicted demand for the given drink type in the specified month or year.
"""

# Filter sales data for the given drink type
drink_type_sales = sales_data[sales_data['Drink Type'] == drink_type]

# Calculate monthly or yearly sales totals
if len(future_date) == 7: # Monthly data
drink_type_sales['Month'] = drink_type_sales['Date Ordered'].dt.to_period('M')
drink_type_sales = drink_type_sales.groupby('Month').agg({'Quantity Ordered': 'sum'}).reset_index()
drink_type_sales = drink_type_sales.set_index('Month')
drink_type_sales.index = drink_type_sales.index.strftime('%Y-%m')
elif len(future_date) == 4: # Yearly data
drink_type_sales['Year'] = drink_type_sales['Date Ordered'].dt.to_period('Y')
drink_type_sales = drink_type_sales.groupby('Year').agg({'Quantity Ordered': 'sum'}).reset_index()
drink_type_sales = drink_type_sales.set_index('Year')
drink_type_sales.index = drink_type_sales.index.strftime('%Y')

# Interpolate missing values in the time series
drink_type_sales = drink_type_sales.interpolate(method='linear')

# Predict the demand for the future month or year
demand = int(drink_type_sales.loc[future_date]['Quantity Ordered'])

return demand


This function takes the drink type for which to predict demand, a string representation of the future date in the format 'YYYY-MM' for a month or 'YYYY' for a year, and a DataFrame containing historical sales data as inputs. The function filters the sales data for the given drink type, calculates monthly or yearly sales totals interpolates missing values in the time series and predicts the demand for the future month or year using linear interpolation. The function returns the predicted demand as an integer value.


Hope this will help!!!
Gribouillis write Feb-28-2023, 12:29 PM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Reply


Messages In This Thread
Time Series Production Process Problem - by Mzarour - Dec-06-2019, 06:44 PM
RE: Time Series Production Process Problem - by get2sid - Feb-28-2023, 12:25 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Help: Conversion of Electricity Data into Time Series Data SmallGuy 3 1,243 Oct-04-2023, 03:31 PM
Last Post: deanhystad
  Help to Plot timeline for intreruption of one line production danut_horincas 2 2,549 Feb-28-2023, 11:48 AM
Last Post: get2sid
  reduce time series based on sum condition amdi40 0 1,113 Apr-06-2022, 09:09 AM
Last Post: amdi40
  How to accumulate volume of time series amdi40 3 2,328 Feb-15-2022, 02:23 PM
Last Post: amdi40
  Recommendations for ML libraries for time-series forecast AndreasPython 0 1,898 Jan-06-2021, 01:03 PM
Last Post: AndreasPython
  Time Series forecating with multiple independent variables Krychol88 1 1,881 Oct-23-2020, 08:11 AM
Last Post: DPaul
  how to handling time series data file with Python? aupres 4 3,024 Aug-10-2020, 12:40 PM
Last Post: MattKahn13
  Changing Time Series from Start to End of Month illmattic 0 1,889 Jul-16-2020, 10:49 AM
Last Post: illmattic
  HELP- DATA FRAME INTO TIME SERIES- BASIC bntayfur 0 1,772 Jul-11-2020, 09:04 PM
Last Post: bntayfur
  Differencing Time series and Inverse after Training donnertrud 0 4,123 May-27-2020, 06:11 AM
Last Post: donnertrud

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020