You've already forked HeurAMS-legacy
format
This commit is contained in:
@@ -12,9 +12,11 @@ from heurams.services.logger import get_logger
|
||||
|
||||
logger = get_logger(__name__)
|
||||
|
||||
|
||||
class AtomRegister_runtime(TypedDict):
|
||||
locked: bool # 只读锁定标识符
|
||||
min_rate: int # 最低评分
|
||||
locked: bool # 只读锁定标识符
|
||||
min_rate: int # 最低评分
|
||||
|
||||
|
||||
class AtomRegister(TypedDict):
|
||||
nucleon: Nucleon
|
||||
@@ -54,7 +56,7 @@ class Atom:
|
||||
"orbital": None,
|
||||
"orbital_path": None, # 允许设置为 None, 此时使用 nucleon 文件内的推荐配置
|
||||
"orbital_fmt": "toml",
|
||||
"runtime": {"locked": False, "min_rate": 0x3f3f3f3f}
|
||||
"runtime": {"locked": False, "min_rate": 0x3F3F3F3F},
|
||||
}
|
||||
self.do_eval()
|
||||
logger.debug("Atom 初始化完成")
|
||||
@@ -75,19 +77,20 @@ class Atom:
|
||||
Args:
|
||||
rating (int): 评分
|
||||
"""
|
||||
self.registry['runtime']['min_rate'] = min(rating, self.registry['runtime']['min_rate'])
|
||||
|
||||
def lock(self, locked = -1):
|
||||
"""锁定, 效果等同于 self.registry['runtime']['locked'] = locked 或者返回是否锁定
|
||||
"""
|
||||
self.registry["runtime"]["min_rate"] = min(
|
||||
rating, self.registry["runtime"]["min_rate"]
|
||||
)
|
||||
|
||||
def lock(self, locked=-1):
|
||||
"""锁定, 效果等同于 self.registry['runtime']['locked'] = locked 或者返回是否锁定"""
|
||||
if locked == 1:
|
||||
self.registry['runtime']['locked'] = True
|
||||
self.registry["runtime"]["locked"] = True
|
||||
return 1
|
||||
elif locked == 0:
|
||||
self.registry['runtime']['locked'] = False
|
||||
self.registry["runtime"]["locked"] = False
|
||||
return 1
|
||||
elif locked == -1:
|
||||
return self.registry['runtime']["locked"]
|
||||
return self.registry["runtime"]["locked"]
|
||||
return 0
|
||||
|
||||
def revise(self):
|
||||
@@ -96,11 +99,10 @@ class Atom:
|
||||
"""
|
||||
if self.registry["runtime"]["locked"]:
|
||||
logger.debug(f"允许总评分: {self.registry['runtime']['min_rate']}")
|
||||
self.registry["electron"].revisor(self.registry['runtime']["min_rate"])
|
||||
self.registry["electron"].revisor(self.registry["runtime"]["min_rate"])
|
||||
else:
|
||||
logger.debug("禁止总评分")
|
||||
|
||||
|
||||
def do_eval(self):
|
||||
"""
|
||||
执行并以结果替换当前单元的所有 eval 语句
|
||||
|
||||
@@ -67,7 +67,7 @@ class Electron:
|
||||
logger.debug("Electron.is_due: 检查 ident='%s'", self.ident)
|
||||
result = self.algo.is_due(self.algodata)
|
||||
logger.debug("is_due 结果: %s", result)
|
||||
return (result and self.is_activated())
|
||||
return result and self.is_activated()
|
||||
|
||||
def is_activated(self):
|
||||
result = self.algodata[self.algo.algo_name]["is_activated"]
|
||||
|
||||
Reference in New Issue
Block a user