Wednesday, 4 December 2013

How to Write Faster Systems

In the new System Selector "Expert Mode" systems are more efficient than in the old System Selector because when you run the new systems they only test the rules you have actually written into them. With the old System Selector every rule was tested because they were all hard coded into the program (even those not being used were tested against the default values).

To speed things up in the old version some clever coding allowed the program to test for meeting and race criteria before looping through all the horse data for the meeting. Similar time savings can be achieved in "Expert Mode" but because the user now has total control over the rules, the user must "flag" the desired race and meeting rules that are to be run in advance of testing the horse and form data.

We will use our Best Bets system as follows as an example:

R:DIST<=2200
R:NREC-NUMSCR<=12
AVBASE>=56
NUMLSW>=1
Dow(V:MDATE)=7
LOCATION$"SMBAW"
H:RUNS>=1
H:POS=1
BOOK2DIV(H:PRICE)<=3

Remember that each line in the above text listing represents a system rule. Each rule is basically an item of form (either typed in or from the editor drop down) compared to a number or character string and the result of the comparison is either true or false depending on whether the horse meets the criteria or not.

Now the above system will run fine without any further modifications but it will be slower than you might expect because it is testing every horse in every race. To rectify this you need to place the meeting based rules towards the top prefixed by "1." followed by the race based rules prefixed by "2.". If you do this with the above Best Bet system you end up with the following:

1.Dow(V:MDATE)=7
1.LOCATION$"SMBAW"
2.R:DIST<=2200
2.R:NREC-NUMSCR<=12
2.AVBASE>=56
2.NUMLSW>=1
H:RUNS>=1
H:POS=1
BOOK2DIV(H:PRICE)<=3

Please note it is not essential that you do this but doing so will decrease the amount of time the test takes to run  as a result of the system skipping over a lot more meetings and races.

To put this into practice you need to have a good understanding of what meeting and race based rules are. Basically a meeting based rule is something that refers to the meeting as a whole. There are really only two of these, namely date and venue although the venue could take the form of a track name, track code or location code.

A race based rule is one that refers to a race as a whole. Most of these can be found via the Race Data drop down but there are also a few on the System Selector Data drop down (NUMSCR, NUMFUP, NUMLSW, MINSTR, AVBASE and SPFAV).

Here's anther tip that won't speed up test times but may reduce the amount of time you spend designing systems. Often you might want to temporarily add or delete rules to see where it leads. Now you can place double forward slashes (//) at the beginning of a line to comment it out so it is ignored when testing. This is great for when you want to temporarily disable a rule and later put it back in because you no longer have to write it down elsewhere or remember what it was.

You might also want to start a line with the double slashes just to provide a general comment about the system. Please note comment lines can be placed anywhere except at the beginning of your file. The first line cannot be a comment and has to be either a normal rule or a special line for constant declarations. More information on constant declarations can be found at:

Testing MyCalcs and Exotics.html

Finally please note the double slashes to identify comments must be at the beginning of a line and cannot appear part way along a line.