Algorithm Optimisation Championship. - page 52

 

Why import in the second example?

//+------------------------------------------------------------------+
// тестовая фитнес функция чемпионата, не известна участникам
#import "\\Projects\\OAC\\lib\\ff.ex5"
// запросить количество параметров ФФ 
int    GetParamCountFF (); 
// запуск ФФ, получеие значения соответствующее параметроам ФФ
double FF (double &array []); 
// произведённое количество запусков ФФ
int    GetCountRunsFF (); 
#import
 
Dmitry Fedoseev:

Well, I could write that too - what's so unclear about my question?

It was more of a rhetorical question, because I'm sure you understand.

Dmitry Fedoseev:
Why do I have to ask one question 10 times?

It's a difficult question, I often wonder the same thing.)

DmitryFedoseev:

Why do you need import in the second example?

In order to control the algorithm from the script, how many times the algorithm actually called the FF.

For the first variant it is clearly visible, because the script itself makes calls, but for the second variant it is not visible, which is why we need the ability to access the FF library from the script.

 

Now, I want to appeal to all participants, who consider themselves as "newcomers" in this subject and do not seriously expect to win.

If we drop all the insane "theory" about multiple dimensions of space, which confuses the problem and turn to pure mathematics, we see that the FF is an equation.

This equation becomes an analytical function only if applied to a graph.

But there is a question - SHOULD IT BE? A graph simply helps to visualize the relationship between the equation's parameters.

After 158 pages of discussion, we can already formulate the essence of the problem:

We need to find the values of the variables on the right side of the equation at which the value of the variable on the left side of the equation is greatest.

The goal is to try to do it more efficiently than a complete enumeration.

That's it.

Next:

To solve this problem, an "Evolutionary" technique for finding values was invented. Analogies and methods originating from Darwinism were constructed.

The question of efficiency of this approach is debatable. Probably, there are simpler and more effective ways to solve this problem.

My practice proves that generally accepted approaches are not always the most effective.

I'm sure we can get around the "evolutionists" quite well...

Let's give it a try!

 

An example of the participant's algorithm for the second variant of calling the FF:

#property library
#property strict

//+------------------------------------------------------------------+
// тестовая фитнес функция чемпионата, не известна участникам
#import "\\Projects\\OAC\\lib\\ff.ex5"
// запросить количество параметров ФФ 
int    GetParamCountFF (); 
// запуск ФФ, получеие значения соответствующее параметроам ФФ
double FF (double &array []); 
// произведённое количество запусков ФФ
int    GetCountRunsFF (); 
#import
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+
void InitAO (int paramCount, int maxFFruns) export
{
  params = paramCount;
  maxFFrunsPossible = maxFFruns;
}
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+
void StartAlgo () export
{
  double param []; 
  ArrayResize (param, params);
  double ffVolue = 0.0; 
  
  //------------------------------------------------------------------
  for(int i=0; i< maxFFrunsPossible; i++) 
  {
    GenerateParam (param);
    ffVolue = FF(param);
    if(ffVolue > maxFFvolue) 
      maxFFvolue = ffVolue;
  }
  //------------------------------------------------------------------
}
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+
double GetMaxFF () export
{
  return(maxFFvolue);
}
//+------------------------------------------------------------------+

//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// Все функции выше этой строки - обязательны! Именно они будут импортированы 
// и использованы тестовым скриптом. Они нужны для доступа к алгоритму оптимизации.
// Содержимое - произвольное, на усмотрение участника
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!



//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// Ниже этой строки пример алгоритма оптимизации участника
//————————————————————————————————————————————————————————————————————
int    params     = 0;
int    maxFFrunsPossible = 0;
double maxFFvolue = - DBL_MAX;
double minParam   = -10.0;
double maxParam   = 10.0;
double stepParam  = 0.1;
//————————————————————————————————————————————————————————————————————

//————————————————————————————————————————————————————————————————————
// Генерация значений оптимизируемых параметров
void GenerateParam (double &param[])
{
  int size = ArraySize (param);
  double paramVolue = 0.0;
  for(int i = 0; i < size; i++) 
  {
    paramVolue = RNDfromCI (minParam, maxParam);
    param [i] = SeInDiSp (paramVolue, minParam, maxParam, stepParam); 
  }
}
//————————————————————————————————————————————————————————————————————

