In-depth analysis of the 2023 Higher Education Society Cup Mathematical Modeling National Competition (Question C)

Question restated:


In fresh food supermarkets, the shelf life of general vegetable products is relatively short, and the quality deteriorates with the increase of sales time. If most varieties are not sold on the same day, they cannot be resold the next day. Therefore, supermarkets usually restock every day based on the historical sales and demand of each product. Since there are many varieties of vegetables sold in supermarkets with different origins, and the purchase and transaction time of vegetables is usually between 3:00 and 4:00 in the morning, merchants must do this without knowing exactly the specific items and purchase prices. Make replenishment decisions for each vegetable category on the day. The pricing of vegetables generally adopts the "cost-plus pricing" method. Supermarkets usually offer discounts for products that have been damaged during transportation and have deteriorated in quality. Reliable market demand analysis is particularly important for replenishment decisions and pricing decisions. From the demand side, there is often a certain correlation between the sales volume of vegetable commodities and time; from the supply side, the supply variety of vegetables is relatively abundant from April to October, and the restrictions on the sales space of supermarkets make reasonable sales Combination becomes extremely important.
 

Question 1


There may be certain correlations between different categories or single products of vegetable commodities. Please analyze the distribution patterns and interrelationships of sales volume of various vegetable categories and single products.

1. Data preprocessing:

· First, filter out the data related to vegetable commodities from the detailed sales data provided in Appendix 2.

· Clean the data, including removing missing values ​​and outliers, to ensure data quality.

· Classify sales dates and sales quantities by vegetable category or single product.

2. Descriptive statistical analysis:

· Perform statistical analysis on the sales volume of each vegetable category and single product, and calculate statistics such as average, variance, and median.

· Draw histograms and boxplots of sales to understand the distribution of sales.

3. Correlation analysis:

· Use statistical tools (such as correlation coefficients) to analyze the sales volume correlation between different vegetable categories or single products.

· Draw a scatter plot to visualize the relationship between sales volumes.

· Data preparation: According to the goal of question 1, select the sales data of the vegetable category or single product that needs to be analyzed, and extract it.

· Calculate correlation: Use statistical methods (such as Pearson correlation coefficient, Spearman correlation coefficient) to calculate the sales volume correlation between different vegetable categories or single products.

·Visualization: Draw scatter plots or heat maps to visualize correlations so that you can more clearly observe the relationship between different categories or single products.

4. Time series analysis:

· For each vegetable category or single product, time series analysis can be performed on the changes in sales volume over time to identify sales trends and seasonality.

· Use time series models (such as ARIMA models) to predict future sales.

· Data preparation: Select the sales data of the vegetable category or single product that needs to be analyzed, and sort it by time.

· Time Series Decomposition: Break down time series data into trend, seasonality, and noise components to better understand sales trends.

· Model fitting: According to the nature of the time series, select an appropriate time series model, such as the ARIMA model. Fit the model and estimate parameters.

· Forecast future sales: Use the fitted model to predict future sales to understand possible sales trends.

5. Cluster analysis:

· Use cluster analysis methods (such as K-means clustering) to group vegetable categories or single products to find product groups with similar sales behavior.

· Further study of sales volume relationships within each group.

· Data preparation: Select the sales data of the vegetable category or single product to be clustered and make sure the data contains enough features.

· Feature selection: If there are multiple features (such as sales quantity, sales volume, gross profit margin, etc.), select the appropriate features for clustering.

· Standardization: Standardize features to ensure they are on the same scale.

· Clustering algorithm: Choose an appropriate clustering algorithm, such as K-means clustering. Determine the number of clusters to divide into.

· Visualization of clustering results: Draw a scatter plot of the clustering results or a visualization of the cluster center to observe the clustering of different vegetable categories or single products.

6. Visual analysis:

· Use data visualization tools to draw heat maps, correlation diagrams, time series diagrams, etc. to more clearly display sales distribution patterns and relationships.

7. Interpretation and application of results:

· The results obtained from the analysis can help supermarkets and supermarkets understand the sales volume trends, correlations and seasonality between different vegetable categories and individual products.

