public void setSearchStrategy(SearchStrategy newStrategy)
 {
     if (newStrategy != null)
     {
         searchStrategy = newStrategy;
     }
 }
示例#2
0
        public ProxyDelegate(Func <object, object>[] propertyGetters, ProxyDelegate <TSearch, TResult>[] children,
                             SearchStrategy <TSearch, TResult> strategy, bool isCollection) : base(children, strategy)
        {
            _isCollection = isCollection;

            _propertyGetters = propertyGetters;
        }
示例#3
0
        public static IEnumerable <Component> GetComponentsInOnlyChildren(this Transform target, Type type,
                                                                          SearchStrategy strategy =
                                                                          SearchStrategy.FindComponent)
        {
            var queue = new Queue <Transform>();

            AddChildren(target);

            while (queue.Any())
            {
                var transform  = queue.Dequeue();
                var components = strategy.FindComponents(transform.gameObject, type);

                foreach (var component in components)
                {
                    yield return(component);
                }

                AddChildren(transform);
            }

            void AddChildren(Transform transform)
            {
                for (var index = 0; index < transform.childCount; index++)
                {
                    var child = transform.GetChild(index);
                    queue.Enqueue(child);
                }
            }
        }
示例#4
0
        public void Begin(EmailSender emailSender = null)
        {
            var logger = LoggerFactory.GetLogger();

            int interval = this.ODs.Count / this.ThreadsQuantity;
            int rest     = this.ODs.Count % this.ThreadsQuantity;

            ThreadManager manager = new ThreadManager(this._graph, this.ThreadsQuantity, this.ODs.Count, this.Radius, this.StrategyFactory.SearchName, this.emailSender);

            for (int i = 0; i < this.ThreadsQuantity; i++)
            {
                int begin = i * interval;
                int end   = interval;//i * interval + interval;

                if (i + 1 == this.ThreadsQuantity)
                {
                    end += rest;
                }

                List <Tuple <long, long> > portion = this.ODs.GetRange(begin, end);

                Graph          graphClone     = this._graph.Clone();
                SearchStrategy searhcStrategy = this.StrategyFactory.GetStrategy(graphClone);

                var ts     = new ThreadSearch(graphClone, searhcStrategy, portion, this.Radius, manager);
                var thread = new Thread(new ThreadStart(ts.Search));
                thread.Name = "T" + (i + 1);

                logger.WriteLine(thread.Name + " ODs: " + portion.Count.ToString());

                thread.Start();
            }
        }
    public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        TipViewModel   tipViewModel = value as TipViewModel;
        SearchStrategy strategy     = tipViewModel.SearchStrategy;
        string         searchString = tipViewModel.SearchString;

        return(Strategy.parseInput <string>(searchString, (first, inp) => strategy.tipMap.ContainsKey(first) && inp.Length == 1 ? first + strategy.tipMap[first] : "", AppResources.GeneralSearchTip));
    }
示例#6
0
 public ThreadSearch(Graph graph, SearchStrategy strategy, List <Tuple <long, long> > ODs, double radius, ThreadManager threadManager)
 {
     this._graph        = graph;
     this.Strategy      = strategy;
     this.ODs           = ODs;
     this.Radius        = radius;
     this.ThreadManager = threadManager;
 }
        public void SetSearchStrategy(string stratString)
        {
            SearchStrategy strategy;

            if (SearchStrategy.TryParse(stratString, true, out strategy))
            {
                bookservice.SetSearchStrategy(strategy);
            }
        }
 public void SetSearchStrategy(SearchStrategy searchStrategy)
 {
     _searchStrategy = searchStrategy;
     if (SearchStrategyChanged != null)
     {
         SearchStrategyChanged(this, new EventArgs <SearchStrategy> {
             Data = searchStrategy
         });
     }
 }
 public void NewSeries()
 {
     if (SearchStrategy != null)
     {
         series = new LineSeries {
             Title = SearchStrategy.ToString(), MarkerType = MarkerType.Circle
         };
         Model.Series.Add(series);
     }
 }
示例#10
0
 public Agent(Coordonnees c, SearchStrategy strategy)
 {
     _coordonnees = c;
     _score       = 0;
     _intentions  = new Intentions();
     _capteurs    = new Capteurs();
     _effecteur   = new Effecteurs();
     _strategy    = strategy;
     _belief      = new Belief();
 }
        public static void ApplyAttribute <TAttribute>(MonoBehaviour behaviour, SearchStrategy strategy, object obj = null)
            where TAttribute : ComponentFinderAttribute
        {
            obj ??= behaviour;
            var attributedFields = AttributeHelper.GetAttributedFields <TAttribute>(obj);

            foreach (var(field, attribute) in attributedFields)
            {
                attribute.Apply(behaviour, obj, field, strategy);
            }
        }
