Exemplo n.º 1
0
        private void InvalidateLoops(ACO.DecisionComponent <ConnectionDC> input, ACO.Solution <ConnectionDC> solution, ACO.ConstructionGraph <ConnectionDC> graph)
        {
            int dependencies = 0;

            int switchIndex  = (InputUnitCount * HiddenUnitCount) + (InputUnitCount * OutputUnitCount) + (HiddenUnitCount * OutputUnitCount);
            int switchIndex2 = (InputUnitCount * HiddenUnitCount * 2) + (InputUnitCount * OutputUnitCount * 2) + (HiddenUnitCount * OutputUnitCount * 2);

            for (int index = switchIndex; index < solution.Components.Count; index++)
            {
                DecisionComponent <ConnectionDC> component = solution.Components[index];
                if (input.Element.Connection.To == component.Element.Connection.To)
                {
                    dependencies++;
                }
            }

            List <int> descendantIndexes = this.GetDescendantIndexes(input.Element, solution);
            List <int> ancestorIndexes   = this.GetAncestorIndexes(input.Element, solution);

            List <DecisionComponent <ConnectionDC> > validComponents = graph.GetValidComponents(switchIndex2, graph.Components.Length - switchIndex2);

            foreach (DecisionComponent <ConnectionDC> component in validComponents)
            {
                if (component.Element.Connection.To == input.Element.Connection.To && component.Element.Connection.From == input.Element.Connection.From)
                {
                    component.IsValid = false;
                    continue;
                }

                if (component.Element.Connection.To == input.Element.Connection.To)
                {
                    if (dependencies == MaxParents)
                    {
                        component.IsValid = false;
                        continue;
                    }
                }


                if (descendantIndexes.Contains(component.Element.Connection.From))
                {
                    if (ancestorIndexes.Contains(component.Element.Connection.To))
                    {
                        component.IsValid = false;
                        continue;
                    }
                }

                if (ancestorIndexes.Contains(component.Element.Connection.To))
                {
                    if (descendantIndexes.Contains(component.Element.Connection.From))
                    {
                        component.IsValid = false;
                        continue;
                    }
                }
            }
        }
Exemplo n.º 2
0
        public void Invalidate(ACO.DecisionComponent <Edge> input, Solution <Edge> solution, ACO.ConstructionGraph <Edge> graph)
        {
            int dependencies = 0;

            foreach (DecisionComponent <Edge> solutionElement in solution.Components)
            {
                if (input.Element.ChildIndex == solutionElement.Element.ChildIndex)
                {
                    dependencies++;
                }
            }

            List <int> descendantIndexes = this.GetDescendantIndexes(input.Element, solution);
            List <int> ancestorIndexes   = this.GetAncestorIndexes(input.Element, solution);



            foreach (DecisionComponent <Edge> component in graph.GetValidComponents())
            {
                if (component.Element.ChildIndex == input.Element.ChildIndex && component.Element.ParentIndex == input.Element.ParentIndex)
                {
                    component.IsValid = false;
                }

                if (component.Element.ChildIndex == input.Element.ChildIndex)
                {
                    if (dependencies == this._maxDependencies)
                    {
                        component.IsValid = false;
                    }
                }

                if (descendantIndexes.Contains(component.Element.ParentIndex))
                {
                    if (ancestorIndexes.Contains(component.Element.ChildIndex))
                    {
                        component.IsValid = false;
                    }
                }

                if (ancestorIndexes.Contains(component.Element.ChildIndex))
                {
                    if (descendantIndexes.Contains(component.Element.ParentIndex))
                    {
                        component.IsValid = false;
                    }
                }
            }
        }