Esempio n. 1
0
        public static void Initialize(string instance)
        {
            var defaultBehaviorWeights = new Dictionary <string, float>
            {
                { BehaviorTypes.View, .5f },
                { BehaviorTypes.AddToCart, .7f },
                { BehaviorTypes.Purchase, 1f }
            };

            foreach (var behaviorType in BehaviorTypes.All())
            {
                BehaviorStores.Register(instance, behaviorType, new SqlceBehaviorStore(instance, behaviorType));

                float weight = defaultBehaviorWeights[behaviorType];
                var   config = BehaviorConfig.Load(instance, behaviorType);
                if (config != null)
                {
                    weight = config.Weight;
                }

                var matrix = new SqlceSimilarityMatrix(instance, behaviorType, "Similarity_" + behaviorType);
                SimilarityMatrixes.Register(instance, behaviorType, matrix);
                RelatedItemsProviders.Register(instance, new ItemToItemRelatedItemsProvider(matrix), weight);
            }

            BehaviorReceivers.Set(instance, new BufferedBehaviorReceiver(new BehaviorReceiver(instance), 1000, TimeSpan.FromSeconds(5)));
            RecommendationEngines.Register(instance, CreateRecommendationEngines(instance));

            Schedulers.Start(instance);
            ScheduleJobs(instance);
        }