Although Dispatcher offers a variety of predefined heuristics for use in generating a first solution, the process of writing a simple one gives you a better understanding of the concepts. Knowing how to write your own first solution heuristic can also be useful when facing certain specific problems that the predefined heuristics do not cover. This section describes how to write your own efficient search goal based on a greedy addition heuristic.
To show how to create your own first solution heuristic, you will solve a PDP problem. Except for the custom first solution heuristic, you will model and solve this problem in the same way as shown in Lesson 7, Pickup and Delivery Problems. The only difference is that you create your own first solution goal and that you call this goal in the RoutingSolver::solve
function instead of a predefined first solution goal. Only the changed parts of the example are shown in this section. You can view the complete program and output online in the YourDispatcherHome/examples/src/firstsol.cpp
file.