Errors, bugs, questions - page 1962

 
Andrey Khatimlianskii:

How does this help?

The optimisation has gone through, we have written down all the parameters to be searched with ranges of values.

And then we run a single test, read the parameter list, and display it: parameter = value. In this case we don't know the value, because we can't refer to the input variable by name.

You make the input parameter bool Optim. In OnInit, you return INIT_FAILED if Optim == true. At the same time in OnTesterPass through FrameInputs and ParameterGetRange (or in the destructor of the global class object) you write the actual SET of Optimization.

Then you put Optim = false. And take one more parameter sinput int Range, set it through ParameterSetRange to change from zero to one. Read the SET-file in OnTesterInit and set values of all the parameters from the file in ParameterSetRange. When Range == 0 you return INIT_FAILED in OnInit.

That's all! Instead of single Optimization you have imaginary Optimization, which is also faster than single Optimization.... Plus read/write input parameters.

 

off-topic question but I will ask you if it is possible to supplement the MQL5 handbook with additional examples of algorithm implementation more and clearer

 
fxsaber:

Make the input parameter bool Optim. In OnInit you return INIT_FAILED if Optim == true. At the same time in OnTesterPass through FrameInputs and ParameterGetRange (or in destructor of global class object) you write actually SET-file Optimization.

Then you put Optim = false. And take one more parameter sinput int Range, set it through ParameterSetRange to change from zero to one. Read the SET-file in OnTesterInit and set values of all the parameters from the file in ParameterSetRange. When Range == 0 you return INIT_FAILED in OnInit.

That's all! Instead of single Optimization you have imaginary Optimization, which is also faster than single Optimization.... Plus read/write input parameters.

Thanks for the detailed algorithm.

 
Compile time in 1643
'TesterBenchmark_Example.mq5'   TesterBenchmark_Example.mq5     1       1
'TesterBenchmark.mqh'   TesterBenchmark.mqh     1       1
0 error(s), 0 warning(s), compile time: 3113 msec               1       1

Compile time at 1648

'TesterBenchmark_Example.mq5'   TesterBenchmark_Example.mq5     1       1
'TesterBenchmark.mqh'   TesterBenchmark.mqh     1       1
0 error(s), 0 warning(s), compile time: 219 msec                1       1

Something's been tweaked!

 

Compilation error

typedef void (*fn)( int );
struct A {
                void f() { return   ; } //(*)
        static  void f( int ) {}
};
void g( fn ) {}
void OnStart()
{
        g( A::f ); //error: 'f' - cannot resolve function address
}

And if you replace line (*) with

                int  f() { return 0; } //(*)
then it's fine. What's the difference?

It looks likehttps://www.mql5.com/ru/forum/1111/page1977#comment_5595772, but has a different error code


Ошибки, баги, вопросы
Ошибки, баги, вопросы
  • 2017.08.11
  • www.mql5.com
Форум алго-трейдеров MQL5
 

Error during compilation

template<typename T>
void g( T ) {}
void f() {}
void OnStart()
{
        g( f ); //error: 'g' - cannot to apply function template
}

Otherwise:


template<typename T>
void g( T ) {}
void f() {}
typedef void (*fn)();
void OnStart()
{
        fn ff = f;
        g( ff ); //нормально
}

It's fine. What difference does it make?
 
A100:

Error during compilation

but this way:

normally. What's the difference?

The difference is huge. When g(f) is called, the compiler has no idea what type f is, because only template is prescribed. If you overload the template, there is no problem

typedef void (*fn)();

template<typename T>
void g( T Value ) { Print(typename(Value)); }
void f() {}

void g( fn Value ) { Print(typename(Value)); }
void OnStart()
{
        g( f ); // void(*fn)()
}
 
fxsaber:
Compile time at 1643.

Compile time at 1648


That's a cool tweak!

Mine is the same as it was, compilation is not faster!

 
Vitaly Muzichenko:

I still have it, compilation is not accelerated

Perhaps not using what used to slow down in TesterBenchmark.mqh

 
fxsaber:

The difference is huge. When g(f) is called, the compiler has no idea what type f is, because only the template is prescribed. If you overload the template, there is no problem

If there is a huge difference, then why does C++ compile well with both variants?
Reason: