Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/27/12 02:01:25 (13 years ago)
Author:
abeham
Message:

#1614

  • Added shaking operator based on n-moves
  • Added pareto analyzer regarding flowdistance and installation qualities
Location:
branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3
Files:
4 added
6 edited

Legend:

Unmodified
Added
Removed
  • branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/Analyzers/BestGQAPSolutionAnalyzer.cs

    r7415 r7418  
    130130    }
    131131
    132     [StorableHook(HookType.AfterDeserialization)]
    133     private void AfterDeserialization() {
    134       // BackwardsCompatibility3.3
    135       #region Backwards compatible code, remove with 3.4
    136       if (!Parameters.ContainsKey("EquipmentNames"))
    137         Parameters.Add(new LookupParameter<StringArray>("EquipmentNames", "Optional: A list of names that describes the equipments."));
    138       if (!Parameters.ContainsKey("LocationNames"))
    139         Parameters.Add(new LookupParameter<StringArray>("LocationNames", "Optional: A list of names that describes the locations."));
    140       #endregion
    141     }
    142 
    143132    public override IOperation Apply() {
    144133      var assignments = AssignmentParameter.ActualValue;
     
    172161      GQAPAssignment assignment = BestSolutionParameter.ActualValue;
    173162      if (assignment == null) {
    174         assignment = new GQAPAssignment((IntegerVector)assignments[bestIndex].Clone(), (DoubleValue)qualities[bestIndex].Clone(),
    175           equipmentNames, locationNames, distances, weights, installationCosts, demands, capacities, transportationCosts,
    176           overbookedCapacityPenalty, flowDistanceQualities[bestIndex], installationQualities[bestIndex], overbookedCapacities[bestIndex]);
     163        assignment = new GQAPAssignment((IntegerVector)assignments[bestIndex].Clone(), (DoubleValue)qualities[bestIndex].Clone(), flowDistanceQualities[bestIndex], overbookedCapacities[bestIndex], installationQualities[bestIndex], equipmentNames, locationNames, distances, weights, installationCosts, demands, capacities, transportationCosts, overbookedCapacityPenalty);
    177164        assignment.Distances = distances;
    178165        BestSolutionParameter.ActualValue = assignment;
    179166        results.Add(new Result("Best GQAP Solution", assignment));
    180167      } else {
    181         if (HasSolutionImproved(assignment.Quality.Value, qualities[bestIndex].Value, maximization)) {
    182           assignment.Assignment = (IntegerVector)assignments[bestIndex].Clone();
    183           assignment.Quality = (DoubleValue)qualities[bestIndex].Clone();
     168        if (HasSolutionImproved(assignment.Solution.Quality.Value, qualities[bestIndex].Value, maximization)) {
     169          assignment.Solution = new GQAPSolution((IntegerVector)assignments[bestIndex].Clone(),
     170            (DoubleValue)qualities[bestIndex].Clone(), (DoubleValue)flowDistanceQualities[bestIndex].Clone(),
     171            (DoubleValue)installationQualities[bestIndex].Clone(), (DoubleValue)overbookedCapacities[bestIndex].Clone());
    184172          assignment.EquipmentNames = equipmentNames;
    185173          assignment.LocationNames = locationNames;
     
    191179          assignment.TransportationCosts = transportationCosts;
    192180          assignment.OverbookedCapacityPenalty = overbookedCapacityPenalty;
    193           assignment.FlowDistanceQuality = (DoubleValue)flowDistanceQualities[bestIndex].Clone();
    194           assignment.InstallationQuality = (DoubleValue)installationQualities[bestIndex].Clone();
    195           assignment.OverbookedCapacity = (DoubleValue)overbookedCapacities[bestIndex].Clone();
    196181        }
    197182      }
  • branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/GQAPAssignment.cs

    r7415 r7418  
    3333
    3434    [Storable]
    35     private IntegerVector assignment;
    36     public IntegerVector Assignment {
    37       get { return assignment; }
     35    private GQAPSolution solution;
     36    public GQAPSolution Solution {
     37      get { return solution; }
    3838      set {
    39         bool changed = (assignment != value);
    40         assignment = value;
    41         if (changed) OnPropertyChanged("Assignment");
    42       }
    43     }
    44 
    45     [Storable]
    46     private DoubleValue quality;
    47     public DoubleValue Quality {
    48       get { return quality; }
    49       set {
    50         bool changed = (quality != value);
    51         quality = value;
    52         if (changed) OnPropertyChanged("Quality");
     39        bool changed = (solution != value);
     40        solution = value;
     41        if (changed) OnPropertyChanged("Solution");
    5342      }
    5443    }
     
    153142    }
    154143
    155     [Storable]
    156     private DoubleValue flowDistanceQuality;
    157     public DoubleValue FlowDistanceQuality {
    158       get { return flowDistanceQuality; }
    159       set {
    160         bool changed = (flowDistanceQuality != value);
    161         flowDistanceQuality = value;
    162         if (changed) OnPropertyChanged("FlowDistanceQuality");
    163       }
    164     }
    165 
    166     [Storable]
    167     private DoubleValue installationQuality;
    168     public DoubleValue InstallationQuality {
    169       get { return installationQuality; }
    170       set {
    171         bool changed = (installationQuality != value);
    172         installationQuality = value;
    173         if (changed) OnPropertyChanged("InstallationQuality");
    174       }
    175     }
    176 
    177     [Storable]
    178     private DoubleValue overbookedCapacity;
    179     public DoubleValue OverbookedCapacity {
    180       get { return overbookedCapacity; }
    181       set {
    182         bool changed = (overbookedCapacity != value);
    183         overbookedCapacity = value;
    184         if (changed) OnPropertyChanged("OverbookedCapacity");
    185       }
    186     }
    187 
    188144    [StorableConstructor]
    189145    private GQAPAssignment(bool deserializing) : base(deserializing) { }
    190146    private GQAPAssignment(GQAPAssignment original, Cloner cloner)
    191147      : base(original, cloner) {
    192       assignment = cloner.Clone(original.assignment);
    193       quality = cloner.Clone(original.quality);
    194148      equipmentNames = cloner.Clone(original.equipmentNames);
    195149      locationNames = cloner.Clone(original.locationNames);
     
    201155      transportationCosts = cloner.Clone(original.transportationCosts);
    202156      overbookedCapacityPenalty = cloner.Clone(original.overbookedCapacityPenalty);
    203       flowDistanceQuality = cloner.Clone(original.flowDistanceQuality);
    204       installationQuality = cloner.Clone(original.installationQuality);
    205       overbookedCapacity = cloner.Clone(original.overbookedCapacity);
    206157    }
    207     public GQAPAssignment(IntegerVector assignment, DoubleValue quality)
     158    public GQAPAssignment(IntegerVector assignment, DoubleValue quality, DoubleValue flowDistanceQuality, DoubleValue installationQuality, DoubleValue overbookedCapacity)
    208159      : base() {
    209       this.assignment = assignment;
    210       this.quality = quality;
     160      this.solution = new GQAPSolution(assignment, quality, flowDistanceQuality, installationQuality, overbookedCapacity);
    211161    }
    212     public GQAPAssignment(IntegerVector assignment, DoubleValue quality, StringArray equipmentNames, StringArray locationNames)
    213       : this(assignment, quality) {
    214       this.equipmentNames = equipmentNames;
    215       this.locationNames = locationNames;
    216     }
    217     public GQAPAssignment(IntegerVector assignment, DoubleValue quality, StringArray equipmentNames, StringArray locationNames,
    218       DoubleMatrix distances, DoubleMatrix weights, DoubleMatrix installationCosts, DoubleArray demands, DoubleArray capacities,
    219       DoubleValue transportationCosts, DoubleValue overbookedCapacityPenalty, DoubleValue flowDistanceQuality,
    220       DoubleValue installationQuality, DoubleValue overbookedCapacity)
    221       : this(assignment, quality, equipmentNames, locationNames) {
     162    public GQAPAssignment(IntegerVector assignment, DoubleValue quality, DoubleValue flowDistanceQuality, DoubleValue overbookedCapacity, DoubleValue installationQuality, StringArray equipmentNames, StringArray locationNames, DoubleMatrix distances, DoubleMatrix weights, DoubleMatrix installationCosts, DoubleArray demands, DoubleArray capacities, DoubleValue transportationCosts, DoubleValue overbookedCapacityPenalty)
     163      : this(assignment, quality, flowDistanceQuality, installationQuality, overbookedCapacity) {
    222164      this.distances = distances;
    223165      this.weights = weights;
     
    227169      this.transportationCosts = transportationCosts;
    228170      this.overbookedCapacityPenalty = overbookedCapacityPenalty;
    229       this.flowDistanceQuality = flowDistanceQuality;
    230       this.installationQuality = installationQuality;
    231       this.overbookedCapacity = overbookedCapacity;
    232171    }
    233172
  • branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/GeneralizedQuadraticAssignmentProblem.cs

    r7415 r7418  
    116116
    117117    public BestGQAPSolutionAnalyzer BestSolutionAnalyzer {
    118       get { return Operators.OfType<BestGQAPSolutionAnalyzer>().First(); }
     118      get { return Operators.OfType<BestGQAPSolutionAnalyzer>().FirstOrDefault(); }
     119    }
     120    public GQAPSolutionArchiveAnalyzer SolutionArchiveAnalyzer {
     121      get { return Operators.OfType<GQAPSolutionArchiveAnalyzer>().FirstOrDefault(); }
    119122    }
    120123
     
    165168
    166169      SolutionCreator.AssignmentParameter.ActualName = "Assignment";
    167       Parameterize();
    168170
    169171      InitializeOperators();
     
    212214    private void InitializeOperators() {
    213215      Operators.Add(new BestGQAPSolutionAnalyzer());
     216      Operators.Add(new GQAPSolutionArchiveAnalyzer());
    214217      Operators.AddRange(ApplicationManager.Manager.GetInstances<IGQAPOperator>());
    215218      Operators.AddRange(ApplicationManager.Manager.GetInstances<IIntegerVectorOperator>());
     
    263266      }
    264267      foreach (var op in Operators.OfType<IGQAPManipulator>()) {
    265         op.IntegerVectorParameter.ActualName = SolutionCreator.AssignmentParameter.ActualName;
     268        op.AssignmentParameter.ActualName = SolutionCreator.AssignmentParameter.ActualName;
    266269      }
    267270      foreach (var op in Operators.OfType<IGQAPMerger>()) {
     
    305308        BestSolutionAnalyzer.LocationNamesParameter.ActualName = LocationNamesParameter.Name;
    306309      }
     310      if (SolutionArchiveAnalyzer != null) {
     311        SolutionArchiveAnalyzer.MaximizationParameter.ActualName = MaximizationParameter.Name;
     312        SolutionArchiveAnalyzer.DistancesParameter.ActualName = DistancesParameter.Name;
     313        SolutionArchiveAnalyzer.WeightsParameter.ActualName = WeightsParameter.Name;
     314        SolutionArchiveAnalyzer.InstallationCostsParameter.ActualName = InstallationCostsParameter.Name;
     315        SolutionArchiveAnalyzer.DemandsParameter.ActualName = DemandsParameter.Name;
     316        SolutionArchiveAnalyzer.CapacitiesParameter.ActualName = CapacitiesParameter.Name;
     317        SolutionArchiveAnalyzer.TransportationCostsParameter.ActualName = TransportationCostsParameter.Name;
     318        SolutionArchiveAnalyzer.OverbookedCapacityPenaltyParameter.ActualName = OverbookedCapacityPenaltyParameter.Name;
     319        SolutionArchiveAnalyzer.AssignmentParameter.ActualName = SolutionCreator.AssignmentParameter.ActualName;
     320        SolutionArchiveAnalyzer.QualityParameter.ActualName = Evaluator.QualityParameter.ActualName;
     321        SolutionArchiveAnalyzer.FlowDistanceQualityParameter.ActualName = Evaluator.FlowDistanceQualityParameter.ActualName;
     322        SolutionArchiveAnalyzer.InstallationQualityParameter.ActualName = Evaluator.InstallationQualityParameter.ActualName;
     323        SolutionArchiveAnalyzer.OverbookedCapacityParameter.ActualName = Evaluator.OverbookedCapacityParameter.ActualName;
     324        SolutionArchiveAnalyzer.ResultsParameter.ActualName = "Results";
     325        SolutionArchiveAnalyzer.BestKnownQualityParameter.ActualName = BestKnownQualityParameter.Name;
     326        SolutionArchiveAnalyzer.BestKnownSolutionParameter.ActualName = BestKnownSolutionParameter.Name;
     327        SolutionArchiveAnalyzer.EquipmentNamesParameter.ActualName = EquipmentNamesParameter.Name;
     328        SolutionArchiveAnalyzer.LocationNamesParameter.ActualName = LocationNamesParameter.Name;
     329      }
    307330    }
    308331    #endregion
  • branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/HeuristicLab.Problems.GeneralizedQuadraticAssignment-3.3.csproj

    r7412 r7418  
    7070      <Private>False</Private>
    7171    </Reference>
     72    <Reference Include="HeuristicLab.Optimization.Operators-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" />
    7273    <Reference Include="HeuristicLab.Parameters-3.3">
    7374      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Parameters-3.3.dll</HintPath>
     
    8990  <ItemGroup>
    9091    <Compile Include="Analyzers\BestGQAPSolutionAnalyzer.cs" />
     92    <Compile Include="Analyzers\GQAPSolutionArchiveAnalyzer.cs" />
    9193    <Compile Include="Evaluators\GQAPNMoveEvaluator.cs" />
    9294    <Compile Include="GQAPAssignment.cs" />
     
    9496    <Compile Include="Evaluators\GQAPEvaluator.cs" />
    9597    <Compile Include="GeneralizedQuadraticAssignmentProblem.cs" />
     98    <Compile Include="GQAPAssignmentArchive.cs" />
    9699    <Compile Include="GQAPIntegerVectorProximityCalculator.cs" />
     100    <Compile Include="GQAPSolution.cs" />
    97101    <Compile Include="Interfaces\IGQAPMerger.cs" />
    98102    <Compile Include="Interfaces\IGQAPNMoveEvaluator.cs" />
     
    122126    <Compile Include="Operators\GQAPSolutionCreator.cs" />
    123127    <Compile Include="Operators\GreedyRandomizedSolutionCreator.cs" />
     128    <Compile Include="Operators\NMoveShakingOperator.cs" />
    124129    <Compile Include="Operators\QualitySimilarityMerger.cs" />
    125130    <Compile Include="Operators\RandomSolutionCreator.cs" />
  • branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/Interfaces/IGQAPManipulator.cs

    r7363 r7418  
    2727  public interface IGQAPManipulator : IGQAPOperator, IManipulator {
    2828    ILookupParameter<IRandom> RandomParameter { get; }
    29     ILookupParameter<IntegerVector> IntegerVectorParameter { get; }
     29    ILookupParameter<IntegerVector> AssignmentParameter { get; }
    3030  }
    3131}
  • branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/Operators/GQAPManipulator.cs

    r7319 r7418  
    3838      get { return (LookupParameter<IRandom>)Parameters["Random"]; }
    3939    }
    40     public ILookupParameter<IntegerVector> IntegerVectorParameter {
     40    public ILookupParameter<IntegerVector> AssignmentParameter {
    4141      get { return (ILookupParameter<IntegerVector>)Parameters["IntegerVector"]; }
    4242    }
     
    5252
    5353    public sealed override IOperation Apply() {
    54       Manipulate(RandomParameter.ActualValue, IntegerVectorParameter.ActualValue);
     54      Manipulate(RandomParameter.ActualValue, AssignmentParameter.ActualValue);
    5555      return base.Apply();
    5656    }
Note: See TracChangeset for help on using the changeset viewer.