As mentioned. Greedy methods seldom find the global minimum. |
It will find A good solution. But is highly unlikely to find THE best solution. That is a fundamental flaw in the greedy algorithm design.
If you picked your starting airport as (B). Then you'd look for the cheapest flight from (B) to any airport that doesn't have any incoming flight (Z). Now, your "pointer" is at (Z). So you look for the cheapest flight from (Z) and build that (D). And continue on that way. So your path-ways are very well defined based on the starting location.
The greedy algorithm has no knowledge of looking ahead and saying "well, if I flew to (Y) now it's going to cost a bit more, but I can get a much cheaper flight to (X) afterwards for a lower score". Hence the name "greedy"
To optimise a function, you want to generate candidate parameters or path and then run it against a likelihood function to get a score. In your case the base score is the total cost of flights. Then you can apply penalties or bonuses based on other criteria.
e.g. You could take the top 10% flights that cost the most, and apply penalty values if any of these were used. You could also apply bonuses if the cheapest 10% were used.
However, this wouldn't work with the greedy algorithm and you'd be better off using something more adaptive (genetic, differential evolution, collective intelligence etc). Personally, I'd go with a Differential evolution style and have quite a large population (20-50) that would give me a really good solution.