示例#12
0
        public void Find <TElement, TResult>(
            TBaseSearchInterface source,
            LinkedList <TResult> resultList,
            SearchStrategy <TElement, TResult> strategy,
            HashSet <object> visited,
            Func <TElement, TResult> action) where TElement : class, TBaseSearchInterface
        {
            var deleg = GetOrCreateDelegate(source, strategy);

            deleg.Invoke(source, resultList, visited, action);
        }
示例#13
0
        public void BasicPrettyPrint(int?OverrideRecursionLevel = null)
        {
            int localRecursionLevel = RecursionLevel;

            if (OverrideRecursionLevel != null)
            {
                localRecursionLevel = (int)OverrideRecursionLevel;
            }

            string Tabs = string.Concat(Enumerable.Repeat("|  ", localRecursionLevel));

            Console.WriteLine("{0:s}├ {1:s} ({2:s}) : {3:s} ", Tabs, ModuleName, SearchStrategy.ToString(), Filepath);
        }
示例#14
0
 public IEnumerable <Mural> GetAllMuralsWithSearchStrategy(string searchParameter, string search)
 {
     if (search == "id")
     {
         int searchId = Int32.Parse(searchParameter);
         searchStrategy = new IDStrategy();
         return(searchStrategy.SearchMuralsWithID(searchId));
     }
     else
     {
         searchStrategy = new NameStrategy();
         return(searchStrategy.SearchMuralsWithName(searchParameter));
     }
 }
示例#15
0
        public void PrettyPrint()
        {
            string Tabs = string.Concat(Enumerable.Repeat("|  ", RecursionLevel));

            Console.WriteLine("{0:s}├ {1:s} ({2:s}) : {3:s} ", Tabs, ModuleName, SearchStrategy.ToString(), Filepath);

            foreach (var Dep in Dependencies)
            {
                if (Root.VisitModule(Dep.ModuleName, Dep.Filepath))
                {
                    Dep.PrettyPrint();
                }
            }
        }
示例#16
0
        public async Task<IHttpActionResult> Search(
            double lat, double lon, string address, double? radius,
            int limit = AppConstants.DefaultAssetSearchLimit, SearchStrategy strategy = SearchStrategy.QUICK)
        {
            var request = new AssetSearchRequest()
            {
                Location = new DefaultAddress(address, new Data.Model.GeoJson.Point(new double[] { lon, lat }.ToList())),
                Limit = limit,
                Radius = radius,
                Strategy = strategy
            };

            var result = await provider.FindEligibleAssets(request);
            return Ok(result);
        }
示例#17
0
 public void SetSearchStrategy(SearchStrategy strategy)
 {
     if (strategy.Equals(SearchStrategy.TITLE))
     {
         this.strategy = new TitleSearch();
     }
     else if (strategy.Equals(SearchStrategy.AUTHOR))
     {
         this.strategy = new AuthorSearch();
     }
     else
     {
         this.strategy = new IsbnSearch();
     }
 }
示例#18
0
        public async Task <IHttpActionResult> Search(
            double lat, double lon, string address, double?radius,
            int limit = AppConstants.DefaultAssetSearchLimit, SearchStrategy strategy = SearchStrategy.QUICK)
        {
            var request = new AssetSearchRequest()
            {
                Location = new DefaultAddress(address, new Data.Model.GeoJson.Point(new double[] { lon, lat }.ToList())),
                Limit    = limit,
                Radius   = radius,
                Strategy = strategy
            };

            var result = await provider.FindEligibleAssets(request);

            return(Ok(result));
        }
示例#19
0
        public static void Main(string[] args)
        {
            string input;
            Dictionary <uint, Dictionary <uint, Datum> > dataByFeatureAndId;

            do
            {
                Console.WriteLine("Enter the file name (e.g. 'small_data.txt')");
                input = Console.ReadLine();
            }while (!DataBuilder.BuildData(input, out dataByFeatureAndId));

            SearchStrategy searchStrategy = null;

            do
            {
                Console.WriteLine("Select an algorithm:");

                input = Console.ReadLine();

                if (!ushort.TryParse(input, out ushort value))
                {
                    continue;
                }

                switch (value)
                {
                case 1:
                {
                    searchStrategy = ForwardSearchStrategy.Instance;

                    break;
                }

                case 2:
                {
                    searchStrategy = BackwardSearchStrategy.Instance;

                    break;
                }
                }
            }while (searchStrategy == null);

            searchStrategy.Search(dataByFeatureAndId);
        }