//————————————————————————————————————————————————————————————————————
// Выбор в дискретном пространстве
double SeInDiSp (double in, double inMin, double inMax, double step) 
{ 
  if(in <= inMin) 
    return (inMin); 
  if(in >= inMax) 
    return (inMax); 
  if(step == 0.0) 
    return (in); 
  else 
    return (inMin + step * (double)MathRound ((in - inMin) / step));
}
//————————————————————————————————————————————————————————————————————

//————————————————————————————————————————————————————————————————————
// ГСЧ в заданном интервале
double RNDfromCI (double min, double max) 
{ 
  if(min == max) 
    return (min); 
  double Min, Max; 
  if(min > max) 
  {
    Min = max; 
    Max = min;
  }
  else 
  {
    Min = min; 
    Max = max;
  }
  return (double(Min + ((Max - Min) * (double)MathRand () / 32767.0)));
}
//————————————————————————————————————————————————————————————————————

The basic code of the algorithm is the same as in the first variant, but with calling the FF from the algorithm instead of from the script.

The results are naturally similar as for the first variant:

2016.06.22 11:47:45.321 OAC variant 2 (GBPUSD,M30) ---------------------------------

2016.06.22 11:47:45.321 OAC variant 2 (GBPUSD,M30) Time: 135 µs; 0.00013500 c

2016.06.22 11:47:45.321 OAC variant 2 (GBPUSD,M30) FF Runs: 1000

2016.06.22 11:47:45.321 OAC variant 2 (GBPUSD,M30) Max: 2.94159260

2016.06.22 11:47:41.404 OAC variant 2 (GBPUSD,M30) ---------------------------------

2016.06.22 11:47:41.404 OAC variant 2 (GBPUSD,M30) Time: 136 µs; 0.00013600 c

2016.06.22 11:47:41.404 OAC variant 2 (GBPUSD,M30) FF Runs: 1000

2016.06.22 11:47:41.404 OAC variant 2 (GBPUSD,M30) Max: 3.10159260

2016.06.22 11:47:37.309 OAC variant 2 (GBPUSD,M30) ---------------------------------

2016.06.22 11:47:37.309 OAC variant 2 (GBPUSD,M30) Time: 133 µs; 0.00013300 c

2016.06.22 11:47:37.309 OAC variant 2 (GBPUSD,M30) FF Runs: 1000

2016.06.22 11:47:37.309 OAC variant 2 (GBPUSD,M30) Max: 3.06159260

2016.06.22 11:47:32.933 OAC variant 2 (GBPUSD,M30) ---------------------------------

2016.06.22 11:47:32.933 OAC variant 2 (GBPUSD,M30) Time: 133 µs; 0.00013300 c

2016.06.22 11:47:32.933 OAC variant 2 (GBPUSD,M30) FF Runs: 1000

2016.06.22 11:47:32.933 OAC variant 2 (GBPUSD,M30) Max: 3.10159260

2016.06.22 11:47:07.584 OAC variant 2 (GBPUSD,M30) ---------------------------------

2016.06.22 11:47:07.584 OAC variant 2 (GBPUSD,M30) Time: 180 µs; 0.00018000 c

2016.06.22 11:47:07.584 OAC variant 2 (GBPUSD,M30) FF runs: 1000

2016.06.22 11:47:07.584 OAC variant 2 (GBPUSD,M30) Max: 3.04159260

That is - not bad at all.

 

So, the examples above show the way participants' algorithms are connected to test scripts through importing functions.

Let me remind you why exactly this way of working with algorithms of participants is organized: it is necessary, on the one hand, to hide the algorithm of the participant to protect intellectual property, and on the other hand, to enable control and verification by both jury members and spectators.

 

I will test it today.

But it would be advisable to compile (I understand, Andrei, that you were in a hurry) and in one post, publish the rules concerning the files, with attachments of these very files. Not necessarily right now, but to have a starting point.

 
Реter Konow:

Now, I want to appeal to all participants, who consider themselves as "newcomers" in this subject and do not seriously expect to win.

If we drop all the insane "theory" about multiple dimensions of space, which wildly confuses an already confusing problem, and turn to pure mathematics, we see that the FF is an equation.

This equation becomes an analytic function only if applied to a graph.

But there is a question - SHOULD THIS BE? - A graph simply helps to visualize the relationship patterns of the equation's parameters.

