Skip to content

Commit

Permalink
add logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Shawnsdaddy committed Dec 13, 2024
1 parent d1f418a commit dcc9588
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion arknights_mower/solvers/base_schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -1713,7 +1713,7 @@ def get_resting_plan_new(self, agents, exist_replacement, plan, current_resting)
if (
(op.current_mood() - op.lower_limit) / (op.upper_limit - op.lower_limit)
) > self.op_data.config.resting_threshold:
continue
return
required += 1
logger.debug(f"需求:{current_resting} 当前休息")
logger.debug(f"需求:{required}宿舍空位")
Expand Down
17 changes: 15 additions & 2 deletions arknights_mower/utils/operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from evalidate import Expr, base_eval_model

from arknights_mower.utils.plan import PlanConfig
from . import config

from ..data import agent_arrange_order, agent_list, base_room_list
from ..solvers.record import save_action_to_sqlite_decorator
Expand Down Expand Up @@ -280,8 +281,12 @@ def init_and_validate(self, update=False):
):
self.run_order_rooms[x] = {}
# 判定分组排班可能性
current_high = self.config.max_resting_count
current_low = len(self.dorm) - self.config.max_resting_count
for key in self.groups:
total_count = 0
high_count = 0
low_count = 0
_replacement = []
for name in self.groups[key]:
_candidate = next(
Expand All @@ -298,8 +303,16 @@ def init_and_validate(self, update=False):
_replacement.append(_candidate)
if self.operators[name].workaholic:
continue
if self.operators[name].resting_priority == "high":
high_count += 1
else:
low_count += 1
if (
high_count > current_high or low_count > current_low
) and not config.conf.flexible_shift_mode:
return f"{key} 分组无法排班,宿舍可用高优先{current_high},低优先{current_low}->分组需要高优先{high_count},低优先{low_count}"
total_count += 1
if total_count > len(self.dorm):
if total_count > len(self.dorm) and config.conf.flexible_shift_mode:
return f"{key} 分组无法排班,分组总数(不包含0心情工作){total_count}大于总宿舍数{len(self.dorm)}"
# 设定令夕模式的心情阈值
self.init_mood_limit()
Expand Down Expand Up @@ -826,7 +839,7 @@ def predict_exhaust(self):
remaining_mood = self.mood - self.lower_limit # 剩余心情
depletion_rate = self.depletion_rate # 心情掉率,小时单位
# 计算到心情归零所需时间(小时),再加上当前时间戳
if depletion_rate > 0:
if self.time_stamp and depletion_rate > 0:
return self.time_stamp + timedelta(
hours=((remaining_mood / depletion_rate) - 0.5)
)
Expand Down
2 changes: 2 additions & 0 deletions arknights_mower/utils/scheduler_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ def generate_plan_by_drom(tasks, op_data):
result = []
planned = set()
for time, (dorms, rest_in_full) in ordered:
logger.debug(f"{time},{dorms},{rest_in_full}")
plan = {}
for room in dorms:
if room.name in planned:
Expand Down Expand Up @@ -239,6 +240,7 @@ def generate_plan_by_drom(tasks, op_data):
else TaskTypes.SHIFT_ON,
)
)
logger.debug("生成任务: " + ("||".join([str(t) for t in result])))
return result


Expand Down

0 comments on commit dcc9588

Please sign in to comment.