Question D of the 2023 National College Student Mathematical Modeling Competition Detailed explanation of space utilization ideas for raising Hu sheep in captivity + Python source code (2)

Yesterday, I wrote out the detailed explanation and source code of the first and second questions of question E. If you want to start with question E, I recommend you to refer to my article. I personally think that question E is better than question D in terms of modeling. After all, there are I have data and a clear modeling idea. For question E, I directly provided the Python source code and you can run it directly:

2023 National College Student Mathematical Modeling Contest - Detailed explanation of question E + Python code source code analysis icon-default.png?t=N7T8https://zhuanlan.zhihu.com/p/654941615 2023 National College Student Mathematical Modeling Contest Detailed explanation of question E + Python code source code (2) icon-default.png?t=N7T8https:/ /zhuanlan.zhihu.com/p/654977217 Take the time to read it carefully if necessary. Let me briefly introduce myself: The blogger has been focusing on modeling for four years, and has participated in dozens of mathematical modeling, large and small, and understands the principles of various models, the modeling process of each model, and various problem analysis methods. He has participated in more than ten mathematical modeling competitions, won two M awards and one H award in three US competitions, and the second prize in the national competition. I hope that if you encounter modeling competitions in the future, you can like me and I can provide free ideas and some source codes. As long as I still have time for future digital modeling competitions, I will definitely write free and open source ideas as soon as possible. The blogger keeps up with various digital and analog competitions, and also recommends the column carefully created by the author. The purpose of this column is to quickly use various mathematical models and codes with zero foundation. Each article contains practical projects and runnable code. Bloggers keep up with various digital and analog competitions. For each digital and analog competition, bloggers will write the latest ideas and codes into this column, as well as detailed ideas and fully operational code:

Quick Learning in One Article - Commonly Used Models in Mathematical Modeling icon-default.png?t=N7T8https://blog.csdn.net/master_hunter/category_10967944.html I solved the first question of question D yesterday. Many people asked me for the source code. To be honest, the source code is really difficult to provide. There are many The direct management of the team does not care about the direct CP, which is very risky. I have given the general framework and custom functions but they still don’t know how to combine them. There is really no way. I only give them here as a reference. The first question of the review is to show you how to implement the code. :

Question D of the 2023 National College Student Mathematical Modeling Competition Detailed explanation of space utilization ideas for raising Hu sheep in captivity + Python source code icon-default.png?t=N7T8https://zhuanlan.zhihu.com/p/655008846

Problem one solution:

def simulate_annual_slaughter(basic_ewes, ram, pen_capacity):
    slaughtered_lambs = 0

    for _ in range(365):
        pregnant_ewes = min(basic_ewes, pen_capacity["natural_mating"]["ewes"]) * pen_capacity["natural_mating"]["ram"]

        # 怀孕
        lambs_born = min(pregnant_ewes * 2, pen_capacity["pregnancy"]["ewes"])

        # 分娩和哺乳
        lactating_ewes = min(lambs_born, pen_capacity["lactation"]["ewes"])
        lactating_lambs = min(lambs_born * 2, pen_capacity["lactation"]["lambs"])

        # 羊只成长
        fattening_lambs = min(lactating_lambs, pen_capacity["fattening"]["lambs"])

        # 更新羊只数量
        basic_ewes = basic_ewes + lambs_born - lactating_ewes

        # 累积出栏羊只数量
        slaughtered_lambs += fattening_lambs

    return slaughtered_lambs

# 初始条件
basic_ewes = 200  # 基础母羊数量
ram = 2  # 种公羊数量

# 羊栏规格
pen_capacity = {
    "natural_mating": {"ram": 1, "ewes": 14},
    "pregnancy": {"ewes": 8},
    "lactation": {"ewes": 6, "lambs": 6},
    "fattening": {"lambs": 14}
}

slaughtered_lambs = simulate_annual_slaughter(basic_ewes, ram, pen_capacity)

print(f"每年预计出栏羊只数量:{slaughtered_lambs:.2f} 只")

