public MultiObjectiveListEvaluator(IGenomeDecoder <TGenome, TPhenome> genomeDecoder, IMultiObjectiveEvaluator <TPhenome> phenomeEvaluator, INoveltyScorer <TGenome> noveltyScorer, IGeneticDiversityScorer <TGenome> geneticDiversityScorer, IMultiObjectiveScorer multiObjectiveScorer, bool enableMultiThreading, ParallelOptions options) { _genomeDecoder = genomeDecoder; _phenomeEvaluator = phenomeEvaluator; _noveltyScorer = noveltyScorer; _geneticDiversityScorer = geneticDiversityScorer; _multiObjectiveScorer = multiObjectiveScorer; _parallelOptions = options; _generation = 0; // Determine the appropriate evaluation method. if (enableMultiThreading) { _evalMethod = EvaluateParallel; } else { _evalMethod = EvaluateSerial; } }
/// <summary> /// Resets the object's properties. /// </summary> void Reset() { // Set the default values. UpdateRenderingObjectsList(); launchOrderIndex = renderingObjectCount; readyToBeLaunched = false; _launchOnAwake = true; _launched = false; _previewRenderTexture = null; _previewEvalTexture = null; // Get the processing component. If this was not called on AddComponent, reset it as well. _processing = GeneralToolkit.GetOrAddComponent <Processing.Processing>(gameObject); if (_processing.renderingCaller != null) { _processing.Reset(); } else { _processing.renderingCaller = this; } // Initialize the rendering methods and helpers. This has to be done after the processing component has been reset. _renderingMethods = RenderingMethod.CreateOrResetRenderingMethods(transform); Method[] methods = GetComponentsInChildren <Method>(); for (int iter = 0; iter < methods.Length; iter++) { methods[iter].InitializeLinks(); } // Initialize the evaluation methods. _evaluationMethods = EvaluationMethod.GetOrCreateEvaluationMethods(transform); #if UNITY_EDITOR UnityEditorInternal.InternalEditorUtility.SetIsInspectorExpanded(processing, false); #endif //UNITY_EDITOR }
private IndividualsGroup UNDX_MGG(IndividualsGroup parents, EvaluationMethod evaluationMethod) { UNDX_Parameters UNDXConfiguration = new UNDX_Parameters() { Alpha = 0.5, Beta = 0.35, NumberOfCrossovers = 10, NumberOfParameters = parents.IndivisualsGroup[0].OptParameters.Length }; UNDX undxExecutor = new UNDX(UNDXConfiguration); MGG mggExecutor = new MGG(); // Execute Crossove with UNDX var parameters = undxExecutor.ExecuteCrossover(parents); var parentsIndex = undxExecutor.ParentsIndex; // Calculate Characteristics var fitnesses = evaluationMethod(parameters); // Create Individuals var offsprings = CreateIndividuals(parameters, fitnesses); // Create New Individuals var newIndividuals = mggExecutor.ExecuteSelection(offsprings); // Return new population return(UpdatePopulation(parents, (int[])parentsIndex, newIndividuals)); }
public IList <IChromosome <T> > Solve <T>(IList <IChromosome <T> > population) { if (population.Count == 0) { return(population); } var currentPopulation = population.Clone(); do { var newPopulation = new List <IChromosome <T> >(); while (newPopulation.Count < _parameters.PopulationSize) { var selected = SelectionMethod.Selection(currentPopulation); var chromozome = CrossoverAlgorithm.RunCrossover(selected.Item1, selected.Item2, _parameters.CrossOverProbability); chromozome = MutationAlgorithm.RunMutation(chromozome, _parameters.MutationProbability); chromozome.FintnessValue = EvaluationMethod.Evaluate(chromozome); newPopulation.Add(chromozome); } currentPopulation = newPopulation; } while (!Convirged()); return(currentPopulation); }
public MultiObjectiveListEvaluator(IGenomeDecoder <TGenome, TPhenome> genomeDecoder, IMultiObjectiveEvaluator <TPhenome> phenomeEvaluator, INoveltyScorer <TGenome> noveltyScorer, IList <IObjectiveScorer <TGenome> > objectiveScorers, IMultiObjectiveScorer multiObjectiveScorer, bool enableMultiThreading, ParallelOptions options) { _genomeDecoder = genomeDecoder; _phenomeEvaluator = phenomeEvaluator; _noveltyScorer = noveltyScorer; _objectiveScorers = objectiveScorers; for (int i = 0; i < _objectiveScorers.Count; i++) { _objectiveScorers[i].Objective = i + 1; } _multiObjectiveScorer = multiObjectiveScorer; _parallelOptions = options; _generation = 0; // Determine the appropriate evaluation method. if (enableMultiThreading) { _evalMethod = EvaluateParallel; } else { _evalMethod = EvaluateSerial; } }
/// <summary> /// Construct with the provided IGenomeDecoder and IPhenomeEvaluator. /// Phenome caching is enabled by default. /// </summary> public SerialGenomeListEvaluator(IGenomeDecoder <TGenome, TPhenome> genomeDecoder, IPhenomeEvaluator <TPhenome> phenomeEvaluator) { _genomeDecoder = genomeDecoder; _phenomeEvaluator = phenomeEvaluator; _enablePhenomeCaching = true; _evaluationMethod = Evaluate_Caching; }
// Token: 0x060005E1 RID: 1505 RVA: 0x00023368 File Offset: 0x00021568 public async Task OnNotificationAsync(Notification notification) { if (this.subscription != null && !(((notification != null) ? notification.SubscriptionId.UniqueName : null) != RollupModeChangedSubscriber.SubscriptionUniqueName)) { if (notification.SourceInstanceProperties == null) { RollupModeChangedSubscriber.log.Error("Argument SourceInstanceProperties is null."); } else if (!notification.SourceInstanceProperties.ContainsKey("Core.StatusRollupMode")) { RollupModeChangedSubscriber.log.Error("Core.StatusRollupMode not supplied in SourceInstanceProperties."); } else { try { string text = (string)notification.SourceInstanceProperties["Core.StatusRollupMode"]; EvaluationMethod evaluationMethod = (text != null) ? Convert.ToInt32(text) : 0; int nodeId = Convert.ToInt32(notification.SourceInstanceProperties["NodeId"]); RollupModeChangedSubscriber.log.DebugFormat("Node with id '{0}' rollup mode changed to '{1}', re-calculating node status ..", nodeId, evaluationMethod); await Task.Run(delegate() { this.RecalculateNodeStatus(nodeId); }); } catch (Exception ex) { RollupModeChangedSubscriber.log.Error("Indication handling failed", ex); } } } }
public void AddResult(T position) { var eval = EvaluationMethod.Evaluate(position); //Log.Post(runner.Name + " achieved: " + Math.Round(eval, 5)); if (eval > BestScore) { BestResult = position; BestScore = eval; } }
public async Task OnNotificationAsync(Notification notification) { RollupModeChangedSubscriber changedSubscriber1 = this; if (changedSubscriber1.subscription == null) { return; } Notification notification1 = notification; string str; if (notification1 == null) { str = (string)null; } else { SubscriptionId subscriptionId = notification1.get_SubscriptionId(); str = ((SubscriptionId) ref subscriptionId).get_UniqueName(); } string subscriptionUniqueName = RollupModeChangedSubscriber.SubscriptionUniqueName; if (str != subscriptionUniqueName) { return; } if (notification.get_SourceInstanceProperties() == null) { RollupModeChangedSubscriber.log.Error((object)"Argument SourceInstanceProperties is null."); } else if (!notification.get_SourceInstanceProperties().ContainsKey("Core.StatusRollupMode")) { RollupModeChangedSubscriber.log.Error((object)"Core.StatusRollupMode not supplied in SourceInstanceProperties."); } else { try { RollupModeChangedSubscriber changedSubscriber = changedSubscriber1; string instanceProperty = (string)notification.get_SourceInstanceProperties()["Core.StatusRollupMode"]; EvaluationMethod evaluationMethod = instanceProperty != null ? (EvaluationMethod)Convert.ToInt32(instanceProperty) : (EvaluationMethod)0; int nodeId = Convert.ToInt32(notification.get_SourceInstanceProperties()["NodeId"]); RollupModeChangedSubscriber.log.DebugFormat("Node with id '{0}' rollup mode changed to '{1}', re-calculating node status ..", (object)nodeId, (object)evaluationMethod); await Task.Run((Action)(() => changedSubscriber.RecalculateNodeStatus(nodeId))); } catch (Exception ex) { RollupModeChangedSubscriber.log.Error((object)"Indication handling failed", ex); } } }
/// <summary> /// Construct with the provided IGenomeDecoder, IPhenomeEvaluator and enablePhenomeCaching flag. /// </summary> public SerialGenomeListEvaluator(IGenomeDecoder <TGenome, TPhenome> genomeDecoder, IPhenomeEvaluator <TPhenome> phenomeEvaluator, bool enablePhenomeCaching) { _genomeDecoder = genomeDecoder; _phenomeEvaluator = phenomeEvaluator; _enablePhenomeCaching = enablePhenomeCaching; if (_enablePhenomeCaching) { _evaluationMethod = Evaluate_Caching; } else { _evaluationMethod = Evaluate_NonCaching; } }
/// <summary> /// Construct with the provided IGenomeDecoder, IPhenomeEvaluator, ParalleOptions and enablePhenomeCaching flag. /// </summary> public ParallelGenomeListEvaluator(IGenomeDecoder <TGenome, TPhenome> genomeDecoder, IPhenomeEvaluator <TPhenome> phenomeEvaluator, ParallelOptions options, bool enablePhenomeCaching) { _genomeDecoder = genomeDecoder; _phenomeEvaluator = phenomeEvaluator; _parallelOptions = options; _enablePhenomeCaching = enablePhenomeCaching; // Determine the appropriate evaluation method. if (_enablePhenomeCaching) { _evalMethod = Evaluate_Caching; } else { _evalMethod = Evaluate_NonCaching; } }
public virtual object Evaluate(IDictionary <string, object> parameterValues) { // the goal here is to use lambda parameters order and create // a list of parameters (from passed dictionary) in the same order // for the DynamicInvoke to work List <object> parameters = new List <object>(); foreach (ParameterExpression parameter in EvaluationLambda.Parameters) { if (parameterValues.ContainsKey(parameter.Name)) { // add value in the list parameters.Add(parameterValues[parameter.Name]); } else { // add null to the list (skipped parameters) parameters.Add(null); } } object result = EvaluationMethod.DynamicInvoke(parameters.ToArray()); return(result); }
public GenerationalChange(EvaluationMethod evaluationMethod, GenerationChangeModel generationChangeModel) { this.evaluationMethod = evaluationMethod; this.generationChangeModel = generationChangeModel; }
/// <summary> /// Default Constructor /// </summary> /// <param name="m">Delegate Reference</param> public Predicate(EvaluationMethod m) { _evaluationMethod = m; }
/// <summary> /// Default Constructor /// </summary> /// <param name="m">Delegate Reference</param> public Predicate(EvaluationMethod m) { _evaluationMethod = m; }