Skip to content

Commit

Permalink
using elastic energy as fitness criterion
Browse files Browse the repository at this point in the history
  • Loading branch information
EmilPoulsen committed Jul 24, 2018
1 parent b095996 commit 222822d
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions Frixel.Optimizer/Optimization/StructuralFitness.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@ public double Evaluate(IChromosome chromosome) {
var pixel = _structure.Pixels[i];

//// HACK //////

bool lol = rand.Next(0, 2) == 0;
pixswi.Switch = lol;
//bool lol = rand.Next(0, 2) == 0;
//pixswi.Switch = lol;
///// HACK //////

if (!pixel.LockedBrace) {
Expand Down Expand Up @@ -83,23 +82,30 @@ public double Evaluate(IChromosome chromosome) {
}

this.LatestResults = results;
double max = double.MinValue;

(chromosome as StructuralChromosome).Results = results;

foreach (var pair in results.NodeResults) {
var res = pair.Value;

double dist = Math.Sqrt(Math.Pow(res.DispX, 2) + Math.Pow(res.DispY, 2));
//double max = double.MinValue;
//foreach (var pair in results.NodeResults) {
// var res = pair.Value;

if (dist > max) {
max = dist;
}
// double dist = Math.Sqrt(Math.Pow(res.DispX, 2) + Math.Pow(res.DispY, 2));

// if (dist > max) {
// max = dist;
// }
//}

double energy = results.ElasticEnergy;
double fitness = 0;
if (energy > 0) {
fitness = 1 / energy;
}
this.CurrentFitness = max;

this.CurrentFitness = fitness;

//double weight = CalcWeight(model);
return max;
return fitness;
}

public AnalysisResults LatestResults { get; set; }
Expand Down

0 comments on commit 222822d

Please sign in to comment.