# 初始条件
basic_ewes = 200  # 基础母羊数量
ram = 4  # 种公羊数量

# 阶段参数
natural_mating_period = 20
gestation_period = 149
lactation_period = 40
fattening_period = 210
rest_period = 20

# 羊栏规格
pen_capacity = {
    "natural_mating": {"ram": 1, "ewes": 14},
    "pregnancy": {"ewes": 8},
    "lactation": {"ewes": 6, "lambs": 6},
    "fattening": {"lambs": 14}
}
# 模拟中使用的羊栏数量
used_pens = {
    "natural_mating": 0,
    "pregnancy": 0,
    "lactation": 0,
    "fattening": 0
}
# 记录出栏羊只数量
slaughtered_lambs = 0

# 模拟一年的时间
for _ in range(365):

    # 自然交配
    pregnant_ewes = min(basic_ewes, pen_capacity["natural_mating"]["ewes"]) * ram

    # 怀孕
    lambs_born = min(pregnant_ewes * 2, pen_capacity["pregnancy"]["ewes"])

    # 分娩和哺乳
    lactating_ewes = min(lambs_born, pen_capacity["lactation"]["ewes"])
    lactating_lambs = min(lambs_born * 2, pen_capacity["lactation"]["lambs"])

    # 羊只成长
    fattening_lambs = min(lactating_lambs, pen_capacity["fattening"]["lambs"])

    # 更新羊只数量
    basic_ewes = basic_ewes + lambs_born - lactating_ewes
    ram = ram

    # 累积出栏羊只数量
    slaughtered_lambs += fattening_lambs
    # 记录使用的羊栏数量
    used_pens["natural_mating"] += 1
    used_pens["pregnancy"] += 1
    used_pens["lactation"] += 1
    used_pens["fattening"] += 1

# 所需羊栏数量
required_pens = max(used_pens.values())

# 现有羊栏数量
existing_pens = 112

# 计算羊栏缺口
pen_shortage = required_pens - existing_pens

# 输出结果
print(f"现有羊栏数量:{existing_pens} 栏")
print(f"所需羊栏数量:{required_pens} 栏")
print(f"羊栏缺口:{pen_shortage} 栏")

 

The above is for reference only, you can modify the corresponding parameters according to your team's problem solving situation.

Question 2

On the basis of question 1, specific production plans are given for 112 standard sheep pens (including the timing and number of breeding rams and basic ewes, the usage plan of the sheep pens, the annual number of sheep slaughtered, etc.), so that The number of annual slaughter sheep is the largest.

answer

From the question correlation, question 1 and question 2 can actually be regarded as calculation and inversion optimization strategy to obtain the optimal solution. Then the idea of ​​​​the second question cannot be considered from the calculation results. The basic number of ewes that meets the standard number of sheep pens should be calculated and analyzed step by step from the basic conditions. Then let us redefine the problem:

Assume that the numbers of breeding rams and foundation ewes are x and y respectively .

In each reproductive cycle, the reproductive capacity of the basic ewe is y , so the number of sheep that can be produced in each cycle is 2×2× y .

The total length of a reproductive cycle is 20+149+20+210=419 days

Therefore, 0.87 remaining cycles can be carried out in a year, so the number of sheep produced per year is 0.87×2×y

In order to ensure that no less than 1,500 sheep are slaughtered every year, we need to solve the equation:

0.87×2×y≥1500

Solve to get y≥861

Under the condition of realizing continuous production, assuming that the utilization rate of each sheep pen is p , the following conditions need to be met:

  • The time the sheep pen is used for natural mating: p ×20 days
  • Sheeppen used during pregnancy: p×149 days
  • Sheep pen for lactation: p×40 days
  • Sheeppen used for lamb fattening period: p ×210 days
  • Sheeppen idle period: (1− p )×20 days

Combined with the previous results, we can determine the reasonable number of breeding rams and foundation ewes. This number is then used to simulate the number of sheep slaughtered to estimate the range of annual sheep slaughtered.

