Ejemplo n.º 1
0
        public void TestEpsilonGreedy()
        {
            var epsilonGreedyTests = new EpsilonGreedyTestConfiguration[]
            {
                // No exploration
                new EpsilonGreedyTestConfiguration
                {
                    AppId = TestContext.TestName + "NoExplorationFixedActionContext",
                    ContextType = ContextType.FixedAction, // test fixed-action context
                    Epsilon = 0f,
                    NumberOfActions = 20,
                    ExperimentalUnitIdList = Enumerable.Range(1, 100).Select(i => i.ToString()).ToList(),
                    PolicyConfiguration = new FixedPolicyConfiguration { Action = 10 }
                },
                new EpsilonGreedyTestConfiguration
                {
                    AppId = TestContext.TestName + "NoExplorationVariableActionContext",
                    ContextType = ContextType.VariableAction, // test variable-action context
                    Epsilon = 0f,
                    NumberOfActions = 20,
                    ExperimentalUnitIdList = Enumerable.Range(1, 100).Select(i => i.ToString()).ToList(),
                    PolicyConfiguration = new FixedPolicyConfiguration { Action = 10 }
                },

                // Regular exploration
                new EpsilonGreedyTestConfiguration
                {
                    AppId = TestContext.TestName + "RegularExplorationFixedActionContext",
                    ContextType = ContextType.FixedAction,
                    Epsilon = 0.2f,
                    NumberOfActions = 10,
                    ExperimentalUnitIdList = Enumerable.Range(1, 100).Select(i => i.ToString()).ToList(),
                    PolicyConfiguration = new FixedPolicyConfiguration { Action = 9 }
                },
                new EpsilonGreedyTestConfiguration
                {
                    AppId = TestContext.TestName + "RegularExplorationVariableActionContext",
                    ContextType = ContextType.VariableAction,
                    Epsilon = 0.2f,
                    NumberOfActions = 10,
                    ExperimentalUnitIdList = Enumerable.Range(1, 100).Select(i => i.ToString()).ToList(),
                    PolicyConfiguration = new FixedPolicyConfiguration { Action = 9 }
                },

                // Heavy exploration
                new EpsilonGreedyTestConfiguration
                {
                    AppId = TestContext.TestName + "HeavyExplorationFixedActionContext",
                    ContextType = ContextType.FixedAction,
                    Epsilon = 0.9f,
                    NumberOfActions = 90, // test many actions
                    ExperimentalUnitIdList = Enumerable.Range(1, 100).Select(i => i.ToString()).ToList(),
                    PolicyConfiguration = new FixedPolicyConfiguration { Action = 81 }
                },
                new EpsilonGreedyTestConfiguration
                {
                    AppId = TestContext.TestName + "HeavyExplorationVariableActionContext",
                    ContextType = ContextType.VariableAction,
                    Epsilon = 0.9f,
                    NumberOfActions = 90,
                    ExperimentalUnitIdList = Enumerable.Range(1, 100).Select(i => i.ToString()).ToList(),
                    PolicyConfiguration = new FixedPolicyConfiguration { Action = 81 }
                }
            };

            Run(outputFilePatternExpected, outputFilePatternActual, outputJsonConfigFile, epsilonGreedyTests);

            for (uint i = 0; i < epsilonGreedyTests.Length; i++)
            {
                CompareExplorationData(FormatPath(outputFilePatternExpected, i), FormatPath(outputFilePatternActual, i));
            }
        }
Ejemplo n.º 2
0
        public void TestEpsilonGreedy()
        {
            var epsilonGreedyTests = new EpsilonGreedyTestConfiguration[]
            {
                // No exploration
                new EpsilonGreedyTestConfiguration
                {
                    AppId                  = TestContext.TestName + "NoExplorationFixedActionContext",
                    ContextType            = ContextType.FixedAction, // test fixed-action context
                    Epsilon                = 0f,
                    NumberOfActions        = 20,
                    ExperimentalUnitIdList = Enumerable.Range(1, 100).Select(i => i.ToString()).ToList(),
                    PolicyConfiguration    = new FixedPolicyConfiguration {
                        Action = 10
                    }
                },
                new EpsilonGreedyTestConfiguration
                {
                    AppId                  = TestContext.TestName + "NoExplorationVariableActionContext",
                    ContextType            = ContextType.VariableAction, // test variable-action context
                    Epsilon                = 0f,
                    NumberOfActions        = 20,
                    ExperimentalUnitIdList = Enumerable.Range(1, 100).Select(i => i.ToString()).ToList(),
                    PolicyConfiguration    = new FixedPolicyConfiguration {
                        Action = 10
                    }
                },

                // Regular exploration
                new EpsilonGreedyTestConfiguration
                {
                    AppId                  = TestContext.TestName + "RegularExplorationFixedActionContext",
                    ContextType            = ContextType.FixedAction,
                    Epsilon                = 0.2f,
                    NumberOfActions        = 10,
                    ExperimentalUnitIdList = Enumerable.Range(1, 100).Select(i => i.ToString()).ToList(),
                    PolicyConfiguration    = new FixedPolicyConfiguration {
                        Action = 9
                    }
                },
                new EpsilonGreedyTestConfiguration
                {
                    AppId                  = TestContext.TestName + "RegularExplorationVariableActionContext",
                    ContextType            = ContextType.VariableAction,
                    Epsilon                = 0.2f,
                    NumberOfActions        = 10,
                    ExperimentalUnitIdList = Enumerable.Range(1, 100).Select(i => i.ToString()).ToList(),
                    PolicyConfiguration    = new FixedPolicyConfiguration {
                        Action = 9
                    }
                },

                // Heavy exploration
                new EpsilonGreedyTestConfiguration
                {
                    AppId                  = TestContext.TestName + "HeavyExplorationFixedActionContext",
                    ContextType            = ContextType.FixedAction,
                    Epsilon                = 0.9f,
                    NumberOfActions        = 90, // test many actions
                    ExperimentalUnitIdList = Enumerable.Range(1, 100).Select(i => i.ToString()).ToList(),
                    PolicyConfiguration    = new FixedPolicyConfiguration {
                        Action = 81
                    }
                },
                new EpsilonGreedyTestConfiguration
                {
                    AppId                  = TestContext.TestName + "HeavyExplorationVariableActionContext",
                    ContextType            = ContextType.VariableAction,
                    Epsilon                = 0.9f,
                    NumberOfActions        = 90,
                    ExperimentalUnitIdList = Enumerable.Range(1, 100).Select(i => i.ToString()).ToList(),
                    PolicyConfiguration    = new FixedPolicyConfiguration {
                        Action = 81
                    }
                }
            };

            Run(outputFilePatternExpected, outputFilePatternActual, outputJsonConfigFile, epsilonGreedyTests);

            for (uint i = 0; i < epsilonGreedyTests.Length; i++)
            {
                CompareExplorationData(FormatPath(outputFilePatternExpected, i), FormatPath(outputFilePatternActual, i));
            }
        }