Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/21/11 10:27:03 (13 years ago)
Author:
svonolfe
Message:

Added possibility to allow infeasible solutions (#1561)

Location:
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/Manipulators
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/Manipulators/PotvinManipulator.cs

    r6449 r6459  
    3535    }
    3636
     37    public IValueParameter<BoolValue> AllowInfeasibleSolutions {
     38      get { return (IValueParameter<BoolValue>)Parameters["AllowInfeasibleSolutions"]; }
     39    }
     40
     41    [StorableHook(HookType.AfterDeserialization)]
     42    private void AfterDeserialization() {
     43      // BackwardsCompatibility3.3
     44      #region Backwards compatible code (remove with 3.4)
     45      if (!Parameters.ContainsKey("AllowInfeasibleSolutions")) {
     46        Parameters.Add(new ValueParameter<BoolValue>("AllowInfeasibleSolutions", "Indicates if infeasible solutions should be allowed.", new BoolValue(false)));
     47      }
     48      #endregion
     49    }
     50
    3751    [StorableConstructor]
    3852    protected PotvinManipulator(bool deserializing) : base(deserializing) { }
     
    4256    public PotvinManipulator() {
    4357      Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator which should be used for stochastic manipulation operators."));
     58      Parameters.Add(new ValueParameter<BoolValue>("AllowInfeasibleSolutions", "Indicates if infeasible solutions should be allowed.", new BoolValue(false)));
    4459    }
    4560
     
    7590    protected static bool FindInsertionPlace(PotvinEncoding individual, int city, int routeToAvoid,
    7691      DoubleArray dueTime, DoubleArray serviceTime, DoubleArray readyTime, DoubleArray demand,
    77       DoubleValue capacity, DistanceMatrix distMatrix,
     92      DoubleValue capacity, DistanceMatrix distMatrix,  bool allowInfeasible,
    7893      out int route, out int place) {
    7994      return individual.FindInsertionPlace(
    8095        dueTime, serviceTime, readyTime,
    8196        demand, capacity, distMatrix,
    82         city, routeToAvoid, out route, out place);
     97        city, routeToAvoid, allowInfeasible,
     98        out route, out place);
    8399    }
    84100     
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/Manipulators/PotvinOneLevelExchangeManipulator.cs

    r6449 r6459  
    4242    public static void Apply(IRandom random, PotvinEncoding individual,
    4343     DoubleArray dueTime, DoubleArray readyTime, DoubleArray serviceTime, DoubleArray demand,
    44       DoubleValue capacity, DistanceMatrix distMatrix) {
     44      DoubleValue capacity, DistanceMatrix distMatrix, bool allowInfeasible) {
    4545      int selectedIndex = SelectRandomTourBiasedByLength(random, individual);
    4646      Tour route1 =
     
    5353        if (FindInsertionPlace(individual, route1.Cities[i], selectedIndex,
    5454          dueTime, serviceTime, readyTime, demand, capacity,
    55           distMatrix,
     55          distMatrix, allowInfeasible,
    5656          out insertedRoute, out insertedPlace)) {
    5757          individual.Tours[insertedRoute].Cities.Insert(insertedPlace, route1.Cities[i]);
     
    8282      DoubleValue capacity = CapacityParameter.ActualValue;
    8383
    84       Apply(random, individual, dueTime, readyTime, serviceTime, demand, capacity, distMatrix);
     84      bool allowInfeasible = AllowInfeasibleSolutions.Value.Value;
     85
     86      Apply(random, individual, dueTime, readyTime, serviceTime, demand, capacity, distMatrix, allowInfeasible);
    8587    }
    8688  }
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/Manipulators/PotvinTwoLevelExchangeManipulator.cs

    r6449 r6459  
    3939    public static void Apply(IRandom random, PotvinEncoding individual,
    4040      DoubleArray dueTime, DoubleArray readyTime, DoubleArray serviceTime, DoubleArray demand,
    41       DoubleValue capacity, DistanceMatrix distMatrix) {
     41      DoubleValue capacity, DistanceMatrix distMatrix, bool allowInfeasible) {
    4242      int selectedIndex = SelectRandomTourBiasedByLength(random, individual);
    4343      Tour route1 = individual.Tours[selectedIndex];
     
    6161                  customer2, selectedIndex,
    6262                  dueTime, serviceTime, readyTime, demand, capacity,
    63                   distMatrix,
     63                  distMatrix, allowInfeasible,
    6464                  out routeIdx, out place)) {
    6565                  individual.Tours[routeIdx].Cities.Insert(place, customer2);
     
    100100      DoubleValue capacity = CapacityParameter.ActualValue;
    101101
    102       Apply(random, individual, dueTime, readyTime, serviceTime, demand, capacity, distMatrix);
     102      bool allowInfeasible = AllowInfeasibleSolutions.Value.Value;
     103
     104      Apply(random, individual, dueTime, readyTime, serviceTime, demand, capacity, distMatrix, allowInfeasible);
    103105    }
    104106  }
Note: See TracChangeset for help on using the changeset viewer.