Improve genetic evolution effectiveness

SQX build 107

See the attached files. If you check box "restart evolution if fitness of in sample stagnates for x (3) generations" the evolution ignore this and continue and continue to reach Max number of generations!
I have UNCHECK box "Start again when finished (continuous repeating evolution)".

I observed this this strange behavior earlier, but now i start 2 tests focused at this problem:
- set the genetic setting by recommendation i help for SQX pdf document (see pdf help file in Home window).
- set 1 island only (remove migration affect, which can distribute "fresh blood" between islands and increase genetic evolution continuation)
- set max number of generations to 10 000 - to see clear how the evolution do not stop and continue and continue with the same initial population without generating new initial population
- set restart evolution stagnation to MINIMUM - min is 3 stagnation

1. I tested it for XAUUSD M30 on M1 data (basic download data set was in tick resolution) and fitness setting R/DD weight 10 and symmetry weight 1 (XAUUSD has problem with generation due very long LONG market till 2011 - for IS for fitness I use symmetry).
2. I tested it for EURUSD M30 on M1 (basic download data set was in tick resolution) and use basic simple fitness setting R/DD only

Mutation is set low - set to 10 % for decreasing evolution befor stagnation (more mutation % can increase evolution due "fresh blood from mutation).

I stopped builder after 700 - 900 generations was reached without restart evolution and restart initial population building - see detail where you can see the same 100 initial population only as at the start of builder.

This is very bad, because evolution continue to reach max setting and waste time for calculation with bad evolution - probably often.

I have experience wit SQ 3.8.2 and older - I i set max stagnation to 9 (and max number of generations to 150) - in average the evolution had 20 - 50 generations and stopped due stagnation > 9. In SQX 107 i set max stagnation to 3 and evolution continue and continue and continue.
In SQX 107 i cannot check stagnation situation by fitness graph or population in generation as in older SQ 3.8.2 - we have not graphs for it and we have not see the temporary generations creation in list (to be done later, probably).

This is major problem in my opinion which decrease in total genetic evolution results generation - generator waste time for calculation old long evolution without stop and start new generation of initial population with new evolution.

Attached file - printscreens of builder, genetic setting and builder configs for XAUUSD and EURUSD which I used.


Vladimir Todt


Attachments
1 PCSQX19 107 XAUUSDM30 Limit podm1_3 shift 1_1 SSMACDaHL GEN 100000_100_95_10_1_3_1_10_5 RDD10Sym1.xml
(1017.83 KiB)
1 Builder restart evolution after fittness stagnation failed genetic setting XAUUSD.png
(129.44 KiB)
1 Builder restart evolution after fittness stagnation failed XAUUSD.png
(209.32 KiB)
2 Builder restart evolution after fittness stagnation failed EURUSD.png
(201.36 KiB)
2 PCSQX20 107EURUSDM30 Limit podm1_3 shift 1_1 SSMACDaHL GEN 100000_100_95_10_1_3_1_10_5 RDD.xml
(1013.91 KiB)
1 Builder restart evolution after fittness stagnation failed genetic setting EURUSD.png
(130.69 KiB)
  • Votes +13
  • Project StrategyQuant X
  • Type Feature
  • Status Fixed
  • Priority Normal

History

t
#1

todtv

08.08.2018 17:54

Task created

t
#2

todtv

08.08.2018 21:21

Attachment 3 Builder restart evolution after fittness stagnation failed genetic setting EURUSD small population.png added

Attachment 3 Builder restart evolution after fittness stagnation failed EURUSD small population.png added

Attachment 3 PCSQX21 107 EURUSDM30 Limit podm1_3 shift 1_1 SSMACDaHL GEN 100000_7_95_10_1_3_1_100_1 RDD.xml added

I tested EURUSD with small population setting too - 7. Small population (7) has more unstable fitness curve then bigger (100) during evolution and stagnation must exist in smart population evolution with bigger probability.


I stopped test after 3087 generations - I need time for building strategy and not to test this bug again and again. See attached files.



h
#3

hankeys

09.08.2018 08:51
i was talking here manytimes about the same problem, that something seem not work and the genetics is still playing with the same initial population. Thx for this kind of test. we will see, what dev team will do with it
t
#4

todtv

09.08.2018 11:27

Yes.

I am thinking to stop betatesting from my side till this problem will be solved, because due this is SQX time "uneconomical" - produce smaller amount of strategy into databank per time or produce more similar strategies - waste my computer time and for my will be better my computers time use for work with SQ 3.8.2 then for SQX with this problem.

MF
#5

Mark Fric

10.08.2018 08:47

Status changed from New to Fixed

Restart because of stagnation was implemented.


I still have to look at genetic evolution, it seems it doesn't work optimally right now. It produces strategies slower than Random generation.

t
#6

todtv

10.08.2018 11:53

Part of this unefficiency is/was due problem with stagnation in my opinion. For example if I set stagnation to 3 and max number of generation to 100. Genetic calculation stop and reset and start with new calculation after 6 - 15 generation if stagnation settins is functional (by SQ 3). If strategies is upgraded by genetics very well on IS, stagnation appear after 15 -50 (80) generations. But if stagnation setting is ignored (as in this reported bug) genetics calculate to  reach 100 generation for each initial population without dependency if initial population is good or bad and this take lot of time and increase (for this setting) genetics unefficiency.

Other problems can be due internal genetic unefficiency calculation as you wrote.


1 observation: In my opinion can be usage of islands in some cases/setting contra productive. Because if I use for example 10 islands genetic calculation start if initial population reach probably 60 - 70 % of target amount (when 7 islands from 10 have of own initial amount filled). Some islands are by time more advanced then other by time calculationa start early then for aother islands and can have better IS fitness (by statistic) but their OOS fitness can be poor, but due migration between islands can spread (due better IS fitness) to all islands and all islands genetic calculation can be uneffectively by bad OOS fitness of original set on for example 1 islands with very good IS fitness but bad OOS fitness.

Reason for this is in my opinion:

1. to use minimal migration (set migration after bigger of generation calculation (20 and more))

2. set amount to migrate <5 %

3. start all genetic calculation on all islands in the same time after total initial populations for all islands is created (not for some islands early then for other as is in build 107 now)!

t
#7

todtv

10.08.2018 12:07

I forgott to add for point 3 this:

My notice is for first initial population and start first genetic calculation for all islands.

But this problem continue as calculation for some islands end earlier then for other (if stagnation setting is functional) and after probably start probably the other initial population creation for early ended genetic calculation on some islands - for this islands more advanced IS fitness form longer genetic calculation islands can overreproduce this new islands calculation due migration.


I suggest to restart other new initial population for all islands after last genetic calculation ends on all last islands from previous all islands calculation set (IP + islands genetics calculations). And do not start new set of IP+genetic calc. befor the older set ends.

MF
#8

Mark Fric

10.08.2018 12:38

Subject changed from SQX 107 - Builder, builder ignore stagnation setting for restarting IP +restarting evolution if fitness stagnate (probably major bug for genetic setting) to Improve genetic evolution effectiveness

Type changed from Bug to Feature

Status changed from Fixed to Confirmed

I renamed this task and makde it a s a feature to check to keep your suggestions tracked..


Genetic evolution should be generally made more efficient.

t
#9

todtv

11.08.2018 02:55

Attachment SQX 108 Builder genetic calculation for more islands setting start from beginnig from different time.png added

Attachment PCSQX24 108 XAUUSDM30 Limit podm1_3 nofuzzy 100_100 shift 1_1 MACDSSaCvstup GEN 150_30_95_50_1_9_3_9_5 RDD6SQN3Sym1.xml added

Attachment SQX 108 Builder genetic calculation for more islands setting start from beginnig from different time 2nd island genetic run.png added

SQX build 108

OK, added info graphs in builder are very usable for my. Stagnation is functional now - I had to increase stagnation setiing for longer genetic calc. - is better for observing how it is calculating. :)

