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); }
public static void Dispose(string instance) { RecommendationEngines.RemoveEngines(instance); Schedulers.Stop(instance); BehaviorReceivers.Remove(instance); BehaviorStores.Remove(instance); SimilarityMatrixes.Remove(instance); RelatedItemsProviders.RemoveProviders(instance); }
public void Execute(JobContext context) { var instance = context.Instance; var behaviorType = context.JobData["BehaviorType"]; var matrix = SimilarityMatrixes.Get(instance, behaviorType); var newMatrix = matrix.PrepareRecomputation(); Recompute(newMatrix, BehaviorStores.Get(instance, behaviorType)); matrix.ReplaceWith(newMatrix); }