示例#20
0
        public T FindComponent <T>(SearchStrategy strategy = SearchStrategy.InChildren)
        {
            var query = new Query
            {
                Type     = typeof(T),
                Strategy = strategy
            };

            if (this.cache.TryGetValue(query, out var result))
            {
                return((T)result);
            }

            var component = query.Execute <T>(this.gameObject);

            this.cache[query] = component;

            return(component);
        }
示例#21
0
        static void Solve(Node Initial)
        {
            SearchStrategy Strat = null;

            Console.WriteLine("Which strategy would you like to use?");
            Console.WriteLine("1) Depth First Search");
            Console.WriteLine("2) Breadth First Search");
            Console.WriteLine("3) Minimize time per day heuristic");
            Console.WriteLine("4) Minimize tasks per day heuristic");
            Console.WriteLine("5) Simulated Annealing");
            int X;

            int.TryParse(Console.ReadLine(), out X);
            switch (X)
            {
            case 1:
                Strat = new DepthFirstSearch();
                break;

            case 2:
                Strat = new BreadthFirstSearch();
                break;

            case 3:
                Strat = new AStarSearch(new LowTimePerDayHeuristic());
                break;

            case 4:
                Strat = new AStarSearch(new LowTaskPerDayHeuristic());
                break;

            case 5:
                SimulatedAnnealer SA = new SimulatedAnnealer(Initial);
                Console.WriteLine(SA.Anneal());
                return;

            default:
                Console.WriteLine("I don't understand, exiting!");
                return;
            }
            Console.WriteLine(Strat.Solve(Initial));
        }
示例#22
0
        private Stack <Action> TreeSearch(Problem p, SearchStrategy strategy)
        {
            /*
             * Arbre de recherche permet de savoir quoi faire
             *
             */
            Stack <Action> actionList = new Stack <Action>();
            Node           endNode    = strategy.SearchPath(p);

            while (endNode != null)
            {
                if (endNode.action != null)
                {
                    actionList.Push(endNode.action);
                }
                endNode = endNode.parentNode;
            }
            actionList.Reverse();
            return(actionList);
        }
示例#23
0
        public void PrettyPrint()
        {
            string Tabs = string.Concat(Enumerable.Repeat("|  ", RecursionLevel));

            Console.WriteLine("{0:s}├ {1:s} ({2:s}) : {3:s} ", Tabs, ModuleName, SearchStrategy.ToString(), Filepath);

            foreach (var Dep in ResolvedImports)
            {
                bool NeverSeenModule = Root.VisitModule(Dep.ModuleName, Dep.Filepath);

                if (NeverSeenModule)
                {
                    Dep.PrettyPrint();
                }
                else
                {
                    Dep.BasicPrettyPrint();
                }
            }
        }
示例#24
0
        public ResultDelegate <TSearch, TResult> CreateResultDelegate(LinkedList <CompositPropertyVertex> vertices,
                                                                      SearchStrategy <TSearch, TResult> strategy)
        {
            var delegateMap = new Dictionary <CompositPropertyVertex, ProxyDelegate <TSearch, TResult> >();

            var delegates = new ProxyDelegate <TSearch, TResult> [vertices.Count];

            var index = 0;

            vertices.ForEach(
                node =>
            {
                CreateDelegate(node.Value, delegateMap, strategy);
                delegates[index++] = delegateMap[node.Value];
            });

            var rootDelegate = new RootProxyDelegate <TSearch, TResult>(delegates, strategy);

            rootDelegate.BuildExecuteChildrenDelegate();

            return(rootDelegate.Execute);
        }
示例#25
0
        public State findPath()
        {
            State result;

            switch (Searcher)
            {
            case Constant.ASTAR:
                searchStrategy = new AStar();
                result         = searchStrategy.findPath(this.start, this.end, this);
                break;

            case Constant.DFS:
                searchStrategy = new DFS();
                result         = searchStrategy.findPath(this.start, this.end, this);
                break;

            case Constant.BFS:
                searchStrategy = new BFS();
                result         = searchStrategy.findPath(this.start, this.end, this);
                break;

            //case Constant.BIDIRECTIONALASTAR:
            //    searchStrategy = new BiDirectionalAStar();
            //    result = searchStrategy.findPath(this.start, this.end, this);
            //    break;
            case Constant.DIJKSTRA:
                searchStrategy = new Dijkstra();
                result         = searchStrategy.findPath(this.start, this.end, this);
                break;

            default:
                searchStrategy = new AStar();
                result         = searchStrategy.findPath(this.start, this.end, this);
                break;
            }

            return(result);
        }
