File size: 1,922 Bytes
85d3923 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | """Task 1 — Feasibility Check (Easy).
The agent observes a scheduling instance (jobs, machines, proposed assignments)
and must respond with "feasible" or "infeasible" to indicate whether all
scheduling constraints are satisfied.
Grading: exact match — 1.0 if correct, 0.1 if wrong, 0.0 if empty.
Max steps per episode: 3.
Expected agent accuracy: ~90%.
"""
from __future__ import annotations
from typing import Any
from environment import INSTANCE_BANK, SchedulingOptEnv
from graders.grader_detection import FeasibilityGrader
from models import Action
TASK_ID = "feasibility_check"
MAX_STEPS = 3
DIFFICULTY = "easy"
def run_episode(env: SchedulingOptEnv, agent_fn: Any) -> dict[str, Any]:
"""Run a single feasibility-check episode.
Args:
env: An initialized SchedulingOptEnv instance.
agent_fn: A callable that receives an Observation and returns a
response string ("feasible" or "infeasible").
Returns:
Episode summary dict with total reward and step count.
"""
obs = env.reset(task_id=TASK_ID)
total_reward = 0.0
steps = 0
info: dict[str, Any] = {}
for _ in range(MAX_STEPS):
response = agent_fn(obs)
action = Action(response=response, task_id=TASK_ID)
obs, reward, done, info = env.step(action)
total_reward += reward
steps += 1
if done:
break
return {
"task": TASK_ID,
"difficulty": DIFFICULTY,
"steps": steps,
"total_reward": round(total_reward, 4),
"info": info,
}
def get_all_instances_with_answers() -> list[dict[str, Any]]:
"""Return instance bank entries relevant to feasibility check."""
return [
{
"instance": entry["instance"],
"is_feasible": entry["is_feasible"],
"description": entry["description"],
}
for entry in INSTANCE_BANK
]
|