RandomDouble() public static method

public static RandomDouble ( double min, double max ) : double
min double
max double
return double
コード例 #1
0
ファイル: MC-AIXI-CTW.cs プロジェクト: ourobouros/SummerCamp
        override public int Search()
        {
            CtwContextTreeUndo undoInstance = new CtwContextTreeUndo(this);

            MonteCarloSearchNode searchTree = new MonteCarloSearchNode(MonteCarloSearchNode.DecisionNode);

            for (int i = 0; i < this.McSimulations; i++)
            {
                searchTree.Sample(this, this.Horizon);
                this.model_revert(undoInstance);
            }

            //searchTree.PrintBs();


            int    bestAction = -1;
            double bestMean   = double.NegativeInfinity;

            foreach (int action in this.Environment.ValidActions)
            {
                if (!searchTree.Children.ContainsKey(action))
                {
                    continue;
                }

                double mean = searchTree.Children[action].Mean + Utils.RandomDouble(0, 0.0001);
                if (mean > bestMean)
                {
                    bestMean   = mean;
                    bestAction = action;
                }
            }
            return(bestAction);
        }
コード例 #2
0
        public int SelectAction(Agent agent)
        {
            Debug.Assert(agent.MaximumReward() != null, "this is weird place, - in selection action");

            double exploreBias          = (double)agent.Horizon * agent.MaximumReward().Value;
            double explorationNumerator = this.ExplorationConstant * Math.Log(this.Visits);
            int    bestAction           = -1;
            double bestPriority         = double.NegativeInfinity;

            foreach (int action in agent.Environment.ValidActions)
            {
                MonteCarloSearchNode node = null;
                if (this.Children.ContainsKey(action))
                {
                    node = this.Children[action];
                }
                double priority;
                if (node == null || node.Visits == 0)
                {
                    // previously unexplored node
                    priority = this.UnexploredBias;    //unexplored bias
                }
                else
                {
                    priority = node.Mean + exploreBias * Math.Sqrt(explorationNumerator / node.Visits);
                }

                if (priority > (bestPriority + Utils.RandomDouble(0, 0.001)))
                {
                    bestAction   = action;
                    bestPriority = priority;
                }
            }
            return(bestAction);
        }
コード例 #3
0
ファイル: RandomAgent.cs プロジェクト: ourobouros/SummerCamp
 override public double Playout(int horizon)
 {
     return(horizon * Utils.RandomDouble((int)this.Environment.minimum_reward(), (int)this.Environment.maximum_reward()));
 }