PathSolver

public class PathSolver

The PathSolver is used to take a set of locations and create an ordered list of locations that is an efficent path though a venue.

This solver cannot just give the best solution, as this a brute force solver would run in O(N!) time, which is not resonable if the number is bigger then half a dozen items.

Instead of solving the problem all at once, the solver improves the solution continuously until a good enough solution is found.

To expediate this result for users, the solver returns results periodically as it finds a better solution then the one it currently has.

If the solver fails to improve it’s solution based on it’s internal huresitcs it will give up to save the users battery life.

  • The venue we are searching

    Declaration

    Swift

    public let venue: Venue

Metal variable

  • Create a new PathSolver

    Declaration

    Swift

    public init(venue: Venue)
  • kick off the solver to find a solution

    Declaration

    Swift

    public func start(origin: Polygon,
                      toVisit: Set<Polygon>,
                      willExpire: Set<Polygon> = Set(),
                      expireTime: Float = 10 * 60)

    Parameters

    origin

    The place where the solution should start from. The solver will always make this a loop and circle back to the origin at the end.

    toVisit

    A set of polygons that should be visited in the path

    willExpire

    a set of polygons that are marked that they should be visited in under the expireTime

    expireTime

    the amount of time (in seconds) it should take to visit all of the willExpire items. / Defaults to 10 Minutes.

  • Stop the solver from searching for a solution. This will block until all thread execution have been halted.

    Declaration

    Swift

    public func stop()