Optimisation in the Strategy Tester - page 7

 

In brief:

  • Reasonable sufficiency is to fit into a search field of 2 to the power of 64
  • Reasonable behaviour is to pre-estimate the search field instead of cranking out all the variables to be searched to the maximum

Rashid, it is unlikely that anyone would dare to do a straightforward enumeration. A 2^64 genetic optimizer will easily check, but that doesn't mean you have to expose unlimited search regions. After all, we have to generate genes for these regions and then manipulate them.

 
Rosh:

OK, let's do the math. Let one pass in the tester take 1 second, then let's divide the number of passes 2^64-1 by 60 and get the optimization time in minutes: 18 446 744 073 709 551 615/60.

Next, divide this time by 8 (8 cores on the computer) and get the optimization time with this number of passes on an 8-core computer. How much will it take in hours or days?

Don't count, I'm not talking about a straightforward enumeration. Let the genetic algorithm itself determine how many it needs.

If you compare it to the human brain, according to scientists the brain contains about 10^10 neurons and each has about 10^4 synaptic connections.

This is what we are all striving for, creating more and more advanced programs.

What was cloud computing made for? Thanks to this, users are not limited to a single computer, for which thanks very much.

Генетические алгоритмы - это просто!
Генетические алгоритмы - это просто!
  • 2010.05.25
  • Andrey Dik
  • www.mql5.com
В статье автор расскажет об эволюционных вычислениях с использованием генетического алгоритма собственной реализации. Будет показано на примерах функционирование алгоритма, даны практические рекомендации по его использованию.
 
Renat:

To make a long story short:

  • Reasonable sufficiency is to fit into a search field of 2 to the power of 64
  • Reasonable behaviour is to pre-estimate the search field instead of cranking out all the variables to be searched to the maximum

Rashid, it's unlikely that anyone would dare to do a straightforward overshoot. A 2^64 genetic optimizer will easily check, but that doesn't mean you have to expose unlimited search domains. After all, we have to generate genes for these regions and then manipulate them.

What is 2 in 64 is a far-fetched problem.

In a genetic algorithm you don't have to keep the worst results?

What prevents you from twisting all the variables to the maximum?

I can't figure out what the connection is between genes and 2^64?

Генетические алгоритмы - это просто!
Генетические алгоритмы - это просто!
  • 2010.05.25
  • Andrey Dik
  • www.mql5.com
В статье автор расскажет об эволюционных вычислениях с использованием генетического алгоритма собственной реализации. Будет показано на примерах функционирование алгоритма, даны практические рекомендации по его использованию.
 

Still, it may come in handy to search through a lot of variables (e.g. Neural Network) and this limitation is not good.

So hope for freedom from constraints))

 

The strategy tester appears to use GA with binary chromosome coding.

Here is a quote:

"However, the binary representation of chromosomes entails certain difficulties when searching in continuous spaces of large dimensionality, and when high accuracy is required a special technique is used based on the fact that the whole interval of admissible values of a feature [ai,bi] is divided into sections with the required accuracy. The required precision p is defined by the expression:


where N is the number of bits to encode a bit string.

This formula shows that p strongly depends on N, i.e. representation accuracy is determined by the number of bits used to encode one chromosome. Therefore, as N increases, the search space expands and becomes huge. A well-known book example: let 100 variables varying in the interval [-500; 500] require finding an extremum to within six decimal places. In this case, using GA with binary coding, the string length would be 3000 elements and the search space would be about101000 chromosomes."

Therefore, even a relatively small-sized neural network in the standard optimizer, when limited to 64 parameters to be optimized, can not be trained. There is one more inconvenience - it is very time consuming to manually fill in parameters of optimizable variables if there are a lot of them. That's why I already suggested that you may specify arrays with optimizable parameters programmatically.

But there is good news. Everything that is missing in the tester and the terminal can be implemented using the native MQL5 means. Later I will post the results of some optimization tests using the tester and the program code.

 

However, I never waited for the results from the tester on the test task (I mean, waiting is lazy).

But anyone can do the tests themselves. For this you can take the first example from the article. Do not forget to set optimization mode - search for maxima (to be able to compare with the standard optimizer where only maxima are available).

Let's write a simple Expert Advisor that is even simpler than a green turnip and does not do anything but calculate the user's test function:

//+------------------------------------------------------------------+
//|                                                  Test expert.mq5 |
//|                                      Copyright 2010, JQS aka Joo |
//|                              https://www.mql5.com/ru/users/joo |
//+------------------------------------------------------------------+
#property copyright "Copyright 2010, JQS aka Joo"
#property link      "https://www.mql5.com/ru/users/joo"
#property version   "1.00"
//--- input parameters
input double   x1=0.0;
input double   x2=0.0;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---