# 计算一个繁育周期的总长度
breeding_cycle_length = natural_mating_period + gestation_period + lactation_period + fattening_period

# 计算一年内可以进行的繁育周期数
num_cycles_per_year = days_in_year / breeding_cycle_length

# 问题 1: 确定养殖场种公羊与基础母羊的合理数量
# 基础母羊数量 (y) 至少需要满足每年出栏不少于1500只羊的条件
required_ewes = 1500 / (2 * num_cycles_per_year)

# 问题 2: 估算现有标准羊栏数量的缺口
# 确定每个羊栏的利用率
pen_capacity = num_pens * pen_utilization

# 一个羊栏在一个繁育周期内的总利用天数
pen_total_days = pen_utilization * breeding_cycle_length

# 一个羊栏的平均利用天数,考虑到空闲期
pen_average_days = pen_total_days + (1 - pen_utilization) * rest_period

# 可以养殖的基础母羊数量
feasible_ewes = pen_capacity * pen_average_days / breeding_cycle_length

# 问题 3: 估算年化出栏羊只数量的范围
# 计算实际每年产羊的数量
actual_annual_lambs = 2 * num_cycles_per_year * required_ewes

# 输出结果
print(f"问题 1: 养殖场需要至少 {int(required_ewes)} 只基础母羊。")
print(f"问题 2: 现有标准羊栏数量满足的基础母羊数量为 {int(feasible_ewes)} 只。")
print(f"问题 3: 年化出栏羊只数量的范围为 {int(actual_annual_lambs)} 只.")

Question 1: The farm requires at least 860 foundation ewes.

Question 2: The basic number of ewes that meets the existing standard sheep pen number is 85.

Question 3: The range of annualized sheep numbers is 1500.

In order to give a specific production plan, we need to consider the following factors:

  1. Number and timing of pairings of foundation ewes and breeding rams.
  2. The use of sheep pens ensures that sheep at all stages can be properly accommodated.
  3. Maximize the annual number of sheep slaughtered.

Space in the sheep pen will be utilized as much as possible to maximize output.

Production Plan:

Breeding rams are paired with basic ewes:

    • Pairing time: 10 days before the natural mating period
    • Number of breeding rams: 2
    • Basic number of ewes: 100

pregnancy:

  • Number of sheep pens used: 8 (112 sheep pens/0.87)
  • Capacity per pen: 8 expectant ewes
  • Pregnancy cycle: 149 days

Childbirth and lactation:

  • Number of sheep pens used: 9 (112 sheep pens/0.87)
  • Capacity per pen: 6 ewes and their lambs
  • Total number of sheep: 54 ewes + 54 lambs
  • Childbirth cycle: 40 days

Lamb fattening period:

  • Number of sheep pens used: 8 (112 sheep pens/0.87)
  • Capacity per pen: 14 lambs
  • Lamb fattening cycle: 210 days

cycle:

After the lamb fattening period is over, the adult sheep are returned to the waiting area, the lambs are moved to the fattening area, and the cycle proceeds to the next round.

I just hope that if you encounter modeling competitions in the future, you can get to know me. I can provide free ideas and some source codes. As long as I still have time for future digital modeling competitions, I will definitely write free open source ideas as soon as possible. Please pay attention. And likes are the motivation for me to write! ! ! If you want to know more, please contact the blogger~~~~ In addition, I would like to recommend the column carefully created by the author. The purpose of this column is to quickly use various mathematical models and codes with zero foundation. Each article contains practical projects and runnable code. Bloggers keep up with various digital and analog competitions. For each digital and analog competition, bloggers will write the latest ideas and codes into this column, as well as detailed ideas and complete codes:

Quick learning in one article - commonly used models in mathematical modeling icon-default.png?t=N7T8https://blog.csdn.net/master_hunter/category_10967944.html

Next chapter updates the source code of the second question and the fourth question of E question

Guess you like

Origin blog.csdn.net/master_hunter/article/details/132780033