public void Invalidate(ACO.DecisionComponent <DRComponent> component, ACO.Solution <DRComponent> solution, ACO.ConstructionGraph <DRComponent> graph) { int index = component.Index; if (component.Element.Include) { index += 2; } else { index += 1; } for (int i = index - 2; i < index; i++) { graph.Components[i].IsValid = false; } if (index < graph.Components.Length) { for (int i = index; i < index + 2; i++) { graph.Components[i].IsValid = true; } } }
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; } } } }
public override void EvaluateSolutionQuality(ACO.Solution <double> solution) { double value = this._function.Calculate(solution.ToList().ToArray()); if (_function.Type == OptimizationType.Maximization) { solution.Quality = value; } else { solution.Quality = 1.0 / (1 + value); } this.CurrentFitness = value; }
public override void EvaluateSolutionQuality(ACO.Solution <double> solution) { if (solution.Components.Count != this._problemSize) { return; } this._problem.SolutionQualityEvaluator.EvaluateSolutionQuality(solution); this.EvaluationCounter++; double fitness = ((OptimizationFunctionQualityEvaluator)this._problem.SolutionQualityEvaluator).Function.Calculate(solution.ToList().ToArray()); this.CheckTerminationCondition(fitness); }
public override void EvaluateSolutionQuality(ACO.Solution <double> solution) { if (solution.Components.Count != this._problemSize) { return; } AbstractContinousOptimizationEvaluator evaluator = this._problem.SolutionQualityEvaluator as AbstractContinousOptimizationEvaluator; evaluator.EvaluateSolutionQuality(solution); this.EvaluationCounter++; double fitness = evaluator.CurrentFitness; if (this._bestFitness > fitness) { this._bestFitness = fitness; } }
public void Invalidate(ACO.DecisionComponent <ConnectionDC> component, ACO.Solution <ConnectionDC> solution, ACO.ConstructionGraph <ConnectionDC> graph) { int switchIndex = (InputUnitCount * HiddenUnitCount * 2) + (InputUnitCount * OutputUnitCount * 2) + (HiddenUnitCount * OutputUnitCount * 2); if (SecondPhase) { this.InvalidateLoops(component, solution, graph); } else { int index = component.Index; if (component.Element.Include) { index += 2; } else { index += 1; } for (int i = index - 2; i < index; i++) { graph.Components[i].IsValid = false; } if (index >= switchIndex) { this.SecondPhase = true; for (int i = index; i < graph.Components.Length; i++) { graph.Components[i].IsValid = true; } } else { for (int i = index; i < index + 2; i++) { graph.Components[i].IsValid = true; } } } }
public void Invalidate(ACO.DecisionComponent <VariableTypeAssignment> component, ACO.Solution <VariableTypeAssignment> solution, ACO.ConstructionGraph <VariableTypeAssignment> graph) { int index = component.Element.VariableIndex; int elementIndex = (index + 1) * 3; for (int i = elementIndex - 3; i < elementIndex; i++) { graph.Components[i].IsValid = false; } if (elementIndex < graph.Components.Length) { for (int i = elementIndex; i < elementIndex + 3; i++) { graph.Components[i].IsValid = true; } } }
public abstract void EvaluateSolutionQuality(ACO.Solution <double> solution);
public void Invalidate(ACO.DecisionComponent <ClusterExampleAssignment> component, ACO.Solution <ClusterExampleAssignment> solution, ACO.ConstructionGraph <ClusterExampleAssignment> graph) { int index = component.Element.ExampleID; int elementIndex = (index + 1) * this._clustersNumber; for (int i = elementIndex - this._clustersNumber; i < elementIndex; i++) { graph.Components[i].IsValid = false; } if (elementIndex < graph.Components.Length) { for (int i = elementIndex; i < elementIndex + this._clustersNumber; i++) { graph.Components[i].IsValid = true; } } }