|Active Topics Memberlist Search Help|
|Calculating the Coverage of Combs by your Lotto Number Set|
|LottoPoster Forums : LOTTO PROBABILITY, COVERAGE AND PROGRAMMING : Calculating the Coverage of Combs by your Lotto Number Set|
|Topic: Coverage Calculation Speed in VBA, VB, C# and C++|
Lotto Systems Tester Creator & Analyst
To dream the impossible dream ...
Joined: September 30 2004
Online Status: Offline
| Topic: Coverage Calculation Speed in VBA, VB, C# and C++
Posted: May 03 2009 at 10:02pm
The objective is to achieve a sub 1 sec time in a visual environment to calculate the coverage of say 44 45 46 47 48 49 by testing all the 13,983,816 possiblities and establishing a count of match Threes in a Pool 49, Pick 6 Lotto game. The combinations would then be flagged as covered in an array or whatever so it would be bypasses for the next combination to calculate. The algorithm you use should give an accurate count whatever the combination entered ie 260624 for the first block.
If iteration is not used then there must be a way of keeping track of what is covered for further block processing and counting the Coverage. The iteration algorithm I used to obtain these Coverage Calculation times is basically the same in all the four languages allowing for syntax differences and was supplied by Michael Harrington mentored by John Rawson in a thread I started called Coverage Calculation in VBA, VB, C# and C++ and can be viewed here. The initial times shown in the thread were based on older slower code than what I was currently using to attract more attention which it did; I had got it down to 70 sec in VBA and 7 sec in VB 2008 on a 1.8 GHz computer. Michael's times were impressively better at 6.5 sec and 0.44 sec respectively.
From the code supplied at the message board you may want to add a couple of improvements for the first two loops, as I do, to opt out when it is greater than the max integer in the block. Obviously, this will not have any effect on our test block of 44 45 46 47 48 49.
I should mention that Michael's code simply counts the extent to which a subset Three in the Play Set is in the 13,983,816 possibilities. When you are generating sets and in my case making sure a Three is not repeated the code is not as simple nor as fast.
Michael came up with a faster algorithm better than the 0.44 sec by breaking the 49c6 into 4 groups: -
This is OK for calculating 1 block - the problem still remains to keep track of what is covered for calculation on multiple blocks as the flow through the lexicographic order has been lost - so, it is still a work in progress. Maybe combinadics can be used?
The times below are adequate for my use using the iteration method.
What is your real processor speed? I downloaded this free program CPUSpeedPro and had to adjust my speed from what I thought was 2.4 GHz as shown by XP to 1.8 GHz as tested. You can access tested speeds of current and old CPU's from around the world.
Coverage Calculation Times Compared for Different Languages
1.8 GHz Est 3 GHz (x.6)
VBA 6.52 sec 3.91 sec
VB 2008 0.44 sec 0.26 sec
C# 0.64 sec 0.38 sec
C++ 4.00 sec 2.40 sec
without Boolean Vector < 0.5 sec < .5 sec
Why does C++ give such a relatively high time? If I remove the 13983816 Vector Boolean which is taking up a lot of contiguous memory it gives the fastest time. But how then does one keep track of what is covered? If you would like to give a time for the code in C++ go ahead - just let us know how fast your processor is and how large the RAM and how you are going to keep track of what is covered.
C# is managed memory and does not have to be contiguous for its arrays .
VB rules! You can get a free copy of Visual Basic Express here:
I use Visual Studio Standard which includes VB, C# and C++ with intellisense in the IDE. Study what you need and what you get before forking out for the considerably more expensive Professional edition.
nb If by the time you read this the thread at the newsgroup has gone stale you are welcome to make comments here. If you have not registered you can still comment in this forum as a guest.
On May 17th Michael Harrington published what is pretty well the final
version of the Coverage Calculation code after some mentoring by John
Rawson. The objective of an under 1 second calculation time was
achieved for not only 1 line but also 163.
Here are the times for the various languages as tested for a 1.8 GHz
1,8 GHz 3.0 GHz
VBA 3.00 sec 1.65 sec
C# 0.45 sec 0.25 sec
VB 2008 0.42 sec 0.25 sec
C++ 0.36 sec 0.20 sec
Congratulations to Michael Harrington. I for one will find some of the
Lotto Draws have no relationship to one another; the integers serve just as identifiers. Any prediction calculation on one history of draws for a same type game is just as irrelevant as another.
Joined: April 25 2005
Online Status: Offline
|Posted: August 11 2010 at 6:07pm|
Here's an interesting article related to this -> http://www.codeproject.com/KB/recipes/combinations_cpp_2.aspx.
Just me here!
|You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum