/// <summary>
 /// Constructs a new SearchContext.
 /// </summary>
 /// <param name="domain"><see cref="SearchContext{D, P, A, S, Sol, N}.Domain"/></param>
 /// <param name="source"><see cref="SearchContext{D, P, A, S, Sol, N}.Source"/></param>
 /// <param name="target"><see cref="SearchContext{D, P, A, S, Sol, N}.Target"/></param>
 /// <param name="subject"><see cref="SearchContext{D, P, A, S, Sol, N}.Subject"/></param>
 /// <param name="solution"><see cref="SearchContext{D, P, A, S, Sol, N}.Solution"/></param>
 /// <param name="status"><see cref="SearchContext{D, P, A, S, Sol, N}.Status"/></param>
 /// <param name="startNode"><see cref="SearchContext{D, P, A, S, Sol, N}.StartNode"/></param>
 /// <param name="search"><see cref="SearchContext{D, P, A, S, Sol, N}.Search"/></param>
 /// <param name="expansion"><see cref="SearchContext{D, P, A, S, Sol, N}.Expansion"/></param>
 /// <param name="application"><see cref="SearchContext{D, P, A, S, Sol, N}.Application"/></param>
 /// <param name="evaluation"><see cref="SearchContext{D, P, A, S, Sol, N}.Evaluation"/></param>
 /// <param name="goal"><see cref="SearchContext{D, P, A, S, Sol, N}.Goal"/></param>
 /// <param name="cloner"><see cref="SearchContext{D, P, A, S, Sol, N}.Cloner"/></param>
 public SearchContext(D domain, P source, P target, S subject, Sol solution, SearchStatus status, SearchNode <P, A> startNode, ISearchStrategy <D, P, A, S, Sol> search, IExpansionStrategy <D, P, A, S, Sol, A> expansion, IApplicationStrategy <D, P, A, S, Sol> application, IEvaluationStrategy <D, P, A, S, Sol> evaluation, IGoalStrategy <D, P, A, S, Sol> goal, ICloneStrategy <P> cloner)
 {
     Domain      = domain;
     Source      = source?.Copy();
     Target      = target?.Copy();
     Subject     = subject;
     Solution    = solution;
     Status      = status;
     StartNode   = startNode?.Copy();
     Search      = search;
     Expansion   = expansion;
     Application = application;
     Evaluation  = evaluation;
     Goal        = goal;
     Cloner      = cloner;
 }
 public PerformanceEvaluator(IEvaluationStrategy evaluationStrategy)
 {
     this._evaluationStrategy = evaluationStrategy;
 }
        internal static IEnumerable <Evidence> Permutation(this IEnumerable <Factor> source, IEvaluationStrategy strategy)
        {
            var layer      = source.First();
            var nextLayers = source.Skip(1);

            if (nextLayers.Any())
            {
                foreach (var set in layer.Values)
                {
                    foreach (var childSet in nextLayers.Permutation(strategy))
                    {
                        if (childSet == null)
                        {
                            yield return(set);
                        }
                        else
                        {
                            var parameter = Expression.Parameter(typeof(HttpContextBase), "x");

                            var body = Expression.AndAlso(
                                Expression.Invoke(set.Expression, parameter),
                                Expression.Invoke(childSet.Expression, parameter));

                            yield return(new Evidence
                            {
                                Name = $"{set.Name}-{childSet.Name}",
                                Expression = Expression.Lambda <Func <HttpContextBase, bool> >(body, parameter),
                                Weight = set.Weight + childSet.Weight + 0.1
                            });
                        }
                    }
                    if (layer.Required == false)
                    {
                        foreach (var x in nextLayers.Permutation(strategy))
                        {
                            yield return(x);
                        }
                    }
                }
            }
            else
            {
                foreach (var set in layer.Values)
                {
                    yield return(set);
                }

                if (layer.Required == false)
                {
                    yield return(null);
                }
            }
        }
Beispiel #4
0
 public int Evaluate(IList <Cell> cells, IEvaluationStrategy strategy)
 {
     return(strategy.Evaluate(cells, this));
 }