Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AutoDrive:dijkstra() optimization #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

DeckerMMIV
Copy link

I've reduced the number of array-lookups and did some tweaks in the function/method, which for me resulted in a speed-boost when recalculating the graph.

Using locals are quicker in LUA (link), than searching through a multi-dimensional-array, so that is why I replaced self.ad.<member> with a newPaths.<member>, and reworked usage of self.ad.Q[start][setToUse] so there is no need to do multiple lookups.

Also discovered that there is no need to make a deep-copy of the Graph into Q. An array of the 'unvisited' nodes will suffice, so that is why I've made a shallow-copy of graphinto local workGraph (previously Q), which directly references the elements in graph, as these elements are not modified when this function is doing its task.

Another trick with LUA, is that the indices of an array/table can have gaps - so it is actually not an 'array' as such. With this knowledge, I could see an optimization of the for i2 in pairs(self.ad.Q) do ... if inQ == true then, and changed it to do a direct-lookup if a wanted waypoint-id was still in the workGraph table (array).

…es and don't make deep-copies.

Also getting the actual distances between waypoints, instead of just '+1'.
@Dzi4d3k
Copy link

Dzi4d3k commented Feb 11, 2017

I can confirm that optimization works very well. On quad core Intel i7 CPU @2.90 GHz recalculation on GCV is reduced from 1:46 minutes to 19 seconds.

@streubeheubar
Copy link

Hallo an Dzi4d3K.

Besteht die Möglichkeit die geänderte Vesion von dir zu bekommen ?

mfg
Martin

@Anonymous-any
Copy link

Anonymous-any commented Feb 5, 2024

Hallo an Dzi4d3K.

Besteht die Möglichkeit die geänderte Vesion von dir zu bekommen ?

mfg Martin

Late but income, click the link below then
https://raw.githubusercontent.com/Stephan-S/AutoDrive/a0e22f793c5bf8def3be87c4f5b3bae61ecdb6c1/Mod/AutoDrive.lua

register file into browser, go to file register under and u got your "AutoDrive.lua" to replace into the .zip file mod.
Br

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants