Questions on OOP in MQL5 - page 94

 
Igor Makanu:

I can make significant bits out of int with a "head-on" solution, but I can't make a universal solution... I can't! (((

It is highly probable that I have not explained how and where I want to go

there are 4 bytes int / uint, and there is my dataset, which I want to unpack in the optimizer

let's assume I succeeded in packing it this way:

0-8 9-16 17-24 25-32
int_11 int_9 int_12

what types I need int_XXX, I have not yet estimated

but I want to have a usability in the form of this code

in general, it works as I want it to

//+------------------------------------------------------------------+
// value - значение
// pos - бит начала числа
// cnt_bits - общее количество занимаемых бит
//+------------------------------------------------------------------+
int BitsToInt(const uint value, const uint pos, const uint cnt_bits)
{
   uint mask_value = (0x7FFFFFFF >> (sizeof(uint) * 8 - cnt_bits)) << pos;
   uint mask_sign = 1 << (pos + cnt_bits - 1);
   int sign = (bool)(value & mask_sign) ? -1 : 1;
   return(sign * (int)((value & mask_value) >> pos));
}
//+------------------------------------------------------------------+
void OnStart()
{
   uint v = 0x7F << 12;
   Print(BitsToInt(v, 12, 8));   // 127
   v = 0xFF << 12;
   Print(BitsToInt(v, 12, 8));   // -127
}
//+------------------------------------------------------------------+

... Too bad, if I counted the bits wrong again (((

 
Igor Makanu:

in general, it works as well as I'd like it to.

... too bad if the bits are counted wrong again (((

Immodest question, what is the purpose of chasing bits?

 
Alexandr Andreev:

Immodest question, what is the purpose of chasing bats?

wrote in the first post of this piece

we need to reduce the number of optimisable parameters - not critical

and want to apply Gray's code to a new "int" optimised parametre, so that the optimiser's GA does not converge so quickly - Wiki

 
Igor Makanu:

in general, it works as well as I'd like it to.

... bad if the bits are counted wrong again (((

If it's 5, 32-bit ints rarely make sense, almost never (only as loop counters and size units, and that's out of habit)

And everything fits into 64 without bit shifts .

By the way, even if you have a 4, you should still pack in 64-bit values, for example in double - it is in demand.

 
Maxim Kuznetsov:

And 64 will fit everything without bit shifts ...

No way, longitudes are not optimized in the tester, a couple of months ago I asked why - no answer

uint - I think it was glitchy too... it seems that the maximal value was not allowed to be used during optimization

so only int and it (most likely) will not work correctly in the new builds

 
Igor Makanu:

No way, longs are not optimised in the tester, I asked them a couple of months ago - they didn't give me an answer

uint - I think it was glitchy too... it seems that the maximum value was not allowed to be used during optimization

so only int and it (most likely) will not work in new builds

it will take you more than a month to overlap an empty loop with logging

You'd better create your own format, where the first few bits are size, then a record. And you should write everything in byte array.

A byte array can easily be copied into any other

 
Alexandr Andreev:

it takes more than a month to go through an empty loop with a long run

So it is, but I for a long time am not chasing after an ideal TS - what the optimizer finds I write in the database, but the problem is in GA convergence around a group of parameters, so I decided to try to cheer up GA with a scientific approach ))))


Alexandr Andreev:

It's easier to create your own format, where the first few bits are size, then a record. And write everything in byte array.

I need to test, but for now I hope, that Gray's code and my manipulations with grouping optimizable parameters into int will help to solve the GA convergence problem... we'll see, not everything is as fast as we'd like it to be

 
Igor Makanu:

No way, longs are not optimised in the tester, I asked them a couple of months ago - they didn't give me an answer

uint - I think it was glitchy too... It seems that the maximum value was not allowed to be used during optimization

so only int and it (most likely) will not work correctly in the new builds

Did you set this parameter for the optimizer?

On the one hand, you can set double, it has a mantis more than 32, but you can get stuck with double<->string conversions in the profile

 
Maxim Kuznetsov:

do you set the optimiser parameter like this?

no

i have more than 10 optimizable parameters, i set the optimization limits, everything works fast, but GA can go around 2 parameters and that's it - no use in optimization anymore

i have either to group the parameters and run them by groups or just restart the optimization and clear the caches

I would like to make an experiment and check if Wiki is right about GA

Gray's codes are widely used in the theory of genetic algorithms [3] for coding genetic features represented by integers.

 
Igor Makanu:

no

i have more than 10 optimized parameters, i set limits, everything works fast, but GA can gather around 2 parameters and no more optimization is needed

i have either to group the parameters and run them by groups or just restart the optimization and clear the caches

i would like to make an experiment and see if wiki tells the truth about GA

Gray's codes are sometimes used in data transfer protocols just because. Actually they were made for them :-)

GA is more of a "buzz word". How can Gray's code help with convergence? Just theoretically...

you might as well just randomly shuffle

Reason: