function [bestActId,alphaRating] = policyQuery(stateVars, belState, alphaVectors, policy)
% function [bestActId,alphaRating] = policyQuery(stateVars, belState, alphaVectors, policy)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Author: Pascal Poupart (Copyright 2007)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Inputs:
%
% stateVars: list of state variables
% belState: current belief state
% alphaVectors: value function
% policy: list of actions for each alphaVector
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Outputs:
%
% bestActId: best action
% alphaRating: value and action for each alpha vector
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Comments:
%
% Computes the best action for a given belief state according to a set of alphaVectors
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

bestVal = -inf;
for alphaId = 1:length(alphaVectors)
  val = OP.dotProduct(belState, alphaVectors(alphaId), stateVars);
  alphaRating(alphaId).value = val;
  alphaRating(alphaId).action = policy(alphaId);
  if val > bestVal
    bestVal = val; 
    bestAlphaId = alphaId;
  end
end
bestActId = policy(bestAlphaId);



