AForge.MachineLearning.TabuSearchExploration.ChooseAction C# (CSharp) Method

ChooseAction() public method

Choose an action.
The method chooses an action depending on the provided estimates. The estimates can be any sort of estimate, which values usefulness of the action (expected summary reward, discounted reward, etc). The action is choosed from non-tabu actions only.
public ChooseAction ( double actionEstimates ) : int
actionEstimates double Action estimates.
return int
        public int ChooseAction( double[] actionEstimates )
        {
            // get amount of non-tabu actions
            int nonTabuActions = actions;
            for ( int i = 0; i < actions; i++ )
            {
                if ( tabuActions[i] != 0 )
                {
                    nonTabuActions--;
                }
            }

            // allowed actions
            double[] allowedActionEstimates = new double[nonTabuActions];
            int[]    allowedActionMap = new int[nonTabuActions];

            for ( int i = 0, j = 0; i < actions; i++ )
            {
                if ( tabuActions[i] == 0 )
                {
                    // allowed action
                    allowedActionEstimates[j] = actionEstimates[i];
                    allowedActionMap[j] = i;
                    j++;
                }
                else
                {
                    // decrease tabu time of tabu action
                    tabuActions[i]--;
                }
            }

            return allowedActionMap[basePolicy.ChooseAction( allowedActionEstimates )]; ;
        }