
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Many thanks to the author for the library!
Add the line "cnt++;" in the loop of the parent search function, otherwise it may go into an eternal loop!
Indeed, in some cases there may be a situation when the loop may become infinite - when there is only one individual in the population.
Thanks for the post, I will make the changes shortly.
PS Most likely, I forgot to insert cnt++, after all, that's why I entered this variable. :)
I remember a desire to make the loop with the for() operator, so that it would be possible to regulate the "persistence" of searching for different parents, but then I changed my mind, not seeing much sense in it.
@joo Is it possible to use your library for selection of parameters of Ishimoku, MAKD, etc. indicators?
If you asked: "For which trader's optimisation tasks is it impossible to use the library?". - then I wouldn't know what to answer.
Of course you can.
If you asked: "For which trader's optimisation tasks is it impossible to use the library?". - then I wouldn't know what to answer.
Of course you can.
Sorry for a stupid question, I am not a programmer. If possible, please share the code, where your library is used to select several parameters to one indicator (for example, Ishimoku, MAKD) for clarity of its work.
The question is not stupid at all.
Use the second example in the article. Instead of the ZZ indicator, substitute any other one. In the place of reading the ZZ tops, you need to write your own conditions (MACD, for example, you will get the same alternative zigzag, but according to the rules you set). There is nothing complicated. Try it, write the code. If you fail, ask questions, demonstrating problematic places in the code. Those who are interested will see ways of solving their tasks, you and everyone will benefit. If you don't want to learn the language, please contact"Work".
2joo:
Could you please tell me the essence of the RemovalDuplicates() function? The question is as follows: If we have two identical chromosomes, should they both be marked as duplicates, or should one of them remain unmarked as a duplicate for further use?
Also, to speed up this function, I suggest that the Ch2 loop start with the value Ch+1, since there is no point in Ch2 starting from zero:
//Выбираем второй из пары...
for (Ch2=Ch+1;Ch2<PopulChromosCount;Ch2++)
and if the answer to my question is that both chromosomes are marked as duplicate, then instead of:
do:
And if the answer is that one chromosome should be left NOT marked as a duplicate, then the Ch2 loop should start with the value Ch+1 anyway.
2joo:
Could you please tell me the essence of the RemovalDuplicates() function? The question is as follows: If we have two identical chromosomes, should they both be marked as duplicates, or should one remain unmarked as a duplicate for further use?
The algorithm for this function is as follows:
We mark all chromosomes with the uniqueness feature "1". We think that all chromosomes are unique.
Check if there are identical chromosomes. To do this, we virtually duplicate the population and compare all chromosomes with each other, while skipping pairs with the same sequence number. The duplicates found are marked with the duplicate feature "0".
Next, copy all remaining chromosomes not marked as "0" into the temporary array. We get a filled temporary array without gaps, and we already know how many unique chromosomes are left in the population.
Next, the only thing left is to copy the chromosomes back into the population. As you can see, there is no chromosome deletion, the unique chromosomes are only shifted to the beginning of the population.
To test this function, write a script and try to feed manually made tricky combinations of filled arrays. You will see how efficiently/inefficiently the function works. Calculate the smallest possible number of checks of columns in the array and compare it with the number of times the RemovalDuplicates() function checks columns.
ZY To test this function, write a script and try to feed manually made tricky combinations of filled arrays. You will see how effective/ineffective the function is. Calculate the smallest possible number of checks of columns in the array and compare it with the number of times the RemovalDuplicates() function checks the columns.
At the beginning of the loop "for (Ch2=Ch+1)" the number of necessary and sufficient iterations will be reduced 2 times and one of the duplicate chromosomes will not be marked as a duplicate. Here I was wondering how much more correct it would be to leave one chromosome of the duplicates unique! I.e. the task of the function is to remove identical chromosomes, but one copy of the duplicate chromosomes seems to me better to return to the population, because the presence of its duplicates does not prove its vitality. For example: if there is an array of chromosomes {1,3,4,7,7,7,6,7,8,8}, I think the optimal duplicate removal would be this result: {1,3,4,7,6,8}. So chromosomes 7 and 8 will be considered further.
Your previous remark about cnt++ was fair. But this time you are wrong. I suggest you not to speculate on "What will happen if...?" but write a script, test the function and demonstrate the result.
One single unique chromosome remains, the rest of its exact copies will be recognised as duplicates and "deleted".
This is probably one of the most moscow-breaking functions of the entire UGA algorithm. It took me the most time. But there are no errors in it.
PS The main thing is that there should be no repeated checks of the same chromosomes - this is done.
The number of checks for uniqueness is the minimum necessary. If you are talking about the number of runs in the for() operator, you can reduce them (while the number of uniqueness checks will remain the same - the minimum possible) by introducing an additional variable, each time increasing by one in the nested one. This will slow down the function.
PPS If you emphasise on:
shurick:
....
how much more correct would it be to leave one chromosome from the duplicates unique! I .e. the task of the function is to remove identical chromosomes, but one copy of duplicate chromosomes seems to me better to return to the population, because the presence of its duplicates does not prove its vitality.
The function's job is to remove duplicates. That's what it's called. It's not about removing identical chromosomes. See the difference? This function doesn't distinguish between chromosomes based on their viability. As a result, only unique chromosomes remain, with no duplicates.
PPPS I'll make one more clarification just in case.
Suppose we have a population consisting of 20 chromosomes (for simplicity and clarity with a single integer gene), the maximisation problem:
|7|2|3|9|2|4|5|3|3|5|6|2|4|3|5|10|6|7|7|2|
That is, in a population of chromosomes containing the gene
2 - 4 pieces
3 - 4 pieces
4 - 2 pieces
5 - 3 pieces
6 - 2 pieces
7 - 3 pieces
9 - 1 piece
10 - 1 piece.
Total - 20 pieces of chromosomes.
After removing the duplicates, the population will look like this, with 8 chromosomes remaining:
|7|2|3|9|4|5|6|10|
So there's one unique chromosome left, the rest are duplicates and will be "deleted"
after the function call.
at the end of the function.
The population will look like this:
|10|9|7|6|5|4|3|2|
PPPS I'll make another clarification just in case.
Thank you very much for the clarification, the question on removing duplicates is fully answered to my satisfaction. I am attaching the script code demonstrating the original and optimised function, which demonstrates the reduction of the number of passes in loops. In my current comment I am NOT pointing out a bug in the function, but suggesting its optimisation, and my main goal was to find out the principle of duplicate removal, to which I received a comprehensive answer. Thank you very much again for the library and for the explanations of the function.