// Does calculation of WCET. private void calculation() { // Check if automatic or manual calculation. if (_automatic) { // Start loop and create new Generation. Generation myGeneration = new Generation(_aSettings.populationSize, _param, _aSettings.mutationRate, _aSettings.crossoverCount, this); _bestGenom = myGeneration.getBestGenom(); do { // Call Functions in GUI to show results. _printResult(myGeneration, myGeneration.getBestGenom()); // Crossover and Mutate Generation. myGeneration.crossover(); myGeneration.mutate(); // Select Genes from Generation with selected Selection Strategy & Create new Generation but use existing genoms. myGeneration = new Generation(_aSettings.strategy.select(generation2Array(myGeneration)), _aSettings.populationSize, _aSettings.mutationRate, _aSettings.crossoverCount, this); // Change bestGenom if necessary. if (_bestGenom.fittness < myGeneration.getBestGenom().fittness) { _bestGenom = myGeneration.getBestGenom(); } } while (again()); // Finish and return Genom with WCET. _finishedWCET(_bestGenom); } // Do Manual calculation. else { // Create Genom. Genom myGenom = new Genom(_param,this); // Return Genom to GUI. _finishedManual(myGenom); } }
private void createGenes(uint givenGenes) { Parameter genomParameter; Random ran; int countAnalog = _blaram.analog.Length; int countDigital = _blaram.digital.Length; int countEnums = _blaram.enums.Length; float[] analogVal = new float[countAnalog]; bool[] digitalVal = new bool[countDigital]; int[] enumVal = new int[countEnums]; for (uint k = givenGenes; k < this._size; k++) { ran = new Random(); for (int i = 0; i < countAnalog; i++) // Erzeugung Random Analogwerte { analogVal[i] = (float)ran.NextDouble(); } for (int i = 0; i < countDigital; i++) // Erzeugung Random Digitalwerte { digitalVal[i] = rndBoolean(); } for (int i = 0; i < countEnums; i++) // Erzeugung Random Enum werte { enumVal[i] = ran.Next(10); } genomParameter = new Parameter(analogVal, digitalVal, enumVal); //Parameter und Genomerzeugung _genomArray[k] = new Genom(genomParameter,_ea); //Calculate Fittness. } }
public Genom getBestGenom() { Genom dummy = new Genom(null,null); dummy.fittness = 0; for (int k = 0; k < _genomArray.Length; k++) { if (_genomArray[k].fittness > dummy.fittness) { dummy = _genomArray[k]; } } return dummy; }
public Genom getBestGenom() { Genom dummy = new Genom(null); return dummy; }