コード例 #1
0
        public spiderModuleData <TElement> CreateNext()
        {
            spiderModuleData <TElement> output = new spiderModuleData <TElement>();

            output.active.AddRange(active);

            output.iteration = iteration;

            return(output);
        }
コード例 #2
0
        public spiderModuleData <TElement> Clone()
        {
            spiderModuleData <TElement> output = new spiderModuleData <TElement>();

            output.active.AddRange(active);

            output.inactive.AddRange(inactive);

            output.isModuleGaveUp = isModuleGaveUp;

            output.lastModifiedBy = lastModifiedBy;

            output.solution = solution;

            output.iteration = iteration;

            return(output);
        }
コード例 #3
0
        /// <summary>
        /// Evaluates the specified input with links
        /// </summary>
        /// <param name="input">The input.</param>
        /// <returns></returns>
        public spiderModuleData <spiderLink> evaluate(spiderModuleData <spiderLink> input, modelSpiderSiteRecord wRecord)
        {
            // wRecord.lastInput = input.Clone();

            //  moduleDLCRecord moduleLevelReportTable = wRecord.frontierDLC[this.name];

            //     moduleIterationRecord moduleDLCRecordTableEntry = null;

            moduleIterationRecord moduleDLCRecordTableEntry = input.moduleDLCRecordTableEntry;

            if (imbWEMManager.settings.directReportEngine.DR_ReportModules)
            {
                moduleDLCRecordTableEntry.reportEvaluateStart(input, wRecord, this);
            }

            wRecord.logBuilder.Append(input.GetInlineDescription("Input (" + name + ") "));

            spiderModuleData <spiderLink> output = new spiderModuleData <spiderLink>();

            output.inactive.AddRange(input.inactive);

            List <spiderLink> rest = new List <spiderLink>();

            // < --- starting iteration for the layer rules
            foreach (layerDistributionActiveRuleBase aRule in layerActiveRules)
            {
                aRule.startIteration(wRecord.iteration, wRecord);
            }


            // << ---- learning about the links
            foreach (spiderLink link in input.active)
            {
                foreach (layerDistributionActiveRuleBase activeRule in layerActiveRules)
                {
                    activeRule.learn(link);
                }
            }

            // <<----- evaluation of the links
            foreach (spiderLink link in input.active)
            {
                bool                      assigned   = false;
                layerCollection           assignedTo = null;
                layerDistributionRuleBase layerRule  = null;
                foreach (layerDistributionPassiveRuleBase passiveRule in layerPassiveRules)
                {
                    spiderEvalRuleResult lres = link.marks[passiveRule];
                    if (lres == null)
                    {
                        lres = passiveRule.evaluate(link);
                        link.marks.deploy(lres);
                    }

                    if (lres.layer > -1)
                    {
                        assignedTo = layers[lres.layer];
                        assigned   = true;
                        layers[lres.layer].Push <spiderLink>(link);
                        layerRule = passiveRule;
                        break;
                    }
                }
                if (!assigned)
                {
                    foreach (layerDistributionActiveRuleBase activeRule in layerActiveRules)
                    {
                        spiderEvalRuleResult lres = activeRule.evaluate(link);
                        link.marks.deploy(lres);

                        if (lres.layer > -1)
                        {
                            assignedTo = layers[lres.layer];
                            assigned   = true;
                            layers[lres.layer].Push <spiderLink>(link);
                            layerRule = activeRule;
                            break;
                        }
                    }
                }

                if (!assigned)
                {
                    rest.Add(link);
                }
                else
                {
                    wRecord.logBuilder.AppendLine("Link [" + link.url + "] => " + assignedTo.name + "(" + assignedTo.Count + ") [" + layerRule.tagName + "]");
                }
            }

            switch (restPolicy)
            {
            case spiderLayerModuleEvaluationRestPolicy.assignToTheInactive:
                output.inactive.AddRange(rest);
                break;

            case spiderLayerModuleEvaluationRestPolicy.assignToTheDeepestLayer:
                output.inactive.AddRange(layers.Deepest.Push <spiderLink>(rest));
                break;
            }


            //  wRecord.logBuilder.Append(layers.GetInlineDescription());



            List <spiderLink> result = layers.Pull <spiderLink>(pullLimit, doTakeFromLower);

            if (imbWEMManager.settings.directReportEngine.DR_ReportModules)
            {
                moduleDLCRecordTableEntry.reportEvaluateEnd(result, wRecord, this);
                //  input.moduleDLC.reportEvaluateEnd(result, wRecord, moduleDLCRecordTableEntry, this);
            }

            wRecord.logBuilder.AppendLine("Module output => layers[" + layers.layer_id + "].Pull(" + pullLimit + ", " + doTakeFromLower + ") => " + result.Count);

            // <<----- ranking
            result = rankLinks(result, wRecord.iteration);

            if (imbWEMManager.settings.directReportEngine.DR_ReportModules)
            {
                moduleDLCRecordTableEntry.reportEvaluateAlterRanking(result, wRecord, this);
                //moduleLevelReportTable.reportEvaluateAlterRanking(result, wRecord, moduleDLCRecordTableEntry, this); // ------ module level report -- after ranking
                // moduleLevelReportTable.AddOrUpdate(moduleDLCRecordTableEntry);
            }

            if (result.Any())
            {
                output.active.AddRange(result);
                output.isModuleGaveUp = false;
            }
            else
            {
                output.active.AddRange(input.active);
                output.isModuleGaveUp = true;
            }

            wRecord.logBuilder.Append(output.GetInlineDescription("Output"));



            return(output);
        }