public override void UpdateData() { if (Segment.Character.Evolution == null) { return; } Valid = IsValid(); if (!Valid) { return; } if (X) { Motion = Segment.Joint.X; } if (Y) { Motion = Segment.Joint.Y; } if (Z) { Motion = Segment.Joint.Z; } Ptr = Segment.Character.Evolution.GetModel().FindMotionPtr(Motion); NormalisedTargetValue = Segment.Joint.JointType == JointType.Rotational ? NormalisedTargetValue = Utility.Deg2Rad * TargetValue : TargetValue; }
//Evaluates the fitness of an individual after modifying one specific gene private double ComputeFitness(double[] genes, bool balanced, Model.MotionPtr modification) { double[] px, py, pz, rx, ry, rz, rw; modification.Node.SimulateModification(genes, out px, out py, out pz, out rx, out ry, out rz, out rw); double fitness = 0.0; for (int i = 0; i < Model.ObjectivePtrs.Length; i++) { Objective objective = Model.ObjectivePtrs[i].Objective; Model.Node node = Model.ObjectivePtrs[i].Node; double loss = objective.ComputeLoss(px[i], py[i], pz[i], rx[i], ry[i], rz[i], rw[i], node, balanced); fitness += objective.Weight * loss * loss; } return(System.Math.Sqrt(fitness / (double)Model.ObjectivePtrs.Length)); }