//---
   return(0);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---

  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {

  }
//+------------------------------------------------------------------+

double OnTester()
  {
   return
   (
    pow(cos((double)(2*x1*x1))-0.11 e1,0.2 e1)+
    pow(sin(0.5 e0 *(double) x1)-0.12 e1,0.2 e1) -
    pow(cos((double)(2*x2*x2))-0.11 e1,0.2 e1)+
    pow(sin(0.5 e0 *(double) x2)-0.12 e1,0.2 e1)
    );
  }
//+------------------------------------------------------------------+

The settings in the tester window are as follows:


In the "Input parameters" tab, do the following:


And go.

The approximate conclusions are as follows:

1) The optimizer in the tester is 10-100 times slower (it worked for me, even though optimizing in the tester was performed on two processor cores, while software optimization was performed on one core). Most likely, such a monstrous difference is due to the fact that the tester has to write logs, display information on the screen, etc., in addition to direct calculations of FF, i.e. it has "forced braking" as opposed to software optimization.

2) It is impossible to use more than 64 optimizable parameters in the tester (and in Wizard for creating Expert Advisors it is limited to 60 parameters), therefore it is impossible to train neural networks of any significant size.

It is either to write test substitutes by yourself (MQL5 allows it, it's an excellent "fishing rod" but not a "fish"), or wait until the binary genetic algorithm of the tester is replaced by a continuous algorithm and the limitation on the number of optimized parameters will be removed. The second is not constructive, so the first remains. :)

Global conclusion: Learn MQL5.


PS A good solution would be to enable to disable output of optimization information (logs, optimization graph) and, even better, to customize the details of the displayed information in order to increase tester's performance.

 
joo, there's more to it, besides writing a tester and optimizer for such not small calculations, you need to make a distributor of calculations, which would involve all the processor cores and possibly connect remote agents (if you do collective calculations). Firstly the speed of it can not compare with the standard tester - everything will run much slower, and secondly for writing all this you need to spend a lot of time and hundreds of kilobytes of code, and all because of what, exactly?
 
Mr.FreeMan:
joo, there's more to it, besides writing a tester and optimizer for such not small calculations, you need to make a distributor of calculations, which would involve all the processor cores and possibly connect remote agents (if you do collective calculations). Firstly it's not comparable with standard tester - everything will be much slower, and secondly for writing all this you need to spend a lot of time and hundreds of kilobytes of code, and what's the reason?
GA from joo is already faster than the standard one, and by porting code to CPP with studio 10 (adapted for multi-core processors) the speedup is 6 times faster still.
 
Mr.FreeMan:
joo, there's more to the point; in addition to writing a tester and optimizer for such small calculations you also need to make a distributor for calculations that would involve all processor cores and possibly connect remote agents (if you want to hold collective calculations). Firstly the speed of it can not compare with the standard tester - everything will run much slower, and secondly for writing all this you need to spend a lot of time and hundreds of kilobytes of code, and all because of what, exactly?

About the red Urain answered.

As for the green, it's about money, of course. Time is money. I'm usually a slow starter, but a fast rider (it took me over a year to develop and debug the GA), and now I keep getting thank you messages in my inbox after the article is published. :)

I'm not criticizing the in-house tester. I am only focusing developers' attention on what must be paid special attention to. After all, no matter how good the optimizer is (the optimizer, not the tester), if it is terribly slow, all its advantages fade away.

 

Just now a bold thought occurred to me. Although, in fact, why wouldn't it?

I will be honored to use my UGA in MetaTrader 5 optimizer by MetaQuotes Software Corp. It will be absolutely free, although I won't refuse bonuses of course.

UGA is simple and efficient. Very flexible in settings. In the tester you can enter three settings templates - "Rough", "Medium" and "Fine", and also display separately the settings with the message "If you don't know exactly what you need it for, don't change anything in these settings". Then it will be possible to conduct optimization with the desired degree of detail search - from very quick approximation to exact final search of optimum settings of TC. At the moment, the built-in optimizer doesn't allow itself to be configured in any way.

Торговая платформа MetaTrader 5 для организации брокерского обслуживания / MetaQuotes Software Corp.
  • www.metaquotes.net
Торговая платформа MetaTrader 5 предназначена для проведения торговых операций на различных финансовый рынках. Терминал обладает большой базой аналитических возможностей и поддерживает более 70 различных инструментов для выполнения технического анализа