修改输入量错误,修改早停逻辑错误(绝对变化改为相对变化)
This commit is contained in:
parent
0e5aaecf02
commit
532d8d8522
|
|
@ -13,7 +13,7 @@ class RiskEnterpriseData:
|
|||
def __init__(self):
|
||||
self.I = 8 # 物料种类数(与订单一致)
|
||||
self.C0_i_min = [50, 100, 150, 80, 100, 150, 80, 100] # 单物料的单位时间最小产能
|
||||
self.C0_total_max = 18000 # 总产能上限(单位时间)
|
||||
self.C0_total_max = 1800 # 总产能上限(单位时间)
|
||||
self.distance = 30 # 与需求点的距离
|
||||
class SupplierData:
|
||||
"""供应商数据类:存储各供应商的产能、价格、距离等信息"""
|
||||
|
|
@ -78,7 +78,7 @@ class SupplierData:
|
|||
[0, 0, 10, 0, 12, 0, 8, 16]
|
||||
]
|
||||
# 供应商与需求点的距离(supplier_count)
|
||||
self.distance = [50, 40, 60, 30, 60, 80, 50, 60]
|
||||
self.distance = [50, 40, 60, 30, 60, 80]
|
||||
class Config:
|
||||
"""算法参数配置类:存储NSGA-II的各类参数"""
|
||||
def __init__(self):
|
||||
|
|
@ -99,7 +99,7 @@ class Config:
|
|||
self.early_stop_threshold = 0.1 # 目标值变化阈值
|
||||
# 目标函数数量
|
||||
self.objective_num = 2 # 双目标(成本+延期)
|
||||
self.duplicate_threshold = 0.01 # 重复解保留数量
|
||||
self.duplicate_threshold = 0.01 # 重复解保留数量比例
|
||||
self.print_top_n = 10 # 打印前N个最优解
|
||||
|
||||
class DataStructures:
|
||||
|
|
|
|||
6
main.py
6
main.py
|
|
@ -74,9 +74,9 @@ def main():
|
|||
cost_change = abs(avg_cost - prev_avg_cost)
|
||||
tardiness_change = abs(avg_tardiness - prev_avg_tardiness)
|
||||
|
||||
# 检查是否两个目标的变化都小于阈值
|
||||
if (cost_change < config.early_stop_threshold and
|
||||
tardiness_change < config.early_stop_threshold):
|
||||
# 检查是否两个目标的变化率
|
||||
if (cost_change < config.early_stop_threshold * prev_avg_cost and
|
||||
tardiness_change < config.early_stop_threshold * prev_avg_tardiness):
|
||||
no_improve_count += 1
|
||||
|
||||
else:
|
||||
|
|
|
|||
Loading…
Reference in New Issue