添加基础数据结构、公用函数、接口等

This commit is contained in:
2025-11-14 11:33:43 +08:00
commit fe1071287b
4 changed files with 213 additions and 0 deletions

51
core/common.py Normal file
View File

@@ -0,0 +1,51 @@
from functools import wraps, reduce
from collections import defaultdict
from tqdm import tqdm
import os
import time
import math
import random
import copy
import argparse
# import joblib
import pickle
import warnings
import heapq
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib
import traceback
import openpyxl
import itertools
matplotlib.use('TkAgg')
# feeder_width = {'SM8': (7.25, 7.25), 'SM12': (7.00, 20.00), 'SM16': (7.00, 22.00),
# 'SM24': (7.00, 29.00), 'SM32': (7.00, 44.00), 'SME8': (7.25, 7.25),
# 'SME12': (7.00, 20.00), 'SME16': (7.00, 22.00), 'SME24': (7.00, 29.00),
# 'SME32': (7.00, 44.00), 'Tray Feeder': (7.25, 7.25)}
feeder_width = {'SM8': (7.25, 7.25), 'SM12': (7.25, 7.25), 'SM16': (7.25, 7.25),
'SM24': (7.25, 7.25), 'SM32': (7.25, 7.25), 'SME8': (7.25, 7.25),
'SME12': (7.25, 7.25), 'SME16': (7.25, 7.25), 'SME24': (7.25, 7.25),
'SME32': (7.25, 7.25), 'Tray Feeder': (7.25, 7.25)}
nozzle_limit = {'CN065': 100, 'CN040': 100, 'CN020': 100, 'CN400': 100, 'CN140': 100, 'CN220': 100, 'CN750': 100}
def timer_wrapper(func):
@wraps(func)
def measure_time(*args, **kwargs):
start_time = time.time()
result = func(*args, **kwargs)
hinter = True
for key, val in kwargs.items():
if key == 'hinter':
hinter = val
if hinter:
print(f"function {func.__name__} running time : {time.time() - start_time:.3f} s")
return result
return measure_time

7
core/interface.py Normal file
View File

@@ -0,0 +1,7 @@
# 用于提供对外接口
from data.type import MachineConfig
from opt.smm.basis import *
from opt.smm.feeder_priority import FeederPriorityOpt
from opt.smm.cell_division import CellDivisionOpt
from opt.smm.hybrid_genetic import HybridGeneticOpt
from opt.smm.aggregation import Aggregation