Class RoutePlannerBase

Class Documentation

class RoutePlannerBase

Public Functions

virtual F2CRoute genRoute(const F2CCells &cells, const F2CSwathsByCells &swaths_by_cells, bool show_log = false, double d_tol = 1e-4, bool redirect_swaths = true, long int time_limit_seconds = 1, bool search_for_optimum = false)

Generate route to cover the swaths on a field. If two consecutive swaths are far away, the route connects both through the headland.

Parameters:
  • cells – Headland swath rings used to travel through the headlands

  • swaths_by_cells – Swaths to be covered.

  • show_log – Show log from the optimizer

  • d_tol – Tolerance distance to consider if two points are the same.

  • redirect_swaths – Whether to allow redirecting swaths

  • time_limit_seconds – Maximum time to spend on optimization

  • search_for_optimum – If true, uses guided local search which may take longer but can find more optimal solutions. If false, uses automatic search which is faster but may find less optimal solutions.

Returns:

Route that covers all the swaths

void setStartAndEndPoint(const F2CPoint &p)

Set the start and the end of the route.

virtual F2CGraph2D createShortestGraph(const F2CCells &cells, const F2CSwathsByCells &swaths_by_cells, double d_tol) const

Create graph to compute the shortest path between two points in the headlands.

Parameters:
  • cells – Headland swath rings used to travel through the headlands

  • swaths_by_cells – Swaths to be covered.

  • d_tol – Tolerance distance to consider if two points are the same.

virtual F2CGraph2D createCoverageGraph(const F2CCells &cells, const F2CSwathsByCells &swaths_by_cells, F2CGraph2D &shortest_graph, double d_tol, bool redirect_swaths = true) const

Create graph to compute the cost of covering the swaths in a given order.

Parameters:
  • cells – Headland swath rings used to travel through the headlands

  • swaths_by_cells – Swaths to be covered.

  • shortest_graph – Graph to compute the shortest path between two nodes.

  • d_tol – Tolerance distance to consider if two points are the same.

virtual ~RoutePlannerBase() = default
virtual std::vector<long long int> computeBestRoute(const F2CGraph2D &cov_graph, bool show_log, long int time_limit_seconds, bool use_guided_local_search = true) const

Use the optimizer to generate the index of the points of the best coverage route.

Parameters:
  • cov_graph – Graph representing the coverage problem

  • show_log – Whether to show optimization logs

  • time_limit_seconds – Maximum time to spend on optimization

  • use_guided_local_search – If true, uses guided local search which may take longer but can find more optimal solutions. If false, uses automatic search which is faster but may find less optimal solutions.

virtual F2CRoute transformSolutionToRoute(const std::vector<long long int> &route_ids, const F2CSwathsByCells &swaths_by_cells, const F2CGraph2D &coverage_graph, F2CGraph2D &shortest_graph) const

Tranform index of points to an actual Route.

Protected Attributes

std::optional<F2CPoint> r_start_end