As I see genetic calc. start when first initial population "pocket" for 1st island is full, after start for 2nd etc.. This mean this earlier start population have UNFAIR time/generation advantage in fitness then later start population on other islands in the same set of islands+initial population+genetic on this island.(Printscreens are for first set of calculation after Builder was started) This is bad for my opinion. All islands gen. calc. must start at the same time together in my opinion without different time unfair advantage for different islands.

The islands wit earlier start with mores advanced fitness are spreaded with higher probability to other island by migration. See the discussion above for my point 3.


The 1st printscreen is in moment when 1st island start calculation. 2nd is moment later when 2nd start calculation too. 3rd island is still waiting for initial population filling and filtering to 30 (I had setting for 30 population on 3 islands). Builder config included too.


Probably better is to have genetic calc. on all island in the same generation inn the same time, but I am not specialist programmer in this and i have no idea is this is some program code problem - some backtest during gen. calc. can be quickier then for other islands (lower number of trades, lower strategy code complexity for population on some island then on other etc.) and will be waiting for other island with slower strategies backtest during genetic calc.

t
#10

todtv

11.08.2018 16:42

Attachment Builder genetic with more islands ignore stagnation PCSQX28 108 XAUUSDM30 Limit podm1_3 nofuzzy 100_100 shift 1_1 MACDSSaCvstup GEN 150_7_95_50_1_9_2_100_1 RDD6SQN3Sym1.xml added

Attachment genetic setting SQX 108 builder genetic evolution ignore stagnation setting with more island for earlier start island evolution genetic setting for removing migration efect.png added

Attachment 2 SQX 108 builder genetic evolution ignore stagnation setting with more island for earlier start island evolution 2 situatin adfter island 0 end for stagnation - reset_ 6 is bad displays_bug reported.png added

Attachment 1 SQX 108 builder genetic evolution ignore stagnation setting with more island for earlier start island evolution 1 situatin befor island 0 end for stagnation.png added

SQX build 108

Thanks new info window about genetic in build 108 i see more clearly situation with usage 2 and more islands.


I had set stagnation to 9, max generation to 150 and small population size 7. For removing migration affect set migration after 100 generation and migration rate to minimum 1 %.


If I start the same setting but for 1 island only due stagnation  (9) genetic ends after 9 - c. 20 generation as I observed.

After I set 2 islands with the same settings and see repeatedly how earlier starting island with genetic is waiting in stagnation for 30 -60 generation then later starting siland genetic reach stagnation for 9 generation. After all islands are reset in the same time and new set package calculations start again from beginning. It is bad Because genetic on some islands wastes time for calculation in stagnation more then 9.

If I set 10 islands some island reach over 100 generation in stagnation (not max 9 as is in setting) due this islands do waste calculation in stagnation and are waiting for stagnation of last started island evolution. Due this is more Island calculation is less effective then use 1 island where is from build 108 stagnation normal functional

