Allenfenqu/luanlai.py

23 lines
831 B
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.

from joblib import Parallel, delayed
import multiprocessing
from hui_fun import liziqunfun # 假设您有一个名为 hui_fun.py 的文件,其中包含 liziqunfun 函数
def multi_huifun(loaded_chrom,yanlinks,road_velocity,dadr,bus_line_sequence,result_array):
# 定义 liziqunfun 函数,注意保留与您提供的函数一致的定义
num_cores = multiprocessing.cpu_count() # 获取可用的 CPU 核心数
# num_cores = 1
results = Parallel(n_jobs=num_cores)(delayed(liziqunfun)(chrom,yanlinks,road_velocity,dadr,bus_line_sequence,result_array) for chrom in loaded_chrom)
return results
if __name__ == "__main__":
results = multi_huifun()
# 在这里可以处理 results例如打印每个结果
for idx, result in enumerate(results):
print(f"Result {idx + 1}: {result}")