Example #1
0
        public static AWSXRayRecorder BuildAWSXRayRecorder(ISamplingStrategy samplingStrategy = null, ISegmentEmitter segmentEmitter = null, string daemonAddress = null, ITraceContext traceContext = null)
        {
            AWSXRayRecorderBuilder builder = new AWSXRayRecorderBuilder();

            if (samplingStrategy != null)
            {
                builder.WithSamplingStrategy(samplingStrategy);
            }
            if (segmentEmitter != null)
            {
                builder.WithSegmentEmitter(segmentEmitter);
            }
            if (!string.IsNullOrEmpty(daemonAddress))
            {
                builder.WithDaemonAddress(daemonAddress);
            }
            if (traceContext != null)
            {
                builder.WithTraceContext(traceContext);
            }

            var result = builder.Build();

            return(result);
        }
 /// <summary>
 /// Constructs a new instance.
 /// </summary>
 /// <param name="explorationStrategy">The exploration strategy.</param>
 /// <param name="playoutStrategy">The playout strategy.</param>
 /// <param name="samplingStrategy">The sampling strategy.</param>
 /// <param name="solutionStrategy">The solution strategy.</param>
 /// <param name="policyGlobal">The global policy.</param>
 public NMCTSBuilder(IExplorationStrategy <D, P, A, S, Sol> explorationStrategy, IPlayoutStrategy <D, P, A, S, Sol> playoutStrategy, ISamplingStrategy <P, A> samplingStrategy, ISolutionStrategy <D, P, A, S, Sol, TreeSearchNode <P, A> > solutionStrategy, double policyGlobal)
 {
     ExplorationStrategy = explorationStrategy;
     PlayoutStrategy     = playoutStrategy;
     SamplingStrategy    = samplingStrategy;
     SolutionStrategy    = solutionStrategy;
     PolicyGlobal        = policyGlobal;
 }
Example #3
0
 /// <summary>
 /// Constructs a new instance.
 /// </summary>
 /// <param name="selectionStrategy">The selection strategy.</param>
 /// <param name="expansionStrategy">The expansion strategy.</param>
 /// <param name="backPropagationStrategy">The back propagation strategy.</param>
 /// <param name="finalNodeSelectionStrategy">The final node selection strategy.</param>
 /// <param name="evaluationStrategy">The state evaluation strategy.</param>
 /// <param name="explorationStrategy">The exploration strategy.</param>
 /// <param name="solutionStrategy">The solution strategy.</param>
 /// <param name="samplingStrategy">The sampling strategy.</param>
 /// <param name="playoutStrategy">The playout strategy.</param>
 /// <param name="time">The amount of time allowed for the search.</param>
 /// <param name="iterations">The amount of iterations allowed for the search.</param>
 /// <param name="globalPolicy">The global policy.</param>
 public NMCTS(ITreeSelection <D, P, A, S, Sol> selectionStrategy,
              ITreeExpansion <D, P, A, S, Sol> expansionStrategy,
              ITreeBackPropagation <D, P, A, S, Sol> backPropagationStrategy,
              ITreeFinalNodeSelection <D, P, A, S, Sol> finalNodeSelectionStrategy,
              IStateEvaluation <D, P, A, S, Sol, TreeSearchNode <P, A> > evaluationStrategy,
              IExplorationStrategy <D, P, A, S, Sol> explorationStrategy,
              ISolutionStrategy <D, P, A, S, Sol, TreeSearchNode <P, A> > solutionStrategy,
              ISamplingStrategy <P, A> samplingStrategy,
              IPlayoutStrategy <D, P, A, S, Sol> playoutStrategy, long time, int iterations, double globalPolicy) :
     base(selectionStrategy, expansionStrategy, backPropagationStrategy, finalNodeSelectionStrategy,
          evaluationStrategy, solutionStrategy, time, iterations)
 {
     ExplorationStrategy = explorationStrategy;
     SamplingStrategy    = samplingStrategy;
     PlayoutStrategy     = playoutStrategy;
     PolicyGlobal        = globalPolicy;
 }
        private static AWSXRayRecorder BuildAWSXRayRecorder(ISamplingStrategy samplingStrategy, ISegmentEmitter segmentEmitter = null)
        {
            AWSXRayRecorderBuilder builder;

            if (segmentEmitter != null)
            {
                builder = new AWSXRayRecorderBuilder()
                          .WithSamplingStrategy(samplingStrategy).WithSegmentEmitter(segmentEmitter);
            }
            else
            {
                builder = new AWSXRayRecorderBuilder()
                          .WithSamplingStrategy(samplingStrategy);
            }

            var result = builder.Build();

            return(result);
        }
 /// <summary>
 /// Instance of <see cref="DefaultSamplingStrategy"/>.
 /// </summary>
 /// <param name="samplingRuleManifest">Path to local sampling maifest file.</param>
 public DefaultSamplingStrategy(string samplingRuleManifest)
 {
     _localFallbackRules = new LocalizedSamplingStrategy(samplingRuleManifest);
     InititalizeStrategy();
 }
 /// <summary>
 /// Instance of <see cref="DefaultSamplingStrategy"/>.
 /// </summary>
 public DefaultSamplingStrategy()
 {
     _localFallbackRules = new LocalizedSamplingStrategy();
     InititalizeStrategy();
 }
Example #7
0
 /// <summary>
 /// Adds the given sampling strategy to builder. There can exist only one sampling strategy.
 /// Any previous value of sampling strategy will be overwritten.
 /// </summary>
 /// <param name="newStrategy">A sampling strategy to add</param>
 /// <returns>The builder with sampling strategy added.</returns>
 public AWSXRayRecorderBuilder WithSamplingStrategy(ISamplingStrategy newStrategy)
 {
     _samplingStrategy = newStrategy;
     return(this);
 }
Example #8
0
 /// <summary>
 /// Adds the given sampling strategy to builder. There can exist only one sampling strategy.
 /// Any previous value of sampling strategy will be overwritten.
 /// </summary>
 /// <param name="newStrategy">A sampling strategy to add</param>
 /// <returns>The builder with sampling strategy added.</returns>
 public AWSXRayRecorderBuilder WithSamplingStrategy(ISamplingStrategy newStrategy)
 {
     _samplingStrategy = newStrategy ?? throw new ArgumentNullException("SamplingStrategy");
     return(this);
 }
Example #9
0
 public abstract ISearchStrategy <D, P, A, S, A> SetupNMCTS(ISamplingStrategy <P, A> samplingStrategy);
        public override ISearchStrategy <object, TicTacToeState, TicTacToeMove, object, TicTacToeMove> SetupNMCTS(ISamplingStrategy <TicTacToeState, TicTacToeMove> samplingStrategy)
        {
            var builder = NMCTS <object, TicTacToeState, TicTacToeMove, object, TicTacToeMove> .Builder();

            builder.Iterations          = 10000;
            builder.PlayoutStrategy     = new AgentPlayout <object, TicTacToeState, TicTacToeMove, object, TicTacToeMove>(Agent);
            builder.EvaluationStrategy  = EvaluationStrategy;
            builder.SolutionStrategy    = new ActionSolution <object, TicTacToeState, TicTacToeMove, object, TicTacToeMove, TreeSearchNode <TicTacToeState, TicTacToeMove> >();
            builder.ExplorationStrategy = new ChanceExploration <object, TicTacToeState, TicTacToeMove, object, TicTacToeMove>(0.5);
            builder.PolicyGlobal        = 0.2;
            builder.SamplingStrategy    = samplingStrategy;

            return(builder.Build());
        }