Generally it is opposite then we need - islands genetics start in different time  with unfair time advantage for earlier start islands, see my notes fro my point 3 above, and all islands end in the same time after the latest started island evolution end - other islands are waiting and calculating in long stagnation for this last island. Yes this frame ideas setting (time different start, the same time end) can be use for mathematical modeling of biological system - included reproducing rate - due this and at the end to see how are in the same artifical "animals" developed on each island. But we use this generally for different purpose and need to do this in opposite (start in the same time, end in different time). Because for us are for example strategies with for example 10 trades per 15 years not usable (but have higher "reproduce rat - quickier backtest and genetic calculation or quickier initial population creation) the normal strategies with for example 400 trades per 15 years for M30 timeframe. We must set the same condition for all kind of strategy befor stagnation - set start genetic calculation in the same time for all islands and end genetic calculation in different time by local stagnation for each island separately. Yeas some island can stop calculation after 20 generation, some after 9, some after 60 generation etc. OK We can use  free CPU power for increase rate calculation for the rest islands befor stagnation or prepare new set package for new initial population (it better in my opinion to use free CPU time to increase rate for rest islands befor stagnation).


I started this repeatedly c. 10x and observed behaviotr of this setting continuously.


In printscreen is config of builder  for 2 islands, genetic setting printscreen and printscreen near 1 island is calculating(waiting) in long stangnation and other is befor stagnation reaching (9) and 2nd printscreen is after reseting after reaching 9 stagnation for  island No. 0 (the numbers 6 in empty initial populations is bug reported in bug report sq4_2451).

I had to do printsreens quickly, due calculation in this setting is relatively quick.


The fitness graph is for No. 0 not 1 - bad name of this graph - it was reported in sq4_2445 bug report .

h
#11

hankeys

14.08.2018 07:25

build 108

how the genetics really works?


- if i set only 1 island my PC could produce 60000 str per hour

- if i set 4 island i could go up to 150000 strs per hour


so by my findings is better to use more islands, but i dont want to use migration betwwen them and want to generate strs from every island independently. So i set migration to 100th generation, so it will never get to it


but i found, that the function "restart evolution" doesnt work independently for each island - but the restart working for all islands together

h
#12

hankeys

14.08.2018 07:57
could the genetics be set, that every island will be independent tree ef evolution with no migration and independent restart function - so we can maximinize effectivness of building process?


because in my PC, if i have more than 1 island, the strs per hour could be doubled

t
#13

todtv

14.08.2018 10:37
hankeys:

"but i found, that the function "restart evolution" doesnt work independently for each island - but the restart working for all islands together"

Yes, this is what I described above in my long comments - especially in red point 3 too and it is wrong.


We need start evolution on all islands in the same time and end evolution for each island independently by calculating his own stagnation. Now SQX genetic on more islands works to the contrary (in opposite way) and this degrades efficiency of islands genetic calculation.

t
#14

todtv

09.09.2018 17:21
Voted for this task.
IH
#15

clonex / Ivan Hudec

20.09.2018 08:57
Voted for this task.
Dw
#16

Diwi

24.09.2018 17:10
Voted for this task.
l
#17

ludvick

02.10.2018 13:51
Voted for this task.
m
#18

Martin

03.10.2018 11:45
Voted for this task.
KW
#19

Sean

03.10.2018 16:21
Voted for this task.
o
#20

Enric

15.10.2018 22:05
Voted for this task.
MF
#21

Mark Fric

23.10.2018 15:26

Status changed from Confirmed to Fixed

fixed several issues and bugs with genetic evolution, it should em much more effective now.


Also, restart after finish and restart because of stagnation are now applied to every island independently, so islands don't wait for each other.


There is surely still some room for improvement, but it is a big step forward.

k
#22

Karish

24.10.2018 09:34
Voted for this task.
IH
#23

clonex / Ivan Hudec

24.10.2018 11:45
wow great sqx team !!! glad to see this fixed
MF
#24

Mark Fric

24.10.2018 14:11

Status changed from Fixed to In progress

I have to reopen it, Genetic Evolution in SQ X is still slower and less effective than in SQ3.


We made a lot of improvements, but there is still work to be done and I'll focus on this in the next build.

IH
#25

clonex / Ivan Hudec

26.10.2018 09:55
great still glad to hear that you will improve it!!!!
g
#26

geektrader

31.10.2018 09:44
Voted for this task.
OS
#27

trader4711

08.11.2018 08:01
Voted for this task.
HH
#28

Hans

20.12.2018 13:44
Voted for this task.
KO
#29

KrzysztofOzog

10.01.2019 21:17
Voted for this task.
IH
#30

clonex / Ivan Hudec

16.01.2019 14:03
Mark only for inspiration: https://pdfs.semanticscholar.org/75eb/30781a18a63a89b09af6cea9c388accac0d4.pdf



Comparison and Analysis of Different Mutation Strategies to improve the Performance of Genetic Algorithm 


MF
#31

Mark Fric

19.02.2019 14:42

Status changed from In progress to Fixed

this task is related to stagnation. 


I investigated it and found the bug - it was incorrectly updating previous fitness and so it didn't detect stagnation properly.

This is fixed now and indeed restart because of stagnation happens much more often.

KL
#32

kainc301

19.02.2019 17:32
This is great to hear! Good work @Mark and the whole SQ team

Votes: +13

Drop files to upload

or

choose files

Max size: 5MB

Not allowed: exe, msi, application, reg, php, js, htaccess, htpasswd, gitignore

...
Wait please