OrderReallocation-HeavyTruc.../data_structures.py

99 lines
3.3 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 数据结构定义
class OrderData:
"""订单数据类"""
def __init__(self):
self.I = 5 # 物料种类数
self.Q = [250, 300, 200, 350, 280] # 各物料待生产量
self.Dd = 12 # 需求交货期(时长)
self.P0 = [50.0, 80.0, 60.0, 70.0, 90.0] # 风险企业单位采购价
self.T0 = [5.0, 8.0, 6.0, 7.0, 9.0] # 风险企业单位运输成本
self.transport_speed = 10.0 # 运输速度(单位/时间)
class RiskEnterpriseData:
"""风险企业数据类(单物料产能约束+总产能约束)"""
def __init__(self):
self.I = 5 # 物料种类数(与订单一致)
self.C0_i_std = [40.0, 50.0, 35.0, 45.0, 48.0] # 单物料单位时间标准产能
self.C0_total_max = 100.0 # 总产能上限
self.distance = 10.0 # 位置距离
class SupplierData:
"""供应商数据类(按约束文档定义)"""
def __init__(self, I=5):
self.I = I
self.supplier_count = 4
self.names = ["S0", "S1", "S2", "S3"]
# 能否生产某物料矩阵 (supplier_count × I)
self.can_produce = [
[1, 1, 1, 1, 1],
[1, 0, 1, 0, 1],
[0, 1, 0, 1, 0],
[0, 0, 1, 1, 1]
]
# 单物料单位时间标准生产能力
self.Cj_i_std = [
[20.0, 18.0, 15.0, 22.0, 25.0],
[25.0, 0.0, 30.0, 0.0, 28.0],
[0.0, 22.0, 0.0, 35.0, 0.0],
[0.0, 0.0, 20.0, 30.0, 22.0]
]
# 供应商单位时间最大总生产能力
self.Cj_total_max = [120.0, 110.0, 100.0, 95.0]
# 最小起订量
self.MinOrder = [
[20.0, 20.0, 15.0, 25.0, 20.0],
[30.0, 0.0, 25.0, 0.0, 30.0],
[0.0, 25.0, 0.0, 30.0, 0.0],
[0.0, 0.0, 20.0, 35.0, 25.0]
]
# 最大供应量
self.MaxOrder = [
[100.0, 150.0, 80.0, 120.0, 130.0],
[120.0, 0.0, 100.0, 0.0, 110.0],
[0.0, 140.0, 0.0, 150.0, 0.0],
[0.0, 0.0, 90.0, 130.0, 100.0]
]
# 单位采购价格
self.P_ij = [
[60.0, 85.0, 70.0, 80.0, 100.0],
[65.0, 0.0, 75.0, 0.0, 105.0],
[0.0, 90.0, 0.0, 85.0, 0.0],
[0.0, 0.0, 78.0, 88.0, 98.0]
]
# 单位运输成本
self.T_ij = [
[7.0, 9.0, 8.0, 10.0, 12.0],
[6.0, 0.0, 9.0, 0.0, 11.0],
[0.0, 10.0, 0.0, 12.0, 0.0],
[0.0, 0.0, 10.0, 13.0, 14.0]
]
# 供应商位置距离
self.distance = [45.0, 35.0, 60.0, 50.0]
class Config:
"""算法参数配置类"""
def __init__(self):
# 种群参数
self.pop_size = 50
self.N1_ratio = 0.2 # 变更成本最小种群比例
self.N2_ratio = 0.2 # 交付延期最短种群比例
self.N3_ratio = 0.3 # 基于风险企业种群比例
self.N4_ratio = 0.3 # 随机种群比例
# 遗传操作参数
self.crossover_prob = 0.8
self.mutation_prob = 0.3
self.max_generations = 100
# 惩罚系数
self.delta = 1.3 # 变更惩罚系数
self.gamma = 0.8 # 提前交付惩罚系数
# 早停参数
self.early_stop_patience = 50
# 目标函数数量
self.objective_num = 2