National Competition Code 2023 Higher Education Society Cup National College Student Mathematical Modeling Part C Question Code

1. Competition questions


        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 varieties of vegetables are relatively abundant from April to October, and the restrictions on the sales space of supermarkets make reasonable sales Combination becomes extremely important.
        Attachment 1 gives the product information of six vegetable categories distributed by a certain supermarket; Attachments 2 and 3 respectively give the sales details and sales of each commodity in the supermarket from July 1, 2020 to June 30, 2023. Relevant data on wholesale prices;
Appendix 4 provides recent loss rate data for each commodity. Please establish a mathematical model based on the attachment and the actual situation to solve the following problems:
Question 1 There may be certain correlations between different categories or single products of vegetable commodities. Please analyze the distribution patterns and interrelationships of the sales volume of various vegetable categories and single products.
Question 2 Consider that supermarkets make replenishment plans on a category basis. Please analyze the relationship between the total sales volume of each vegetable category and cost-plus pricing, and give the forecast for each vegetable category in the next week (July 1-7, 2023). The total daily replenishment volume and pricing strategy maximize the profits of supermarkets.
Question 3: Due to the limited sales space of vegetable products, the supermarket hopes to further develop a replenishment plan for single products. It requires that the total number of single products available for sale be controlled to 27-33, and the order quantity of each single product meets the minimum display quantity requirement of 2.5 kg. . Based on the varieties available for sale from June 24 to 30, 2023, the single product replenishment volume and pricing strategy on July 1 are given, so as to maximize the profits of supermarkets while trying to meet the market demand for various types of vegetable commodities.
Question 4 In order to better make replenishment and pricing decisions for vegetable commodities, what other relevant data do supermarkets need to collect? How can these data help solve the above problems? Please give your opinions and reasons.

2. Part of the code

        In order to facilitate modeling, some common codes are provided for everyone to improve the efficiency of modeling papers.
1. There may be certain correlations between different categories or single products of vegetable commodities. Please analyze the distribution patterns of sales volume of various vegetable categories and single products. and mutual relationships.

import re
import os
from sqlalchemy import create_engine
import pandas as pd
import numpy as np
# import toad
import warnings
warnings.filterwarnings('ignore')
import sklearn
from sklearn.model_selection import train_test_split
from sklearn.metrics import roc_curve,roc_auc_score
import xgboost as xgboost
from xgboost.sklearn import XGBClassifier
# import lightgbm as lgb
import matplotlib.pyplot as plt
import gc
from sklearn.model_selection import cross_val_predict,cross_validate
# from bayes_opt import BayesianOptimization
import json
import seaborn as sns
import matplotlib.pyplot as plt


df1=pd.read_excel('附件1.xlsx')
df2=pd.read_excel('附件2.xlsx')
df3=pd.read_excel('附件3.xlsx')
df4=pd.read_excel('附件4.xlsx')



def get_df2_pre():
    df2_copy=df2.merge(df1,how='left',on=['单品编码'])
    df2_copy['month']=df2_copy['销售日期'].astype(str).str[:7]
    df2_copy['year']=df2_copy['销售日期'].astype(str).str[:4]
    
    return df2_copy

df2_copy=get_df2_pre()
df_month_sta=(
    df2_copy
    .groupby(['month','分类编码'])
    [['销量(千克)', '销售单价(元/千克)']]
    .sum()
    .reset_index()
    .rename(columns={'销售单价(元/千克)':'销售额(元)'})
    .pivot(index=['month'],columns=['分类编码'],values=['销量(千克)', '销售额(元)'])
)
df_month_sta


plt.subplots(figsize = (8,8))
sns.heatmap(df_month_sta['销量(千克)'].corr(),annot = True,vmax = 1,square = True,cmap = "Reds")
plt.show()

string = "9ae4ac08-b8b5-485f-b4b6-35d2e567486e"

       .......

3. Obtain the complete idea for free. Follow the Python risk control model and data analysis
        of the Weixin official account . Reply to the national competition question C code  to get the complete code for free (partly universal). The official account will continue to improve the idea and update the relevant code; it is not easy to write, so please pay attention to the hard work.

Guess you like

Origin blog.csdn.net/a7303349/article/details/132760715