After 158 pages of discussion, we can already formulate the essence of the problem:

We need to find the values of the variables on the right side of the equation at which the value of the variable on the left side of the equation is greatest.

The goal is to try to do it more efficiently than a complete brute force.

That's it.

Next:

To solve this problem, an "Evolutionary" technique for finding values was invented. Analogies and methods originating from Darwinism were constructed.

The question of efficiency of this approach is debatable. Probably, there are simpler and more effective ways to solve this problem.

My practice proves that the generally accepted approaches are not always the most effective.

I'm sure we can get around the "evolutionists" quite well...

Let's give it a try!

If you put aside the emotional colouring of the post, what you said is basically true. The only thing you neglected to mention is that the FF equation itself is unknown within this championship (in life it may or may not be known).

About "non-fiction theories" - I gave in this thread clear hints on the principles of the optimization algorithm that are not used anywhere else and have never been used before (at least in available sources). And the choice is always up to the researcher - how and what he will use in the algorithm. In the example above is an algorithm that has nothing to do with Darwin even indirectly. There are plenty of optimization methods and nobody, at least I did not claim that "originating from Darwin" is better.

So, good luck to the Beginners! Go on, to victory!

 
I haven't coded on a five and also have no experience in export/import operations. Please tell me if I understand your example correctly. I have put my comments in the code. Another question . If the FF will be given by formula then will there be division or root extraction operations. A zero or negative value will cause a critical error and stop the program.
// -- данный код находится на стороне жюри (организатора)---------------------
#property library    //EX5-файл будет являться библиотекой
#property strict
int  countRuns    = 0;  // число обращений к ФФ. Фитнес функции это, как я понимаю неизвестная никому функция у которой 500 параметров
 // и нужно найти такие значения параметров при которой значение фф= максимальному 
//+------------------------------------------------------------------+
int GetParamCountFF () export //функция задачи участникам количества параметров фф  модификатор export указывает что функция доступна
// алгоритму участника  
{ 
  return (2);// возвращает количество параметров участнику 2 для данного примера 
  // участник в своём коде прописывает  int NumberParam=GetParamCountFF();
}

double FF (double &array []) export // сама фф 
{ 
  countRuns++;
  int sizeArray = ArraySize (array);//количество элементов массива
  //-------дальше не пойму логику----------------- 
  if(sizeArray != 2) 
    return (-DBL_MAX); 
  return (-(pow (2.4 + array [0], 2.0) + pow (array [1] - 2.3, 2.0))+3.1415926);
 //--------------вероятно нужно так --------------
    if(sizeArray != 2){ // возвращает минимальное double ( или может лучше ошибку)
    // если количество элементов в массиве пользователя не равно заданному)
    return (-DBL_MAX);
    } 
    else{ // возвращает значение функции
  return (-(pow (2.4 + array [0], 2.0) + pow (array [1] - 2.3, 2.0))+3.1415926);
  }
  //------------------------------------------------------------------
}

int GetCountRunsFF () export
{ 
  return (countRuns);// возвращает кол. обращений к фф
}
 
Yuri Evseenkov:
I do not code on A and have no experience with export-import operations. Please tell me if I understand your example correctly. I have put my comments in the code. Another question . If the FF will be given by formula, will there be division or root extraction operations. A zero or negative value will cause a critical error and stop the program.

Yes, you are correct in your understanding of how the FF championship works.

The only correction about returning results in case of incorrect parameter array size - the participant's algorithm knows about the number of FF parameters and if it sends the wrong size array to the FF, it is the problem of the participant's algorithm, not the FF. Think about this point, if you take the market as an example - the market will never inform you that you are using the "wrong" number of strategy parameters in your trading, you will just get a negative trading result and that's it, without any explanation from the market for your mistakes.

You can replace the word Your with the word Our, and you can replace the word You with We - nothing will change and nothing will remain true.

 
Igor Volodin:

I will test it today.

But it would be advisable to compile (I understand, Andrei, that you were in a hurry) and in one post, publish the rules concerning the files, with attachments of these very files. Not necessarily right now, but to have a starting point.

Probably, it would be convenient to put files of examples in an accessible file storage, so as not to jump in search of them, and to place a link to the storage at the beginning of the branch.

Yes, I will do so.

Reason: