refactor: 对配置处理器和配置结构进行重构

This commit is contained in:
2026-04-20 01:44:43 +08:00
parent 5c43059518
commit a38fd3d398
36 changed files with 1097 additions and 917 deletions

View File

@@ -1,18 +1,18 @@
from .base import BaseAlgorithm
from .sm2 import SM2Algorithm
from .sm15m import SM15MAlgorithm
from .fast0 import FAST0Algorithm
from .nsp0 import NSP0Algorithm
__all__ = [
"SM2Algorithm",
"BaseAlgorithm",
"SM15MAlgorithm",
"FAST0Algorithm",
"NSP0Algorithm",
]
algorithms = {
"SM-2": SM2Algorithm,
"FAST-0": FAST0Algorithm,
"NSP-0": NSP0Algorithm,
"SM-15M": SM15MAlgorithm,
"Base": BaseAlgorithm,
}

View File

@@ -8,8 +8,8 @@ from .base import BaseAlgorithm
logger = get_logger(__name__)
class FAST0Algorithm(BaseAlgorithm):
algo_name = "FAST-0"
class NSP0Algorithm(BaseAlgorithm):
algo_name = "NSP-0"
desc = '快速筛选用特殊调度器'
class AlgodataDict(TypedDict):
real_rept: int
@@ -36,7 +36,7 @@ class FAST0Algorithm(BaseAlgorithm):
def revisor(
cls, algodata: dict, feedback: int = 5, is_new_activation: bool = False
):
"""FAST-0 算法迭代决策机制实现
"""NSP-0 算法迭代决策机制实现
根据 quality(0 ~ 5) 进行参数迭代最佳间隔
quality 由主程序评估
@@ -44,7 +44,7 @@ class FAST0Algorithm(BaseAlgorithm):
quality (int): 记忆保留率量化参数
"""
logger.debug(
"FAST0.revisor 开始, feedback: %d, is_new_activation: %s",
"NSP0.revisor 开始, feedback: %d, is_new_activation: %s",
feedback,
is_new_activation,
)
@@ -71,7 +71,7 @@ class FAST0Algorithm(BaseAlgorithm):
def is_due(cls, algodata):
result = algodata[cls.algo_name]["next_date"] <= timer.get_daystamp()
logger.debug(
"FAST0.is_due: next_date=%d, current_daystamp=%d, result=%s",
"NSP0.is_due: next_date=%d, current_daystamp=%d, result=%s",
algodata[cls.algo_name]["next_date"],
timer.get_daystamp(),
result,
@@ -81,11 +81,11 @@ class FAST0Algorithm(BaseAlgorithm):
@classmethod
def get_rating(cls, algodata):
efactor = algodata[cls.algo_name]["efactor"]
logger.debug("FAST0.rate: efactor=%f", efactor)
logger.debug("NSP0.rate: efactor=%f", efactor)
return str(efactor)
@classmethod
def nextdate(cls, algodata) -> int:
next_date = algodata[cls.algo_name]["next_date"]
logger.debug("FAST0.nextdate: %d", next_date)
logger.debug("NSP0.nextdate: %d", next_date)
return next_date

View File

@@ -27,7 +27,7 @@ from heurams.kernel.algorithms.sm15m_calc import (
# 全局状态文件路径
_GLOBAL_STATE_FILE = os.path.expanduser(
pathlib.Path(config_var.get()["paths"]["data"])
pathlib.Path(config_var.get()['global']["paths"]["data"])
/ "global"
/ "sm15m_global_state.json"
)

View File

@@ -19,14 +19,14 @@ class Nucleon:
data_safe['puzzles'] = {}
env = {
"payload": data_safe,
"default": config_var.get()["puzzles"],
"default": config_var.get()['interface']["puzzles"],
"nucleon": data_safe,
}
self.evalizer = Evalizer(environment=env)
data_safe = self.evalizer(deepcopy(data_safe))
env = {
"payload": data_safe,
"default": config_var.get()["puzzles"],
"default": config_var.get()['interface']["puzzles"],
"nucleon": data_safe,
}
self.evalizer = Evalizer(environment=env)