· This information can be used to develop replenishment strategies, such as alternative replenishment between vegetable categories with higher sales volume, to reduce inventory losses.

· It can also be used for pricing strategies, such as adjusting the pricing of different categories or single products based on sales volume relationships to increase sales revenue.

The complete version of the answer (below) has the complete code.

Question 2


During the calculation:

1. Data preparation:

· Use the data in Appendix 2 to extract the sales quantity, wholesale price and loss rate of each vegetable category.

· Clean and process data to ensure data accuracy and completeness.

2. Cost-plus pricing analysis:

· Calculate the cost of each vegetable category, which can include procurement costs, transportation costs and other related costs.

· Determine the selling price of each vegetable category based on the cost-plus pricing method. Typically, the selling price can be set as a markup percentage of the cost.

3. Establish an optimization model:

Objective function:

· Define an objective function to maximize the total revenue of the supermarket. Total revenue can be calculated as sales revenue minus total costs.

Decision variables:

· For each vegetable category:

· Pricing decision variable: selling price (Price)

· Replenishment decision variable: daily replenishment quantity (Replenishment)

Restrictions:

· Constraints include:

· Demand constraints: The daily sales quantity must not exceed the replenishment quantity to avoid inventory overstock or sell-out.

· Total replenishment quantity constraint: The total daily replenishment quantity cannot exceed a certain limit to avoid over-purchasing.

· Selling price range constraint: The selling price cannot be lower than the minimum price or higher than the maximum price.

· Loss constraints: Consider the loss rate of vegetables to avoid excessive losses.

4. Model solution:

· Use linear programming solvers (such as PuLP, Gurobi, CPLEX, etc.) to solve the established linear programming model. These solvers can help find optimal selling prices and replenishment decisions to maximize total revenue.

5. Model output and decision-making:

· The solver outputs the optimal selling price and replenishment decisions, and the corresponding total revenue.

· Based on the results of the model, formulate the total daily replenishment volume and pricing strategy for the next week (July 1-7, 2023) to maximize the profits of the supermarket.

6. Model evaluation and adjustment:

· Evaluate the output of the model to verify the feasibility and effectiveness of the model.

· If necessary, the parameters or constraints of the model can be adjusted according to the actual situation to optimize the decision-making strategy.

import pandas as pd
import pulp
 
# 读取销售数据
data = pd.read_csv('sales_data.csv')
 
# 假设您已经有了每个蔬菜品类的成本数据和损耗率数据
# 请确保数据的格式与您的实际数据一致
 
# 创建线性规划问题
model = pulp.LpProblem("Maximize_Revenue", pulp.LpMaximize)
 
# 创建决策变量:售价和补货数量
price = pulp.LpVariable.dicts("Price", data['Category'], lowBound=0, upBound=None, cat='Continuous')
replenishment = pulp.LpVariable.dicts("Replenishment", data['Category'], lowBound=0, upBound=None, cat='Continuous')
 
# 定义目标函数:最大化总收益
model += pulp.lpSum((price[category] * replenishment[category] * (1 - data['LossRate'][i]) - data['Cost'][i]) * data['Sales'][i] 
                    for i, category in enumerate(data['Category']))
 
# 添加约束条件:需求约束、补货总量约束、售价范围约束
for category, df_category in data.groupby('Category'):
    model += pulp.lpSum(replenishment[category]) >= pulp.lpSum(df_category['Sales']), f"Demand_Constraint_{category}"
    model += pulp.lpSum(replenishment[category]) <= 7 * pulp.lpSum(df_category['Sales']), f"Replenishment_Constraint_{category}"
    model += price[category] >= df_category['Cost'].min(), f"Min_Price_Constraint_{category}"
    model += price[category] <= df_category['Cost'].max(), f"Max_Price_Constraint_{category}"
 
# 求解线性规划问题
model.solve()
 
# 打印结果
print(f"Status: {pulp.LpStatus[model.status]}")
 
for category in data['Category']:
    print(f"Category: {category}")
    print(f"Optimal Price: ${price[category].varValue:.2f}")
    print(f"Optimal Replenishment: {replenishment[category].varValue:.2f} units")
    print()
 
