Changeset 10858


Ignore:
Timestamp:
05/19/14 10:22:29 (6 years ago)
Author:
pfleck
Message:

#2182:

  • Implemented a more stable version for calculating the polar angle between two coordinates that allows calculating the angle between two locations with the same coordinates.
  • Fixed a radiant/grad bug.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Creators/PushForwardInsertionCreator.cs

    r10298 r10858  
    3333
    3434namespace HeuristicLab.Problems.VehicleRouting.Encodings.Potvin {
    35   [Item("PushForwardInsertionCreator", "Creates a randomly initialized VRP solution.")]
     35  [Item("PushForwardInsertionCreator", "The push forward insertion heuristic. It is implemented as described in Sam, and Thangiah, R. (1999). A Hybrid Genetic Algorithms, Simulated Annealing and Tabu Search Heuristic for Vehicle Routing Problems with Time Windows. Practical Handbook of Genetic Algorithms, Volume III, pp 347–381.")]
    3636  [StorableClass]
    3737  public sealed class PushForwardInsertionCreator : PotvinCreator, IStochasticOperator {
     
    138138          dueTime = 0;
    139139
    140         double dist;
    141         if (problemInstance.Coordinates[customer + depotCount - 1, 0] < x0)
    142           dist = -distance;
    143         else
    144           dist = distance;
     140        double x = problemInstance.Coordinates[customer + depotCount - 1, 0];
     141        double y = problemInstance.Coordinates[customer + depotCount - 1, 1];
    145142
    146143        double cost = alpha * distance + // distance 0 <-> City[i]
    147                    -beta * dueTime + // latest arrival time
    148                    -gamma * (Math.Asin((problemInstance.Coordinates[customer + depotCount - 1, 1] - y0) / dist) / 360 * dist); // polar angle
     144                      -beta * dueTime + // latest arrival time
     145                      -gamma * ((Math.Atan2(y - y0, x - x0) + Math.PI) / (2.0 * Math.PI) * distance); // polar angle
    149146
    150147        if (cost < minCost) {
Note: See TracChangeset for help on using the changeset viewer.