Algorithm Optimisation Championship. - page 130

 
Andrey Dik:

You can go anywhere you like. But this championship will take place as I said earlier. According to these rules, you can compete with me and with other competitors and without me.

Other championships may be different, arrange your own, and do as you see fit. It's a free country.

Voilà!

All the best, dear theorist!

 
Реter Konow:

Voilà!

Goodbye, respected theorist!

Don't take the piss out of me. Prepare and compete by the rules, instead of trying to change the rules to suit you... And do not just babble, better start reading the relevant literature on optimization.

All the best, dear theorist!

 

Greetings.

Transferred my code from the four-editor to the five-editor. Only one error! Replaced TRUE with one and everything worked ! Pleasantly surprised.

This is my first code on F. Could you please tell me what I need to put in my code to connect to the championship?

//+------------------------------------------------------------------+
//|                                                 Yuri skript.mq5 |
//|                        Copyright 2016, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2016, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"

//----------Блок глобальных переменных кода-----
Глобальные переменные кода не должны совпадать с 
именами глобальных переменных интерфейса?
//----------------------------------------------

//---------- Блок ввода начальных значений------
input double xmin=0;//min диапазона поиска
input double xmax=100;//max диапазона поиска
input double Xnz=10;// начальные значения X[]
input int N=3;     // число параметров
input double e=0.01; // погрешность поиска
Будет ли известен диапазон поиска, число параметров ?
//----------------------------------------------
void OnStart()
  {
OC();
}
//--------------ОСНОВНАЯ ФУНКЦИЯ---------------
void OC()
{
//---------
// ЗДЕСЬ РАСПОЛОЖЕН АЛГОРИТМ ПОИСКА.ИМЕЕТСЯ НЕСКОЛЬКО ПОДФУНКЦИЙ.
// ФУНКЦИЯ ФОРМИРУЕТ МАССИВ ЗНАЧЕНИЙ X[x1,x2...xn]. 
// ФУНКЦИЯ РАСЧЕТА F() ВЫСЧИТЫВАЕТ И ВОЗВРАЩАЕТ ЗНАЧЕНИЕ ЗАДАННОЙ ФУНКЦИИ И ДАЛЕЕ ПО АЛГОРИТМУ
F();
//----------
}
//------ФУНКЦИЯ РАСЧЕТА ЗАДАННОЙ ФУНКЦИИ НАПРИМЕР F=(exp(X[1]+X[2]+X[3]))/(X[1]*X[2]*X[2]*X[3]*X[3]*X[3]);
double F()
{
if(X[1]==0||X[2]==0||X[3]==0){zn=0;return(F);}
F=(exp(X[1]+X[2]+X[3]))/(X[1]*X[2]*X[2]*X[3]*X[3]*X[3]);
return (F);
}
 
Yuri Evseenkov:

Greetings.

Transferred my code from the four-editor to the five-editor. Only one error! Replaced TRUE with one and everything worked ! Pleasantly surprised.

This is my first code on F. Could you please tell me what I need to insert in my code to connect to the championship?

Hi.

No, that's not good.

You have to do it like this

Script -> BiblAO.ex5 -> ff.ex5

Earlier in the branch were examples of codes, please take a look. No time now, I'll show links to examples a bit later.

 

Executable Championship script:

#property script_show_inputs
#property strict

//+------------------------------------------------------------------+
// алгоритм оптимизации участника
#import "ao.ex5"
// инициализация АО
void   InitAO (int paramCount, int maxFFruns);
// запуск АО 
void   StartAlgo (); 
// получить максимальное значение ФФ       
double GetMaxFF (); 
#import
//+------------------------------------------------------------------+

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

//--- input parameters
input int MaxFFruns_P = 1000; 


//+------------------------------------------------------------------+
void OnStart () 
{ 
  // узнаем, сколько параметров нужно оптимизировать
  int    paramCount = GetParamCount (); 

  ulong  startTime = GetMicrosecondCount (); 
  
  //------------------------------------------------------------------
  InitAO (paramCount, MaxFFruns_P);
  StartAlgo ();
  //------------------------------------------------------------------
  
  startTime = GetMicrosecondCount () - startTime; 
  
  Print ("Макс: " + DoubleToString (GetMaxFF (), 16)); 
  Print ("Запусков ФФ: " + (string)GetCountRunsFF ()); 
  Print ("Время: " + (string)startTime + " мкс; " + DoubleToString ((double)startTime / 1000000.0, 8) + " c"); 
  Print ("---------------------------------");
}
//+------------------------------------------------------------------+
 

I will now prepare a sample FF library (to demonstrate the interface) and an example of a participant's optimization algorithm (working, can be applied anywhere).

Please note: the above script is already self-sufficient to understand what is required from participants, connect your algo by interfaces and depreciated functions and be ready to participate. The script was given many pages ago....

 

Example of a FF championship (everything will be the same, except for the contents of the FF function and respectively theG_paramCount variable - they will not be known to the contestants, the referee will compile):

#property library
#property strict

int G_countRuns  = 0; 
int G_paramCount = 3; 

//+------------------------------------------------------------------+
int GetParamCount () export
{ 
  return (G_paramCount);
}
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+
void GetParamProperties (double &min, double &max, double &step) export
{ 
  min  = 0.1; 
  max  = 10.0; 
  step = 0.1;
}
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+
int GetCountRunsFF () export
{ 
  return (G_countRuns);
}
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+
double FF (double &param []) export
{ 
  G_countRuns++; 
  
  int sizeArray = ArraySize (param); 
  if(sizeArray != G_paramCount) 
    return (-DBL_MAX); 
  
  double x1 = param [0];
  double x2 = param [1];
  double x3 = param [2];

  double ffVolue = (-exp(x1+x2+x3))/(x1*x2*x2*x3*x3*x3);
  
  return (ffVolue);
}
//+------------------------------------------------------------------+
 
Andrey Dik:

Example FF championship (everything will be the same, except the contents of the FF function and accordingly the variableG_paramCount- they will not be known to the competitors, the referee will compile):

Amazing.

When I asked for this example, you did everything not to provide it.

Now I've gone, and please - FF example.

What is the meaning of this?

 
Реter Konow:

Amazing.

When I asked for this example, you did everything not to provide it.

Now I've gone, and there you go - a FF example.

What do you mean by that?

It's just an example, the same as in the text problem, I've told you that many times. Look closely - the connection interface is exactly the same, like two drops of moonshine.

But you are asking for FF championship code, of course you won't get it, no one will, and it is not in the example now, and I won't know it. The only thing known is the FF connection interface via function import, and this is what is shown in the example. Is it clear? Well, how much more can we explain already... I don't know.

These codes have already been shown in the branch, I'm just bringing it all together for convenience.

So understand, and preferably so I don't have to explain it again, and to the same person....

If you finally understand everything, go ahead, write the algorithm and go to battle. You should have done it a long time ago, everyone has almost finished writing their algorithms (not counting those who have them ready-made).

 
Andrey Dik:

This is just an example, the same as in the text problem, I have told you this many times. Look closely - the connection interface is exactly the same, like two drops of moonshine.

But you are asking for FF code, of course you won't get it, no one will, and it's not in the example now, and I won't know it. The only thing known is the FF connection interface via function import, and this is what is shown in the example. Is it clear? Well, how much more can we explain already... I don't know.

These codes have already been shown in the branch, I'm just bringing it all together for convenience.

So understand, and preferably so that I don't have to explain it again, and to the same person....

I just needed such an example.

The one in the problem with the text is different from this one.

There was a string, and here - an analytical function.

That's why I asked for an example.

Reason: