Free cookie consent management tool by TermsFeed Policy Generator

Changeset 7418


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

#1614

  • Added shaking operator based on n-moves
  • Added pareto analyzer regarding flowdistance and installation qualities
Location:
branches/GeneralizedQAP
Files:
7 added
8 edited

Legend:

Unmodified
Added
Removed
  • branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Views/3.3/GQAPAssignmentView.cs

    r7415 r7418  
    4646    protected override void DeregisterContentEvents() {
    4747      Content.PropertyChanged -= new PropertyChangedEventHandler(Content_PropertyChanged);
     48      Content.Solution.PropertyChanged -= new PropertyChangedEventHandler(ContentSolution_PropertyChanged);
    4849      base.DeregisterContentEvents();
    4950    }
     
    5152      base.RegisterContentEvents();
    5253      Content.PropertyChanged += new PropertyChangedEventHandler(Content_PropertyChanged);
     54      Content.Solution.PropertyChanged += new PropertyChangedEventHandler(ContentSolution_PropertyChanged);
    5355    }
    5456    #endregion
     
    5759      base.OnContentChanged();
    5860      UpdateQuality();
     61      UpdateFlowDistanceQuality();
     62      UpdateInstallationQuality();
     63      UpdateOverbookedCapacity();
    5964      UpdateAssignment();
    6065    }
     
    6772    private void Content_PropertyChanged(object sender, PropertyChangedEventArgs e) {
    6873      switch (e.PropertyName) {
     74        case "EquipmentNames": UpdateAssignment(); break;
     75        case "LocationNames": UpdateAssignment(); break;
     76        default: break;
     77      }
     78    }
     79    private void ContentSolution_PropertyChanged(object sender, PropertyChangedEventArgs e) {
     80      switch (e.PropertyName) {
    6981        case "Quality": UpdateQuality(); break;
    7082        case "FlowDistanceQuality": UpdateFlowDistanceQuality(); break;
     
    7284        case "OverbookedCapacity": UpdateOverbookedCapacity(); break;
    7385        case "Assignment": UpdateAssignment(); break;
    74         case "EquipmentNames": UpdateAssignment(); break;
    75         case "LocationNames": UpdateAssignment(); break;
    7686        default: break;
    7787      }
     
    8595          qualityLabel.Text = "-";
    8696        } else {
    87           qualityLabel.Text = Content.Quality.ToString();
     97          qualityLabel.Text = Content.Solution.Quality.ToString();
    8898        }
    8999      }
     
    93103      if (InvokeRequired) Invoke((Action)UpdateFlowDistanceQuality);
    94104      else {
    95         if (Content == null || Content.FlowDistanceQuality == null) {
     105        if (Content == null || Content.Solution.FlowDistanceQuality == null) {
    96106          flowDistanceQualityLabel.Text = "-";
    97107        } else {
    98           flowDistanceQualityLabel.Text = Content.FlowDistanceQuality.ToString();
     108          flowDistanceQualityLabel.Text = Content.Solution.FlowDistanceQuality.ToString();
    99109        }
    100110      }
     
    104114      if (InvokeRequired) Invoke((Action)UpdateInstallationQuality);
    105115      else {
    106         if (Content == null || Content.InstallationQuality == null) {
     116        if (Content == null || Content.Solution.InstallationQuality == null) {
    107117          installationQualityLabel.Text = "-";
    108118        } else {
    109           installationQualityLabel.Text = Content.InstallationQuality.ToString();
     119          installationQualityLabel.Text = Content.Solution.InstallationQuality.ToString();
    110120        }
    111121      }
     
    115125      if (InvokeRequired) Invoke((Action)UpdateOverbookedCapacity);
    116126      else {
    117         if (Content == null || Content.OverbookedCapacity == null) {
     127        if (Content == null || Content.Solution.OverbookedCapacity == null) {
    118128          overbookedCapacityLabel.Text = "-";
    119129        } else {
    120           overbookedCapacityLabel.Text = Content.OverbookedCapacity.ToString();
     130          overbookedCapacityLabel.Text = Content.Solution.OverbookedCapacity.ToString();
    121131        }
    122132      }
     
    128138        assignmentTreeView.Nodes.Clear();
    129139        if (Content != null) {
    130           IntegerVector assignment = Content.Assignment;
     140          IntegerVector assignment = Content.Solution.Assignment;
    131141          Dictionary<int, TreeNode> locationNodes = new Dictionary<int, TreeNode>();
    132142          for (int i = 0; i < assignment.Length; i++) {
  • branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Views/3.3/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Views-3.3.csproj

    r7412 r7418  
    3838  </PropertyGroup>
    3939  <ItemGroup>
     40    <Reference Include="HeuristicLab.Collections-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" />
    4041    <Reference Include="HeuristicLab.Common-3.3">
    4142      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Common-3.3.dll</HintPath>
     
    7475      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.PluginInfrastructure-3.3.dll</HintPath>
    7576    </Reference>
     77    <Reference Include="HeuristicLab.Visualization.ChartControlsExtensions-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" />
    7678    <Reference Include="System" />
    7779    <Reference Include="System.Core" />
    7880    <Reference Include="System.Drawing" />
    7981    <Reference Include="System.Windows.Forms" />
     82    <Reference Include="System.Windows.Forms.DataVisualization" />
    8083    <Reference Include="System.Xml.Linq" />
    8184    <Reference Include="System.Data.DataSetExtensions" />
     
    8588  </ItemGroup>
    8689  <ItemGroup>
     90    <Compile Include="GQAPAssignmentArchiveView.cs">
     91      <SubType>UserControl</SubType>
     92    </Compile>
     93    <Compile Include="GQAPAssignmentArchiveView.Designer.cs">
     94      <DependentUpon>GQAPAssignmentArchiveView.cs</DependentUpon>
     95    </Compile>
    8796    <Compile Include="GQAPAssignmentView.cs">
    8897      <SubType>UserControl</SubType>
     
    106115  </ItemGroup>
    107116  <ItemGroup>
     117    <EmbeddedResource Include="GQAPAssignmentArchiveView.resx">
     118      <DependentUpon>GQAPAssignmentArchiveView.cs</DependentUpon>
     119    </EmbeddedResource>
    108120    <EmbeddedResource Include="GQAPAssignmentView.resx">
    109121      <DependentUpon>GQAPAssignmentView.cs</DependentUpon>
  • 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.