In many reinforcement learning settings, a single agent must handle multiple different tasks using a shared representation. Rather than maintaining separate policies or value functions for each task, the agent uses a unified system that conditions its behavior on a task identifier.
Implement a function unified_task_handler that computes task-conditioned action values and an action selection policy for a multi-task RL agent.
Given:
state_features: a numpy array of shape (num_actions, feature_dim) representing the feature vector associated with each available action in the current state.task_weights: a numpy array of shape (num_tasks, feature_dim) containing learned weight vectors, one per task.task_id: an integer specifying which task the agent is currently performing.epsilon: a float (default 0.0) for epsilon-greedy action selection.Your function should return a dictionary with:
'q_values': a numpy array of shape (num_actions,) containing the estimated action values under the specified task.'greedy_action': an integer indicating the action with the highest Q-value. In the case of ties, select the action with the lowest index.'action_probs': a numpy array of shape (num_actions,) containing the epsilon-greedy probability of selecting each action.Use only NumPy.