+ Reply to Thread
Results 1 to 34 of 34

Speeding up macro process (Graph algorithm stuff)

  1. #1
    Registered User
    Join Date
    05-08-2009
    Location
    Yogya
    MS-Off Ver
    Excel 2007
    Posts
    96

    Speeding up macro process (Graph algorithm stuff)

    Hi, i'm working on floyd algorithm macro for a project,
    problem is, the spreadsheet matrix is huge, it's a 1043 x 1043 spreadsheet
    And this is taking wayyy too long, i've been waiting for almost 2 days already..
    here's the file :
    http://ifile.it/6v2j39f
    (You start the macro using "run" command in "input" sheet)

    So is there any way to speed it up?
    Or if anyone got a supercomputer, could you help me process this? :p

    I'm thinking about changing the 10^5 value into infinite value, but i can't find a way to display infinite value..

    And here's some reference for Floyd's algorithm,
    http://ifile.it/12p5zle

    I have tried to split the algorithm to make it process one iteration at a time, but i've been waiting like 2 hours with no result,
    and that's for 1 iteration, can't imagine how long it takes for 1043 iterations
    You can do this by deleting the ' on this code
    Please Login or Register  to view this content.
    I'd really appreciate any help.. thanks.
    Last edited by Kb24; 07-07-2009 at 06:24 AM.

  2. #2
    Forum Contributor
    Join Date
    02-23-2006
    Location
    Near London, England
    MS-Off Ver
    Office 2003
    Posts
    770

    Re: Speeding up macro process (Graph algorithm stuff)

    Hi,

    I just wanted to check whether this line is correct in the 'Copy Weights to output sheet' section:

    Please Login or Register  to view this content.
    Referencing row 3 of that sheet causes the column header to be entered into the table, is this the intended behaviour?
    If you find the response helpful please click the scales in the blue bar above and rate it
    If you don't like the response, don't bother with the scales, they are not for you

  3. #3
    Registered User
    Join Date
    05-08-2009
    Location
    Yogya
    MS-Off Ver
    Excel 2007
    Posts
    96

    Re: Speeding up macro process (Graph algorithm stuff)

    Sorry forgot to change it, it should be :

    Please Login or Register  to view this content.

  4. #4
    Forum Contributor
    Join Date
    02-23-2006
    Location
    Near London, England
    MS-Off Ver
    Office 2003
    Posts
    770

    Re: Speeding up macro process (Graph algorithm stuff)

    After reading up some on Floyd's Algorythm, I've realised I don't understand why you have 3 matrices.
    The way I understand it Floyd's will calculate the least cost route between 2 nodes, identified by the row & column vertices of the matrix.
    Do you not just need the input matrix, and then the resulting Output Matrix? (or am I missing something? )

    Thanks

    EDIT Not to worry, I now see that one matrix is used to give the 'cost' and one gives the 'route'
    Last edited by Phil_V; 07-07-2009 at 07:27 AM.

  5. #5
    Forum Contributor
    Join Date
    02-23-2006
    Location
    Near London, England
    MS-Off Ver
    Office 2003
    Posts
    770

    Re: Speeding up macro process (Graph algorithm stuff)

    Out of interest what is the spec of the PC you are running this on?

    I have just performed some test runs on my machine:

    Intel Core 2 Duo 6300 @ 1.86GHz
    3.50 GB of RAM

    Floyd's Algorithm takes t * n^3 to run, where t is the time taken for a single vertices and n is the number of vertices.
    Based on tests of 50, 100 and 150 vertices my computer takes 47.12 micro seconds per vertices.

    Calculating this out based on your data of 1043 vertices:

    0.00004712 * 1043^3 = approx. 15 hours.

    It might be worth you running your code and setting the number of vertices to say 100 and timing how long it takes. We can then calculate how long you should EXPECT the full dataset to take.

  6. #6
    Forum Contributor
    Join Date
    02-23-2006
    Location
    Near London, England
    MS-Off Ver
    Office 2003
    Posts
    770

    Re: Speeding up macro process (Graph algorithm stuff)

    As an ammendment to the above post I forgot that timing was with various debug options enabled.

    With that removed on my PC the whole set should be done in around 7 hours.

    The modified code that I have been using is shown below. Note that I am specifying the number of Vetices in the red line of code, rather than reading it from the cell, this is purely to allow for easy testing with different quantities of Vertices.

    To 'estimate' the total time that will be taken do these steps:
    1) Set n = 100
    2) Run the macro and take a note of the time in seconds reported (t)
    3) A rough estimate of the time for the full dataset of 1043 vertices is given by:
    Please Login or Register  to view this content.
    Floyd's Algorithm Function:
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    05-08-2009
    Location
    Yogya
    MS-Off Ver
    Excel 2007
    Posts
    96

    Re: Speeding up macro process (Graph algorithm stuff)

    My PC is
    Intel Core 2 Duo T7500 2.2 Ghz
    2 GB of RAM

    I added .screenupdating = false and .calculation = manual to make it faster,
    and i just realized i miscalculated the "n", it should be 1044
    Tried running 100 matrices and i got around 2:03.. or 123 sec
    so using your formula :
    (123 / 100^3) * (1044^3) / 3600

    (0,000123) * 1137893184 = ~38 hours

    this is gonna take awhile :/

    Any other way to further optimize the speed?
    I'm thinking about changing the 10^5 values on the "input" sheet into infinity symbol.. Is it possible?
    Or is there something i could do with my PC? maybe changing the excel process priority in task manager?

    thanks your help btw..

  8. #8
    Registered User
    Join Date
    05-08-2009
    Location
    Yogya
    MS-Off Ver
    Excel 2007
    Posts
    96

    Re: Speeding up macro process (Graph algorithm stuff)

    Didn't notice you changed the code on your last post...

    it took me 59.28 sec to do 100 matrices with your code

    So 1044 matrices = ~19 hours
    Guess i''ll use this for now..
    Hopefully there'll be other way to improve the speed..

    thanks a lot for your help Phil.

  9. #9
    Forum Contributor
    Join Date
    02-23-2006
    Location
    Near London, England
    MS-Off Ver
    Office 2003
    Posts
    770

    Re: Speeding up macro process (Graph algorithm stuff)

    Hi,

    Yeah, there is quite a bit of difference between your original code and the modified code that I posted, namely the use of ranges to initialise the original matrices, which saves quite a lot of time.

    I'm not convinced that changing the 10^5 on teh input sheet to infinity would make much difference to be honest, as they only have to represent 'infinity' based on your other data. You could try using 10^8 just to be sure that your data can't reach that level, but I don't think it is a problem at the moment.

    The actual processing of the algorithm if done in the for k... for i... for j... style will always take n^3 time to complete, so all you can try and do is accelerate the speed that the function inside the loop runs at;

    Please Login or Register  to view this content.
    Looking at it though, I can't see anyway that would make a significant enough difference to make it faster.

    A couple of thoughts I had earlier though;

    * Is your input matrix always undirectional, that is mirrored around the diagonal zero line? If so it might be possible to speed up the computation by just calculating half of the resulting matrix and then reflecting that back into the corrresponding cells. I have not thought about this in any detail though, so that might not be possible.

    * Do you HAVE to use Floyd's Algorithm?
    For a sparce graph, (ie. like yours with few connecting vertices compared to the number that are infinite cost), Johnson's Algorithm is supposed to be faster. However in my brief internet search on this topic I found the information on this method to be sparse to, and it may well take longer to research and code the Johnson's method than it would to just let the Floyd's method run, especially if you are only going to be doing this one time. If of course you are running this calculation more than once then the research might be worthwhile. I don't know where you got your original Floyd's Algorithm word file of information from, but it might be worth checking that source for anything on Johnson's too. If you do get any useful information feel free to post it and I will see if we can work that into your code.

    I am quite interested in this project now that I have looked into Floyd's so would be interested to see an example of how Johnson's is implemented. The examples I have seen so far have been very poor.

  10. #10
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Speeding up macro process (Graph algorithm stuff)

    Reading the data into arrays and operating on it there might be faster.
    Entia non sunt multiplicanda sine necessitate

  11. #11
    Forum Contributor
    Join Date
    02-23-2006
    Location
    Near London, England
    MS-Off Ver
    Office 2003
    Posts
    770

    Re: Speeding up macro process (Graph algorithm stuff)

    Aha, I do that on many other projects, not sure why I didn't think of it here
    Thanks Shg, I'll give it a go and report back

  12. #12
    Registered User
    Join Date
    05-08-2009
    Location
    Yogya
    MS-Off Ver
    Excel 2007
    Posts
    96

    Re: Speeding up macro process (Graph algorithm stuff)

    Hi,
    The matrix has to be asymmetrical, because practically, there are roads (vectors) that only allow 1 way traffic..
    the flow against 1 way road is considered infinite..

    I used Floyd's because it was the only shortest path algorithm i knew that represents the final result (route) as matrix..
    and i thought time won't be an issue because it's a one time process,
    but i didn't think it would be this long :/

    I'd be interested as well if with Johnson's Algorithm we could get faster speed, but i'm actually more interested on reducing the input matrix by separating the graphs into groups..
    because that would greatly decrease the number of vertice.. and i think that's a bigger factor than time because once the iteration process is done time won't matter anymore...

    As for the book unfortunately it only mentions Dijkstra's and Floyd's..
    The book is "Operations Research : An Introduction 8th Ed" by Hamdy a Taha
    I couldn't find good exampleas well on internet, and the examples that i found don't use matrix,
    So i'm not sure if it could be applied on my case..

  13. #13
    Forum Contributor
    Join Date
    02-23-2006
    Location
    Near London, England
    MS-Off Ver
    Office 2003
    Posts
    770

    Post Re: Speeding up macro process (Graph algorithm stuff)



    Give this a go, it would seem to be the dog's doo-dahs based on the timings I am getting from it

    Thanks to Shg for the 'reminder' regarding Arrays

    The previous "Floyds" routine that I posted takes around 30 seconds to run with 100 vertices (on this PC, I have moved to my sloooow laptop )
    The new "Floyds_Arrays" routine reports a time of 0.5 seconds!
    Please let me know how you get on

    Note that the number of vertices is now entered via the use of an input box which defaults to 100, (line highlighted in red)

    Please Login or Register  to view this content.

  14. #14
    Registered User
    Join Date
    05-08-2009
    Location
    Yogya
    MS-Off Ver
    Excel 2007
    Posts
    96

    Re: Speeding up macro process (Graph algorithm stuff)

    "Excel cannot complete this task with available resources. Choose less data or other applications"

    And in debug :

    Run time error '1004'
    Application defined or object defined error

    Please Login or Register  to view this content.
    Maybe it has something to do with the 10^5 values?

  15. #15
    Forum Contributor
    Join Date
    02-23-2006
    Location
    Near London, England
    MS-Off Ver
    Office 2003
    Posts
    770

    Re: Speeding up macro process (Graph algorithm stuff)

    How many vertices were you running?
    My clapped out old laptop managed to do 255 with no problem so I am intrigued what value your's failed at?
    Does it work ok at 255 for instance?

  16. #16
    Registered User
    Join Date
    05-08-2009
    Location
    Yogya
    MS-Off Ver
    Excel 2007
    Posts
    96

    Re: Speeding up macro process (Graph algorithm stuff)

    100, i only took the first 100x100 matrix from the first excel file i posted..

  17. #17
    Forum Contributor
    Join Date
    02-23-2006
    Location
    Near London, England
    MS-Off Ver
    Office 2003
    Posts
    770

    Re: Speeding up macro process (Graph algorithm stuff)

    Ok, that is seriously confusing then

    Can you try it on the attached spreadsheet? Bearing in mind this is a subset of your data as my Excel 2003 can only handle worksheets up to 256 columns, so the largest vertices that you can do is 255.
    Attached Files Attached Files

  18. #18
    Registered User
    Join Date
    05-08-2009
    Location
    Yogya
    MS-Off Ver
    Excel 2007
    Posts
    96

    Re: Speeding up macro process (Graph algorithm stuff)

    Well it works.. but i'm not sure if it's faster, it's 2038.18 sec
    thats almost 1 sec per vertice right? 2038/255?

    FYI, the number of vertice input must always be the same with the number of matrix , so we can just refer it to
    n = Worksheets("Input").Cells(1, 8)
    Last edited by Kb24; 07-07-2009 at 05:46 PM.

  19. #19
    Forum Contributor
    Join Date
    02-23-2006
    Location
    Near London, England
    MS-Off Ver
    Office 2003
    Posts
    770

    Re: Speeding up macro process (Graph algorithm stuff)

    When you say "it works" what do you mean by "it" ?

    The new macro in your existing workbook?
    The new macro in the subset workbook that I posted?
    Something else?
    How many Vertices have you specified?

    I realise that the number of vertices is supposed to be the same as the size of the matrix, however when the processing was taking a long time it was useful to be able to tell it to only work on the first 10x10 or 50x50 or 100x100 of the input matrix to make sure all was working correctly.
    In final run you will of course need to run it over the entire matrix.

  20. #20
    Registered User
    Join Date
    05-08-2009
    Location
    Yogya
    MS-Off Ver
    Excel 2007
    Posts
    96

    Re: Speeding up macro process (Graph algorithm stuff)

    The new macro that you posted, i tested with 255 matrix.
    Oh and there's another thing that changed in route sheet,
    the diagonal vertices only list numbers instead of letter-number (e.g not T23 but 23)
    Did you change anything?

  21. #21
    Registered User
    Join Date
    05-08-2009
    Location
    Yogya
    MS-Off Ver
    Excel 2007
    Posts
    96

    Re: Speeding up macro process (Graph algorithm stuff)

    Ah i see, on that part the original code i posted was correct actually :p
    It's for filling up route vertices with the 'node' values (T23, G4,etc)


    Please Login or Register  to view this content.
    And the latest one you gave me definitely slower than the one that doesn't use arrays though..
    I tested both with 100 matrix :
    the one you posted on first page only took 59.86 sec while the one with arrays gave me 144.66 sec
    Last edited by Kb24; 07-07-2009 at 10:30 PM.

  22. #22
    Forum Contributor
    Join Date
    02-23-2006
    Location
    Near London, England
    MS-Off Ver
    Office 2003
    Posts
    770

    Post Re: Speeding up macro process (Graph algorithm stuff)



    I am now thoroughly confused!
    The most recent code I posted DOES fill the route vertices with the destination node values...
    After running the code the route table looks like the attached LCR.jpeg, if that is not correct then please explain how it should be.
    Perhaps Excel 2007 is dealing with arrays differently...

    Just so that we can be sure we are singing from the same sheet as it were can you try the following.
    I have attached my test workbook.
    Please run the 'Floyds' macro with 100 Vertices entered into the inputbox.
    This gives me the following time report:
    Time to clear: 05.19 seconds
    Time to init: 05.19 seconds
    Time to run: 21.48 seconds
    Then run the 'Floyds_Arrays' macro, again with 100 Vertices.
    This gives me the following time report:
    Time to clear: 05.25 seconds
    Time to init: 05.25 seconds
    Time to run: 00.33 seconds
    Time to txfer from Array to range: 00.03 seconds
    PLEASE post the timings you get from your computer as a comparison.

    Perhaps someone else can shed some light on why Excel 2007 seems to be so much slower dealing with the arrays than 2003 if that does prove to be the case.

    The following code is already in the example workbook attached, but is presented here also for completeness:

    Using Worksheets (no arrays)
    Please Login or Register  to view this content.
    Using Arrays
    Please Login or Register  to view this content.
    Attached Images Attached Images
    Attached Files Attached Files

  23. #23
    Registered User
    Join Date
    05-08-2009
    Location
    Yogya
    MS-Off Ver
    Excel 2007
    Posts
    96

    Re: Speeding up macro process (Graph algorithm stuff)

    Sorry i should've explained it with a pic..
    See the diagonal vertices above the diagonal zeros? there are only numbers there, it supposed to have nodes value just like my pic

    I can't use my laptop for another 10 hours because i have to get the result asap (Deadline.. )..
    So i have to use another laptop, it also uses 2007 excel, but the RAM is slightly better than mine

    1.67 Ghz Processor
    2.24 GB of RAM

    and here's the result :

    Floyd :
    Time to clear : 06.55
    Time to Init : 06.55
    Time to run : 26.22

    Floyd Array :
    Time to clear : 06.52
    Time to Init : 06.52
    Time to run : 00.50
    Time to txfer from Array to range : 00.03 sec

    ..Thats's pretty close with yours,
    but it still needs correction for the node values
    so it should be a little bit longer than this..
    Attached Images Attached Images

  24. #24
    Registered User
    Join Date
    05-08-2009
    Location
    Yogya
    MS-Off Ver
    Excel 2007
    Posts
    96

    Re: Speeding up macro process (Graph algorithm stuff)

    Wow i just realized, the floyd_array macro only needs a mere 0.5 sec?
    and that means for 1044 vertices :
    0.5/100^3 * 1044^3 = 0.15 hours ~ 9 minutes!

    Am i right? the "t" is time to run right?
    Or do we add up time to initial too?

    If its that fast , i'll repeat the macro, but i need to be sure first cause my deadline is tomorrow :]

  25. #25
    Forum Contributor
    Join Date
    02-23-2006
    Location
    Near London, England
    MS-Off Ver
    Office 2003
    Posts
    770

    Post Re: Speeding up macro process (Graph algorithm stuff)

    You are correct with your timings, now they are making more sense to me
    You can see now that the array version is much faster to process the algorithm.

    You do need to add the additional times to it, but even so the array version should be considerably faster.

    Looking at your post;
    Floyd :
    Time to clear : 06.55
    Time to Init : 06.55
    Time to run : 26.22
    So the whole thing took 6.55 + 6.55 + 26.22 seconds = 39.32 seconds

    Floyd Array :
    Time to clear : 06.52
    Time to Init : 06.52
    Time to run : 00.50
    Time to txfer from Array to range : 00.03 sec
    So the whole thing took 6.52 + 6.52 + 0.5 seconds + 0.03 = 13.57 seconds

    The thing to note here is that the 'time to clear' will be constant as it is clearing the ENTIRE data area no matter the qty of input vertices.
    So it should only be the last 3 timings that change.

    I would definitly recommend re-running it using the Array version on your full dataset.

    To fix the 'Route' situation make the following change to the macro:

    WAS:
    Please Login or Register  to view this content.
    CHANGED TO:
    Please Login or Register  to view this content.
    Fingers crossed for you. Please let me know how you / it gets on

  26. #26
    Registered User
    Join Date
    05-08-2009
    Location
    Yogya
    MS-Off Ver
    Excel 2007
    Posts
    96

    Re: Speeding up macro process (Graph algorithm stuff)

    Aw man, looks like your code won't work on large matrix...

    Tried it on my other laptop,
    and i got this message again when i try to run it with 1044 vertices:

    "Excel cannot complete this task with available resources. Choose less data or other applications"

    Run time error '1004'
    Application defined or object defined error

    Maybe it only works for excel 2003 because of the 65535 character limit?

  27. #27
    Forum Contributor
    Join Date
    02-23-2006
    Location
    Near London, England
    MS-Off Ver
    Office 2003
    Posts
    770

    Re: Speeding up macro process (Graph algorithm stuff)

    Perhaps.
    In Excel 2003 the largest Input matrix I can use from the worksheet is 255x255 as all columns after that are truncated.
    Perhaps having two 1044x1044 arrays in memory is just too much for Excel to cope with, not having a copy of 2007 available I can't shed any more light on it than that

    Do you get an option to 'Debug' when you get that error come up? If so what line is highlighted Yellow when the debug screen opens?

  28. #28
    Registered User
    Join Date
    05-08-2009
    Location
    Yogya
    MS-Off Ver
    Excel 2007
    Posts
    96

    Re: Speeding up macro process (Graph algorithm stuff)

    This one :

    Please Login or Register  to view this content.
    btw, how come you never used .Application.Calculation = xlCalculationManual
    I read somewhere it would reduce the time too..

    Oh and check your PM

  29. #29
    Forum Contributor
    Join Date
    02-23-2006
    Location
    Near London, England
    MS-Off Ver
    Office 2003
    Posts
    770

    Post Re: Speeding up macro process (Graph algorithm stuff)

    Weird, so it is at the point when it is trying to clear the Output worksheet...

    Can you try this for me please, (whether it fixes the problem or not it is faster )

    Change:
    Please Login or Register  to view this content.
    To be:
    Please Login or Register  to view this content.
    I haven't switched calculation to manual because we are performing no calculations on the worksheet itself.
    I've just tried it here just in case and it made no difference to the timings on 255 vertices.

  30. #30
    Registered User
    Join Date
    05-08-2009
    Location
    Yogya
    MS-Off Ver
    Excel 2007
    Posts
    96

    Re: Speeding up macro process (Graph algorithm stuff)

    It works! Cheers!
    Please Login or Register  to view this content.
    Sorry for late reply, i had to wait for the other one to finish..
    Now i need to check the route matrix to see if the result is correct..
    But it should be because it was ok when i tested it with a small matrix..

    Kudos to you
    thanks, you've really helped me.
    Let me know if you need another help with this algorithm.

  31. #31
    Forum Contributor
    Join Date
    02-23-2006
    Location
    Near London, England
    MS-Off Ver
    Office 2003
    Posts
    770

    Re: Speeding up macro process (Graph algorithm stuff)

    All together now...

    HOORAY!

    Glad it worked for you. 603.15, so whats that, a little over 10 minutes?
    Wow, that is some improvement over the '2 days' figure that we had when we originally started along this 'path'.
    Thankyou for presenting such an interesting problem, that has increased my knowledge of VBA and also has stirred up some interesting 'side-threads' along the way

  32. #32
    Forum Expert
    Join Date
    01-03-2006
    Location
    Waikato, New Zealand
    MS-Off Ver
    2010 @ work & 2007 @ home
    Posts
    2,243

    Re: Speeding up macro process (Graph algorithm stuff)

    Edit: HOORAY!

    Wow, there's some reading in this thread!

    KB24, can you please post the final version for curious sods like me?
    (I'm not sure if it's in the latest version, but I did notice the use of the status bar in the code of one post - if this is removed, the macro will be even faster (perhaps not "significantly" though).)

    Nice work Phil (with the reminder from Shg)

    As you said, it does stir up some interesting side threads... I've been looking into the use of arrays for faster processing of large data sets too and have come across some issues to be aware of (transpose limits, array length limits etc). On the small chance that you are interested, I've decided to post the below links (copied straight from my notes file but unsorted for total relevance here) which provide some light reading on arrays:

    'array explanations sourced from:
    'http://www.dailydoseofexcel.com/arch...ays-explained/
    'http://www.pcreview.co.uk/forums/thread-1001986.php (transpose limit of 5461 items)
    'http://support.microsoft.com/kb/177991
    'http://support.microsoft.com/?scid=kb;EN-US;153090 (basic principle of principle of Array to Range - out of date & doesn't refer to limits)
    'http://support.microsoft.com/?scid=kb;en-us;843145 (general array explanations)
    'http://babelfish.yahoo.com/translate_url?doit=done&tt=url&intl=1&fr=bf-res&trurl=http%3A%2F%2Fwww.xlam.ch%2Fxlimits%2Farrays.htm&lp=de_en&btnTrUrl=Translate (translated link to lots of Array related info)
    'http://www.dailydoseofexcel.com/arch...nge-using-vba/ (links to the next 2 URL's)
    'http://support.microsoft.com/kb/818808 ("correctly" states if (an item of the array, not entire array!) is greater than 911 characters (1/2 x 1,823))
    'http://support.microsoft.com/kb/832136 (includes 1,823 character info on Excel 2003 & 8,023 characters in 2007)
    'http://support.microsoft.com/kb/166342/ (some Excel array limits - not the char length limit though)
    'unused example from Jindon http://www.ozgrid.com/forum/showthread.php?t=57877
    'http://www.ozgrid.com/forum/showthread.php?t=65585 (another Jindon example & also Erase for arrays to free memory)
    'http://support.microsoft.com/kb/843145 (descrip of arrays in subs)
    'http://newtonexcelbach.wordpress.com...es-and-arrays/
    'http://stackoverflow.com/questions/3...hats-the-point
    '(Tushar's examples of writing to a range) http://www.mrexcel.com/forum/showthread.php?t=55175, http://www.mrexcel.com/forum/showthread.php?t=14194
    'http://www.codingforums.com/archive/...p/t-82649.html, http://www.experts-exchange.com/Soft..._24458794.html (typed arrays filled by looping)
    'http://support.microsoft.com/kb/184178/en-us (XL98: Variant Array of Dates Is Transferred to Worksheet)
    'http://www.xtremevbtalk.com/archive/...p/t-79722.html
    'http://blogs.msdn.com/excel/archive/...l.aspx#9472363
    'http://www.utteraccess.com/forums/sh...Number=1146152
    'http://www.experts-exchange.com/Prog..._20572066.html
    PROBABLE WINNER! = http://www.experts-exchange.com/Soft..._21804560.html


    Rob
    Last edited by broro183; 07-08-2009 at 08:45 PM. Reason: added a cheer ;-)
    Rob Brockett
    Kiwi in the UK
    Always learning & the best way to learn is to experience...

  33. #33
    Forum Contributor
    Join Date
    02-23-2006
    Location
    Near London, England
    MS-Off Ver
    Office 2003
    Posts
    770

    Re: Speeding up macro process (Graph algorithm stuff)

    Rob,

    Here is the latest version of the macro code. You can try commenting out the StatusBar parts, but as I only implemented it in the outer (k) loop it seems to have negligable effect from what I can tell. (Testing 255 vertices I can detect no difference over several runs with it present or removed).
    However on my PC at least, when doing a large number of vertices it seems like it suffers from the "Status bar not updating" problem anyway, so could be removed if it is of no use.
    It might be useful if KB24 could post the entire workbook though, as I only have it in '2003 format' now, which truncates his 1044x1044 dataset down to 255x1044 due to Excel's limitations, which then means the largest array you can process from the data is 255x255.

    Please Login or Register  to view this content.

  34. #34
    Forum Expert
    Join Date
    01-03-2006
    Location
    Waikato, New Zealand
    MS-Off Ver
    2010 @ work & 2007 @ home
    Posts
    2,243

    Re: Speeding up macro process (Graph algorithm stuff)

    Thanks Phil,

    I'm in the same boat as you with no current access to Excel 2007 so I can't test this in further - but then, even if I could test, it may not be worth it, because you've already done a fantastic job!

    I tried a few alternative approaches (Select Case instead of If, the below With clause, precalculating the addition of the output_matrix) to see if I could make it any faster but using the simple timer & only running for 255x255 didn't show any favourable differences*. On the other hand, I was surprised to find some small negative impacts for the latter two approaches (ignoring effects of any other concurrent processes).

    When I next have the chance to play in Excel 2007 I may remember to come back to this thread with some more detailed timing results of a larger matrix using a high performance timer (search for GetTickCount or see http://www.j-walk.com/ss/excel/eee/eee005.txt).


    Please Login or Register  to view this content.
    In fact, just out of curiosity, I'm going to try looping through the code to get average times in Excel 2000 & will probably post my comparison file tomorrow...

    Rob

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1