Gamingforce Interactive Forums
85242 35212

Go Back   Exploding Garrmondo Weiner Interactive Swiss Army Penis > Garrmondo Network > Help Desk
Register FAQ GFWiki Community Donate Arcade ChocoJournal Calendar

Notices

Welcome to the Exploding Garrmondo Weiner Interactive Swiss Army Penis.
GFF is a community of gaming and music enthusiasts. We have a team of dedicated moderators, constant member-organized activities, and plenty of custom features, including our unique journal system. If this is your first visit, be sure to check out the FAQ or our GFWiki. You will have to register before you can post. Membership is completely free (and gets rid of the pesky advertisement unit underneath this message).


Matrixes and Randomization in Excel
Reply
 
Thread Tools
packrat
Mountain Chocobo


Member 8785

Level 28.07

Jun 2006


Reply With Quote
Old Jul 7, 2009, 12:44 PM 2 #1 of 21
I don't know about in excel, but I figure something like this would be very feasible in C.

A solution that I came up with was to place all your numbers into a matrix, and have another matrix of the same length defined by a 25-bit binary(0000000000000000000000001), starting with one. You multiply the sample set with your binary matrix and then sum the values in the result. Then compare the result with one of your two target values (i.e. 94,204,280).

Next would be to establish a tolerance value to eliminate blatantly wrong solutions (say 500 or so). If your first result is within 500 of your target value, then have your program complement your binary matrix, multiply with the sample set matrix, and compare the sum of the resultant matrix with your second target (70,043,499). If it too is within 500, just have it display the binary value as well as each of the differences.

The program will then increment the number defining the binary matrix (0000000000000000000000010) and start all over again, printing out all combinations that are within 500 of your targets.
Afterward, you can scan through all of your results and select the solutions that have the smallest difference values and figure out the correct combination from the associated binary matrix. If you find you have way too many solutions popping up then you can just reduce your tolerance and run the program again.

Sadly, this whole cycle will have to run about 33 million times, but I'm sure that and the associated programming are faster than checking all solutions through trial and error.

This is similar to the method Secret Squirrel suggests, except without the genetic algorithm crap. You can be your own optimizing function.

I'm sure there are many ways to streamline this process but I'll freely admit that I'm a godawful programmer.

Additional Spam:
Okay, so I ended up doing this in Matlab in a little under an hour.
Your ideal solution is probably the following:

1. 508791
3. 60642
4. 1268384
5. 1831963
8. 1079081
10. 2755461
15. 6730411
17. 9865374
20. 22983457
24. 812882
25. 22147053

The above list summed = 70043499 (exactly as desired)

and

2. 110776
6. 5141077
7. 2200967
9. 590535
11. 176599
12. 16323547
13. 1739899
14. 452583
16. 5657172
18. 561737
19. 36144212
21. 6164492
22. 8489925
23. 10450763

the above list summed = 94204284 (off by 4)

In case you are curious, here is the program that I used to get the solution:
Spoiler:

Code:
sampleset = [508791, 110776, 60642, 1268384,1831963,5141077,2200967,1079081,590535,2755461,176599,16323547,1739899,452583,6730411,5657172,9865374,561737,36144212,22983457,6164492,8489925,10450763,812882,22147053];
target1 = 94204280;
target2 = 70043499;
tolerance = 50;
limit = 33554431;

for k=1:limit; 
    binary25bit = bitget(k,1:25);
    total1 = binary25bit .* sampleset;
    sumtotal1 = sum(total1);
    Total1Diff = abs(sumtotal1 - target1);
    if (Total1Diff <= tolerance)
        total2 = ~binary25bit .* sampleset;
        sumtotal2 = sum(total2);
        Total2Diff = abs(sumtotal2 - target2);
        
        if (Total2Diff <= tolerance)
           disp(binary25bit);
           disp(Total1Diff);
           disp(Total2Diff);
        end
    end
    
    
    
end


Jam it back in, in the dark.


Last edited by packrat; Jul 7, 2009 at 04:20 PM. Reason: This member got a little too post happy.
packrat
Mountain Chocobo


Member 8785

Level 28.07

Jun 2006


Reply With Quote
Old Jul 7, 2009, 08:20 PM 1 #2 of 21
The script I posted is a brute force method which basically just avoids the comparative step Araes mentioned.

And yes, in my case, the limit variable is determined by the number of elements in your array. (you had 25, so 2^25 - 1 = 33554431)
Here are a few modifications to the script I posted that will make it easier to scale to different data sets:

Spoiler:

Code:
sampleset = [508791, 110776, 60642, 1268384,1831963,5141077,2200967,1079081,590535,2755461,176599,16323547,1739899,452583,6730411,5657172,9865374,561737,36144212,22983457,6164492,8489925,10450763,812882,22147053];
target1 = 94204280;
target2 = 70043499;
tolerance = 50;
samplenumber = numel(sampleset);
limit = (2^samplenumber)-1;

for k=1:limit; 
    binarymultiplier = bitget(k,1:samplenumber);
    total1 = binarymultiplier .* sampleset;
    sumtotal1 = sum(total1);
    Total1Diff = abs(sumtotal1 - target1);
    if (Total1Diff <= tolerance)
        total2 = ~binarymultiplier .* sampleset;
        sumtotal2 = sum(total2);
        Total2Diff = abs(sumtotal2 - target2);
        
        if (Total2Diff <= tolerance)
           disp(binarymultiplier);
           disp(Total1Diff);
           disp(Total2Diff);
        end
    end
end

As stated earlier, this is a brute-force method that computes through every possible combination and then displays only those within a given tolerance value. Final discretion is left to the operator.
When I ran this program, it was probably only 1/4 of the way through when it output a combination that gave differences of 0 and 4. I just stopped it there and recorded the combination, since I doubt you could get much better than that.

I figure this script could actually be ported to C/C++, but I'm not the person to do that.

There's nowhere I can't reach.

Reply


Exploding Garrmondo Weiner Interactive Swiss Army Penis > Garrmondo Network > Help Desk > Matrixes and Randomization in Excel

Forum Jump


All times are GMT -5. The time now is 09:06 AM.


Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2026, vBulletin Solutions, Inc.