|
QuantShare
2012-06-28 11:13:35
|
|
Here is a script that was sent to me by a QuantShare user. It plays a sound each time the PBIL or Genetic Algorithm optimizer finds a new fitness high.
The script must be placed as a fitness formula in your optimizer.
Fitness = AnnualReturn; // Type your fitness formula here
String soundfile = "e:\\_Quantshare\\Sounds\\new fitness high found.wav";
if (!Global.ContainsVariable("max_Fitness"))
{Global.SetVariable("max_Fitness", (double)Double.NegativeInfinity);};
if (Fitness > (double)Global.GetVariable("max_Fitness"))
{
System.Media.SoundPlayer new_fitness_high = new System.Media.SoundPlayer(soundfile);
new_fitness_high.Play();
Global.SetVariable("max_Fitness", Fitness);
Global.Trace("New Fitness High " + Math.Round(Fitness, 2).ToString() + " in Generation " + (OptimizerMetrics.Generation + 1).ToString());
}
|
|