public override void Evaluate(Solution solution) { var s = (IntergenSolution)solution; var doubleVal = new double[Model.Setting.NumberOfFeatures]; var interacVal = new double[Model.Setting.NumberOfInteractions]; var values = new XReal(solution); for (var i = 0; i < Model.Setting.NumberOfFeatures; i++) { doubleVal[i] = values.GetValue(i); } for (var i = 0; i < Model.Setting.NumberOfInteractions; i++) { interacVal[i] = values.GetValue(i + Model.Setting.NumberOfFeatures); } //the distribution from the NSGA2 var nsgaFv = new Distribution(doubleVal); var interacDist = new Distribution(interacVal); var variantValuesWithoutInteraction = FeatureMatrix.Dot(doubleVal); var interacVals = InteractionMatrix.Dot(interacVal); var variantResults = variantValuesWithoutInteraction.Add(interacVals); var variantResult = new Distribution(variantResults); var fc = new FitnessCalculator(Model, s.FoundAtEval); var fitnessValues = fc.Calculate(null, null, null, null, interacDist, InteractionTarget); solution.Objective[0] = fitnessValues.InteracVal; FitnessTracker.AddInterac(s.FoundAtEval, fitnessValues.InteracVal); }
/// <summary> /// One of the most fundamental types of groups is the triads /// Rapid formation and reformation of triads is one key aspect of flexibility /// For flexibility, Triads numbers are normalized with maximum potential triads /// </summary> public void HandleTriads(ushort agentsCount) { var numberOfTriads = InteractionMatrix.NumberOfTriads(Environment.MainOrganization.ArtifactNetwork.InteractionSphere.Sphere); var maxTriads = InteractionMatrix.MaxTriads(agentsCount); var triads = new DensityStruct(numberOfTriads, maxTriads, Environment.Schedule.Step); Triads.Add(triads); }
public override void Evaluate(Solution solution) { var s = (IntergenSolution)solution; var doubleVal = new double[Model.Setting.NumberOfFeatures]; var interacVal = new double[Model.Setting.NumberOfInteractions]; var values = new XReal(solution); for (var i = 0; i < Model.Setting.NumberOfFeatures; i++) { doubleVal[i] = values.GetValue(i); } for (var i = 0; i < Model.Setting.NumberOfInteractions; i++) { interacVal[i] = values.GetValue(i + Model.Setting.NumberOfFeatures); } //the distribution from the NSGA2 var nsgaFv = new Distribution(doubleVal); var interacDist = new Distribution(interacVal); var multiplicationTime = new Stopwatch(); multiplicationTime.Start(); var variantValuesWithoutInteraction = FeatureMatrix.Dot(doubleVal); var interacVals = InteractionMatrix.Dot(interacVal); var variantResults = variantValuesWithoutInteraction.Add(interacVals); multiplicationTime.Stop(); FitnessTracker.AddMultiplicationTime(multiplicationTime.ElapsedMilliseconds); var variantResult = new Distribution(variantResults); var localScaledVariants = new double[VariantTarget.Values.Length]; Array.Copy(VariantTarget.Values, localScaledVariants, VariantTarget.Values.Length); var localVariantTarget = new Distribution(localScaledVariants); localVariantTarget = FMScaling.InteractionToScale(localVariantTarget, variantResults.Min(), variantResults.Max()); var fc = new FitnessCalculator(Model, s.FoundAtEval); var fitnessValues = fc.Calculate(variantResult, localVariantTarget, nsgaFv, FeatureTarget, interacDist, InteractionTarget); solution.Objective[0] = fitnessValues.FeatureVal; solution.Objective[1] = fitnessValues.InteracVal; solution.Objective[2] = fitnessValues.VariantVal; FitnessTracker.AddCalcTime(fc.GetFitnessTime()); FitnessTracker.Add(s.FoundAtEval, fitnessValues.FeatureVal, fitnessValues.InteracVal, fitnessValues.VariantVal); }