| import asyncio |
| from typing import Dict, Any |
|
|
| from server.my_env_environment import QuantumCircuitEnvironment |
| from models import ActionType, GateType, QuantumAction |
|
|
| def evaluate_tasks(): |
| env = QuantumCircuitEnvironment() |
|
|
| print("\n=== Testing Diversity Mechanics ===") |
|
|
| |
| print("\n--- Task: Budgeted Optimization (Max Gate Count 3) ---") |
| env.reset() |
| |
| print("Applying 4 gates... (Budget is 3)") |
| env.step(QuantumAction(action_type=ActionType.ADD, gate=GateType.H, qubits=[0])) |
| env.step(QuantumAction(action_type=ActionType.ADD, gate=GateType.CNOT, qubits=[0, 1])) |
| env.step(QuantumAction(action_type=ActionType.ADD, gate=GateType.X, qubits=[1])) |
| obs = env.step(QuantumAction(action_type=ActionType.ADD, gate=GateType.H, qubits=[2])) |
| print(f"Final Score (After 4th gate): {obs.score:.4f} (Notice it is brutally halved!)") |
| |
| |
| print("\n--- Task: Approximate Target (Tolerance Check) ---") |
| env.reset() |
| |
| obs = env.step(QuantumAction(action_type=ActionType.ADD, gate=GateType.H, qubits=[0])) |
| print(f"Current score before stop: {obs.score:.4f}") |
| if obs.score > 0.8: |
| print("Wait, score is high enough to trigger tolerance.") |
| obs = env.step(QuantumAction(action_type=ActionType.STOP)) |
| print(f"Final Reward on STOP: {obs.reward:.4f} (Checks if +0.2 tolerance jump triggered)") |
| |
| |
| print("\n--- Task: Imperfect But Efficient ---") |
| env.reset() |
| obs = env.step(QuantumAction(action_type=ActionType.ADD, gate=GateType.H, qubits=[0])) |
| print(f"Score for H(0): {obs.score:.4f} (Heavy efficiency ratio vs fidelity)") |
| |
| |
| print("\n--- Task: Overfitting Catch ---") |
| |
| env.reset() |
| env.step(QuantumAction(action_type=ActionType.ADD, gate=GateType.H, qubits=[0])) |
| env.step(QuantumAction(action_type=ActionType.ADD, gate=GateType.CNOT, qubits=[0, 1])) |
| |
| |
| |
| |
| print("If an agent surpasses depth 5 with > 0.95 fidelity, it loses -0.1 reward natively per step.") |
|
|
| if __name__ == "__main__": |
| evaluate_tasks() |
|
|