Free cookie consent management tool by TermsFeed Policy Generator

Changeset 10060 for branches


Ignore:
Timestamp:
10/17/13 16:34:53 (11 years ago)
Author:
ascheibe
Message:

#1886

  • added point calculation from distance matrices
  • added convex hull algorithm based on LP (work in progress)
  • added unit tests
Location:
branches/HeuristicLab.Analysis.AlgorithmBehavior
Files:
6 added
8 edited
1 moved

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Analysis.AlgorithmBehavior/AlgorithmBehaviorUnitTests/AlgorithmBehaviorUnitTests.csproj

    r10026 r10060  
    7676  </Choose>
    7777  <ItemGroup>
    78     <Compile Include="UnitTest2.cs" />
     78    <Compile Include="LPConvexHullSortingTest.cs" />
     79    <Compile Include="LPConvexHullTest.cs" />
     80    <Compile Include="PermutationCacheTest.cs" />
     81    <Compile Include="DistanceMatrixToPointsTest.cs" />
    7982    <Compile Include="Properties\AssemblyInfo.cs" />
    8083    <Compile Include="ConvexHullTest.cs" />
  • branches/HeuristicLab.Analysis.AlgorithmBehavior/AlgorithmBehaviorUnitTests/PermutationCacheTest.cs

    r10048 r10060  
    1 using System.Linq;
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 *
     5 * This file is part of HeuristicLab.
     6 *
     7 * HeuristicLab is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 3 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * HeuristicLab is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19 */
     20#endregion
     21
     22using System.Linq;
    223using HeuristicLab.Analysis.SolutionCaching;
    324using HeuristicLab.Analysis.SolutionCaching.PermutationEncoding;
     
    728namespace AlgorithmBehaviorUnitTests {
    829  [TestClass]
    9   public class UnitTest2 {
     30  public class PermutationCacheTest {
    1031    [TestMethod]
    1132    public void TestPermutationSolutionDictionary() {
  • branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers.Views/3.3/ConvexHullView.Designer.cs

    r10027 r10060  
    4040      // resultsTextBox
    4141      //
    42       this.resultsTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    43             | System.Windows.Forms.AnchorStyles.Left)
     42      this.resultsTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
     43            | System.Windows.Forms.AnchorStyles.Left) 
    4444            | System.Windows.Forms.AnchorStyles.Right)));
    4545      this.resultsTextBox.Location = new System.Drawing.Point(3, 33);
     
    6464    #endregion
    6565
    66     private System.Windows.Forms.Button testConvexHullButton;
    67     private System.Windows.Forms.TextBox resultsTextBox;
     66    protected System.Windows.Forms.Button testConvexHullButton;
     67    protected System.Windows.Forms.TextBox resultsTextBox;
    6868
    6969  }
  • branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers.Views/3.3/ConvexHullView.cs

    r10027 r10060  
    4242    }
    4343
    44     protected void testConvexHullButton_Click(object sender, System.EventArgs e) {
     44    protected virtual void testConvexHullButton_Click(object sender, System.EventArgs e) {
    4545      for (int i = 0; i < 20; i++) {
    4646        var sols = Content.GetSolutionsFromGeneration(i);
  • branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers.Views/3.3/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers.Views-3.3.csproj

    r10027 r10060  
    9393      <Private>False</Private>
    9494    </Reference>
     95    <Reference Include="HeuristicLab.Optimization.Operators-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     96      <SpecificVersion>False</SpecificVersion>
     97      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Optimization.Operators-3.3.dll</HintPath>
     98      <Private>False</Private>
     99    </Reference>
    95100    <Reference Include="HeuristicLab.Optimization.Views-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    96101      <Private>False</Private>
     
    117122      <SpecificVersion>False</SpecificVersion>
    118123      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Problems.Instances-3.3.dll</HintPath>
     124      <Private>False</Private>
     125    </Reference>
     126    <Reference Include="HeuristicLab.Problems.TravelingSalesman-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     127      <SpecificVersion>False</SpecificVersion>
     128      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Problems.TravelingSalesman-3.3.dll</HintPath>
    119129      <Private>False</Private>
    120130    </Reference>
  • branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers.Views/3.3/PermutationConvexHullView.cs

    r10027 r10060  
    2020#endregion
    2121
     22using System;
    2223using System.Linq;
    2324using HeuristicLab.Analysis.SolutionCaching.PermutationEncoding;
    2425using HeuristicLab.Encodings.PermutationEncoding;
    2526using HeuristicLab.MainForm;
     27using HeuristicLab.Problems.TravelingSalesman;
    2628
    2729namespace HeuristicLab.Analysis.AlgorithmBehavior.Analyzers.Views {
     
    3436      return vertex;
    3537    }
     38
     39    protected override void testConvexHullButton_Click(object sender, System.EventArgs e) {
     40      for (int i = 0; i < 20; i++) {
     41        var sols = Content.GetSolutionsFromGeneration(i);
     42        //double[][] pop = sols.Select(x => ConvertPermutationToVertex(x)).ToArray(); 
     43        //TODO: simCalculators should be somehow be selected based on problem
     44
     45        double[][] dm = new double[sols.Count][];
     46        for (int j = 0; j < sols.Count; j++) {
     47          dm[j] = new double[sols.Count];
     48        }
     49
     50        for (int j = 0; j < sols.Count; j++) {
     51          for (int k = 0; k < sols.Count; k++) {
     52            dm[j][k] = TSPSimilarityCalculator.CalculateSimilarity(sols[j], sols[k]);
     53          }
     54        }
     55
     56        double[][] popPoints = DistanceMatrixToPoints.ConvertDistanceMatrixToPoints(dm);
     57
     58        var convexHull = HyperHull.CalculateUsingSMO(popPoints);
     59        resultsTextBox.Text += "Nr. of Points in Generation " + i + ": " + convexHull.Count + Environment.NewLine;
     60        resultsTextBox.Text += "Volume of Convex Hull in Generation " + i + " is: " +
     61                               ConvexHullMeasures.CalculateVolume(convexHull) + Environment.NewLine;
     62      }
     63    }
    3664  }
    3765}
  • branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers/3.3/ConvexHullMeasures.cs

    r10008 r10060  
    5151    }
    5252
    53     //calculate inner point for boundary triangulation (slowwwww.....)
     53    //calculate center for boundary triangulation (slowwwww.....)
    5454    private static double[] CalculateInnerPoint(List<double[]> hyperHull) {
    5555      double[] result = new double[hyperHull[0].Count()];
    5656
    5757      for (int i = 0; i < hyperHull[0].Count(); i++) {
    58         result[i] = hyperHull.Max(x => x[i]) - hyperHull.Min(x => x[i]);
     58        result[i] = (hyperHull.Max(x => x[i]) + hyperHull.Min(x => x[i])) / 2.0;
    5959      }
    6060
  • branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers/3.3/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers-3.3.csproj

    r10026 r10060  
    118118  </ItemGroup>
    119119  <ItemGroup>
     120    <Compile Include="DistanceMatrixToPoints.cs" />
     121    <Compile Include="VertexComparer.cs" />
    120122    <Compile Include="CombinedOperator.cs" />
    121123    <Compile Include="AlgorithmBehaviorHelpers.cs" />
     
    133135    <Compile Include="ConvexHullMeasures.cs" />
    134136    <Compile Include="IntegerExtensions.cs" />
     137    <Compile Include="LPHull.cs" />
    135138    <Compile Include="SelectionPressureAnalyzer.cs" />
    136139    <Compile Include="SVM.cs" />
  • branches/HeuristicLab.Analysis.AlgorithmBehavior/MIConvexHull/MIConvexHull.csproj

    r9730 r10060  
    3030    <DebugType>full</DebugType>
    3131    <Optimize>false</Optimize>
    32     <OutputPath>..\..\..\..\trunk\sources\bin\</OutputPath>
     32    <OutputPath>..\..\..\trunk\sources\bin\</OutputPath>
    3333    <DefineConstants>DEBUG;TRACE</DefineConstants>
    3434    <ErrorReport>prompt</ErrorReport>
     
    3838    <DebugType>pdbonly</DebugType>
    3939    <Optimize>true</Optimize>
    40     <OutputPath>..\..\..\..\trunk\sources\bin\</OutputPath>
     40    <OutputPath>..\..\..\trunk\sources\bin\</OutputPath>
    4141    <DefineConstants>TRACE</DefineConstants>
    4242    <ErrorReport>prompt</ErrorReport>
Note: See TracChangeset for help on using the changeset viewer.