# 计算总收益
total_revenue = pulp.value(model.objective)
print(f"Total Revenue: ${total_revenue:.2f}")

Question 3


Question 3 requires formulating a single product replenishment plan to control the total number of sellable single products between 27 and 33, while meeting the minimum display quantity requirements and maximizing the supermarket's profits. In order to solve this problem, Mixed Integer Linear Programming (MILP) can be used to build an optimization model.

1. Data preparation:

· Use the data in Attachment 3 to extract information on sellable single products, including sales data, cost, loss rate, etc. of the single product.

· Clean and process data to ensure data accuracy and completeness.

2. Establish an optimization model:

Objective function:

· Define an objective function to maximize the total revenue of the supermarket. Total revenue can be calculated as sales revenue minus total costs.

Decision variables:

· For each sellable item:

· Order quantity decision variable: Order Quantity is an integer variable that represents the quantity of a single product to be ordered.

· Pricing decision variable: Selling price (Price) is a continuous variable that represents the selling price of a single product.

Restrictions:

· Constraints include:

· Single product quantity constraint: The total number of single products ordered must be between 27-33.

· Minimum display quantity constraint: The order quantity of each item must meet the minimum display quantity (2.5 kg) requirement.

· Selling price range constraint: The selling price cannot be lower than the minimum price or higher than the maximum price.

· Loss constraints: Consider the loss rate of single products to avoid excessive losses.

3. Solve the optimization model:

· Use mixed integer linear programming solvers (such as PuLP, Gurobi, CPLEX, etc.) to solve the established MILP model.

· Find the optimal order quantity and pricing strategy for a given sellable unit to maximize total revenue.

4. Model output and decision-making:

· The solver outputs the optimal order quantity and pricing strategy, and the corresponding total revenue.

· Based on the results of the model, formulate the single product replenishment volume and pricing strategy for July 1.

5. Model evaluation and adjustment:

· Evaluate the output of the model to verify the feasibility and effectiveness of the model.

· If necessary, the parameters or constraints of the model can be adjusted according to the actual situation to optimize the decision-making strategy.

Objective function: Maximize the total revenue of the supermarket. Total revenue can be calculated as sales revenue minus total costs.

Loss rate cost Maximize ∑i(Pi⋅Qi⋅(1−loss rate i)−cost i⋅Qi)\text{Maximize } \sum_{i} (P_i \cdot Q_i \cdot (1 - \text{Loss rate} _i) - \text{cost}_i \cdot Q_i)

Decision variables: For each sellable item, we have two decision variables:

· Order quantity decision variable (integer): QiQ_i, indicating the quantity of a single product to be ordered.

· Pricing decision variable (continuous): PiP_i, indicating the selling price of a single product.

Restrictions:

1. Single product quantity constraint: The total number of single products ordered must be between 27-33. 27≤∑i​Qi​≤3327≤∑i​Qi​≤33

27≤∑iQi≤3327 \leq \sum_{i} Q_i \leq 33

2. Minimum display quantity constraint: The order quantity of each item must meet the minimum display quantity (2.5 kg) requirement. Qi​≥2.5Qi​≥2.5 , for all i

Qi≥2.5, for all iQ_i \geq 2.5, \text{ for all } i

3. Selling price range constraints: the selling price cannot be lower than the minimum price, nor higher than the maximum price. Pi​≥minimum price, for all i

Minimum price Pi≥minimum price, for all iP_i \geq \text{Minimum price}, \text{ for all } i

Pi​≤maximum price, for all i

Maximum price Pi ≤ maximum price, for all iP_i \leq \text{Maximum price}, \text{ for all } i

1. Loss constraints: Consider the loss rate of a single product to avoid excessive losses.

Loss rate available inventory Qi​≤(1−loss rate i​)×available inventory i​,foralli

Qi​≤(1−loss rate i​)×available inventory i​, for all i

Loss rate available inventory Qi ≤ (1 − loss rate i) ⋅ available inventory i, for all i

Q_i \leq (1 - \text{loss rate}_i) \cdot \text{available inventory}_i, \text{ for all } i

Definition of objective function: Maximize total revenue, where total revenue consists of sales revenue minus costs for each unit. Maximize ∑i​(Pi​⋅Qi​⋅(1−loss rate i​)−cost i​⋅Qi​)

Question 4


1. Real-time sales data:

· Data type: Daily sales quantity, sales volume, sales channel and other data of different vegetable categories and single products.

· Help: Real-time sales data can provide information about current demand, helping supermarkets and supermarkets make more accurate replenishment decisions and pricing strategies. It can also help supermarkets track sales trends and seasonal changes.

2. Supply chain data:

· Data type: Supply chain information of different vegetable categories and single products, including suppliers, supply time, purchase price, etc.

· Help: Supply chain data can help merchants and supermarkets understand the performance, stability and on-time delivery of suppliers, and help make better supplier selection and purchasing decisions.

3. Cost data:

· Data type: procurement costs, transportation costs, warehousing costs, etc. of different vegetable categories and single products.

· Help: Cost data is important in developing a cost-plus pricing strategy. They can help supermarkets ensure that the selling price is high enough to cover all costs and make a reasonable profit.

4. Loss rate data:

· Data type: loss rate data of different vegetable categories and single products.

· Help: Loss rate data can help supermarkets optimize inventory management and replenishment decisions. They also help reduce losses and improve profit margins.

5. Market trend data:

· Data types: market trends, competitor prices, consumer preferences and other data.

· Help: Market trend data can help supermarkets adjust pricing strategies to stay competitive. Understanding your competitors' prices and consumer preferences can help you develop a more attractive pricing strategy.

6. Seasonal data:

· Data type: vegetable sales data in different seasons, seasonal price change data, etc.

· Help: Seasonal data helps supermarkets develop different replenishment and pricing strategies in different seasons to meet seasonal demand and price fluctuations.

7. Inventory data:

· Data type: Inventory volume, inventory turnover rate and other data.

· Help: Inventory data can help supermarkets optimize inventory management, reduce inventory overstock or sell-out situations, and improve capital utilization.

8. Customer feedback data:

· Data type: data such as customer feedback, complaints and suggestions.

import requests
· import pandas as pd
· 
· # 从API获取数据的示例
· url = 'https://api.example.com/data'
· response = requests.get(url)
· data = response.json()  # 将响应数据解析为JSON格式
· 
· # 将数据存储为DataFrame
· 
· df = pd.DataFrame(data)
· 
· #2. 数据清洗和预处理:
· 
· #对数据进行清洗和预处理,包括处理缺失值、重复值、异常值等。
· # 处理缺失值
· df.dropna(inplace=True)
· 
· # 处理重复值
· df.drop_duplicates(inplace=True)
· 
· # 处理异常值
· # 例如,移除销售数量小于0的记录
· df = df[df['Sales'] >= 0]
· 
 
· #3. 数据分析:
· 
· #使用pandas和其他数据分析库来执行数据分析任务,如统计、聚合、计算指标等。
· # 统计数据摘要
· summary_stats = df.describe()
· 
· # 计算总销售额
· total_sales = df['Sales'].sum()
· 
· # 分组聚合操作
· category_sales = df.groupby('Category')['Sales'].sum()
· 
· # 数据可视化
· import matplotlib.pyplot as plt
· 
· # 绘制销售量的直方图
· plt.hist(df['Sales'], bins=20, color='blue', edgecolor='black')
· plt.xlabel('Sales')
· plt.ylabel('Frequency')
· plt.title('Sales Distribution')
· plt.show()
· #4. 数据可视化:
· 
· #使用数据可视化库(如matplotlib、seaborn)来创建图表和可视化工具,以更好地理解数据。
· # 绘制销售量的折线图
· plt.plot(df['Date'], df['Sales'], marker='o', linestyle='-', color='green')
· plt.xlabel('Date')
· plt.ylabel('Sales')
· plt.title('Sales Over Time')
· plt.xticks(rotation=45)
· plt.show()

Complete code + ideas:In-depth analysis of the 2023 Higher Education Society Cup Mathematical Modeling National Competition (Question C)

Guess you like

Origin blog.csdn.net/qq_25834913/article/details/132737255