示例#26
0
        private static void CreateDelegate(CompositPropertyVertex vertex,
                                           Dictionary <CompositPropertyVertex, ProxyDelegate <TSearch, TResult> > delegateMap,
                                           SearchStrategy <TSearch, TResult> strategy)
        {
            if (vertex.PropertyList.First == null)
            {
                throw new NullReferenceException();
            }

            if (delegateMap.ContainsKey(vertex))
            {
                return;
            }

            var propertyGetters = new Func <object, object> [vertex.PropertyList.Count];

            var parameter = Expression.Parameter(typeof(object), "obj");
            var nullConst = Expression.Constant(null);

            var hasCollection = false;

            var index = 0;

            vertex.PropertyList.ForEach(
                node =>
            {
                if (typeof(ICollection).IsAssignableFrom(node.Value.PropertyType))
                {
                    hasCollection = true;
                }

                var resultVariable = Expression.Variable(typeof(object), "result");

                var castVariable = Expression.Variable(node.Value.DeclaringType, "value");
                var castAs       = Expression.TypeAs(parameter, node.Value.DeclaringType);
                var castAssign   = Expression.Assign(castVariable, castAs);

                var checkNotNull = Expression.NotEqual(castVariable, nullConst);
                var memberAccess = Expression.Convert(Expression.MakeMemberAccess(castVariable, node.Value),
                                                      typeof(object));
                var conditionalMemberAccess = Expression.Condition(checkNotNull, memberAccess, nullConst);

                var resultAssign = Expression.Assign(resultVariable, conditionalMemberAccess);

                var returnTarget = Expression.Label(typeof(object));
                var returnLabel  = Expression.Label(returnTarget, nullConst);
                var returnExpr   = Expression.Return(returnTarget, resultVariable);

                var block = Expression.Block(typeof(object), new[] { castVariable, resultVariable }, castAssign,
                                             resultAssign, returnExpr, returnLabel);

                var deleg = Expression.Lambda <Func <object, object> >(block, parameter).Compile();

                propertyGetters[index++] = deleg;
            });

            var childDelegates = new ProxyDelegate <TSearch, TResult> [vertex.Children.Count];

            delegateMap[vertex] = new ProxyDelegate <TSearch, TResult>(propertyGetters, childDelegates, strategy,
                                                                       hasCollection);

            index = 0;
            vertex.Children.ForEach(
                node =>
            {
                CreateDelegate(node.Value, delegateMap, strategy);
                childDelegates[index++] = delegateMap[node.Value];
            });
        }
 public abstract void Apply(MonoBehaviour behaviour, object obj, FieldInfo field, SearchStrategy searchStrategy);
示例#28
0
        public void BasicPrettyPrint()
        {
            string Tabs = string.Concat(Enumerable.Repeat("|  ", RecursionLevel));

            Console.WriteLine("{0:s}├ {1:s} ({2:s}) : {3:s} ", Tabs, ModuleName, SearchStrategy.ToString(), Filepath);
        }
示例#29
0
 protected AbstractProvider(string someConfigurationFilePath, SearchStrategy someSearchStrategy)
 {
     setConfiguration(someConfigurationFilePath);
     setSearchStrategy(someSearchStrategy ?? getDefaultStrategy());
 }
示例#30
0
 public void SetSearchStrategy(SearchStrategy strategy)
 {
     this.searchStrategy = strategy;
 }
 public void SetSearchStrategy(SearchStrategy searchStrategy)
 {
     _searchStrategy = searchStrategy;
     if (SearchStrategyChanged != null)
     {
         SearchStrategyChanged(this, new EventArgs<SearchStrategy> { Data = searchStrategy });
     }
 }
示例#32
0
 public void setSearchStrategy(SearchStrategy newStrategy)
 {
     if (newStrategy != null) {
         searchStrategy = newStrategy;
     }
 }
示例#33
0
 private void FindComponentsCustom(SearchStrategy strategy)
 {
     ComponentFinderAttribute.ApplyAttribute <ComponentFinderAttribute>(this, strategy);
 }
示例#34
0
 protected BaseProxyDelegate(ProxyDelegate <TSearch, TResult>[] children,
                             SearchStrategy <TSearch, TResult> strategy)
 {
     Children  = children;
     _strategy = strategy;
 }