Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/14/12 18:58:15 (12 years ago)
Author:
gkronber
Message:

#1847 merged r8205:8635 from trunk into branch

Location:
branches/GP-MoveOperators
Files:
6 edited
3 copied

Legend:

Unmodified
Added
Removed
  • branches/GP-MoveOperators

  • branches/GP-MoveOperators/HeuristicLab.Problems.TravelingSalesman/3.3/Evaluators/TSPDistanceMatrixEvaluator.cs

    r7558 r8660  
    5959      if (distances == null || distances.Rows == 0 || distances.Columns == 0
    6060        || distances.Rows != distances.Columns)
    61         throw new InvalidOperationException("The distance matrix is empty or not square");
    62       if (tour == null) throw new ArgumentNullException("tour", "No tour is given.");
     61        throw new InvalidOperationException("TSPDistanceMatrixEvaluator: The distance matrix is empty or not square");
     62      if (tour == null) throw new ArgumentNullException("tour", "TSPDistanceMatrixEvaluator: No tour is given.");
    6363      Permutation p = tour;
    6464      double length = 0;
  • branches/GP-MoveOperators/HeuristicLab.Problems.TravelingSalesman/3.3/HeuristicLab.Problems.TravelingSalesman-3.3.csproj

    r7646 r8660  
    108108    <Reference Include="System.Data" />
    109109    <Reference Include="System.Drawing" />
     110    <Reference Include="System.Windows.Forms" />
    110111    <Reference Include="System.Xml" />
    111112  </ItemGroup>
     
    118119    <Compile Include="Evaluators\TSPEuclideanPathEvaluator.cs" />
    119120    <Compile Include="Evaluators\TSPGeoPathEvaluator.cs" />
     121    <Compile Include="Improvers\TSPImprovementOperator.cs" />
    120122    <Compile Include="Interfaces\ITSPDistanceMatrixEvaluator.cs" />
    121123    <Compile Include="MoveEvaluators\ThreeOpt\TSPTranslocationMoveEuclideanPathEvaluator.cs" />
     
    127129    <Compile Include="MoveEvaluators\TwoOpt\TSPInversionMovePathEvaluator.cs" />
    128130    <Compile Include="MoveEvaluators\TwoOpt\TSPInversionMoveRoundedEuclideanPathEvaluator.cs" />
     131    <Compile Include="PathRelinkers\TSPMultipleGuidesPathRelinker.cs" />
     132    <Compile Include="PathRelinkers\TSPPathRelinker.cs" />
     133    <Compile Include="PathRelinkers\TSPSimultaneousPathRelinker.cs" />
    129134    <Compile Include="Plugin.cs" />
     135    <Compile Include="SimilarityCalculators\TSPSimilarityCalculator.cs" />
    130136    <Compile Include="TravelingSalesmanProblem.cs" />
    131137    <Compile Include="PathTSPTour.cs" />
     
    182188      <Name>HeuristicLab.Operators-3.3</Name>
    183189      <Private>False</Private>
     190    </ProjectReference>
     191    <ProjectReference Include="..\..\HeuristicLab.Optimization.Operators\3.3\HeuristicLab.Optimization.Operators-3.3.csproj">
     192      <Project>{25087811-F74C-4128-BC86-8324271DA13E}</Project>
     193      <Name>HeuristicLab.Optimization.Operators-3.3</Name>
    184194    </ProjectReference>
    185195    <ProjectReference Include="..\..\HeuristicLab.Optimization\3.3\HeuristicLab.Optimization-3.3.csproj">
     
    240250  -->
    241251  <PropertyGroup>
    242     <PreBuildEvent>set Path=%25Path%25;$(ProjectDir);$(SolutionDir)
     252   <PreBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">set Path=%25Path%25;$(ProjectDir);$(SolutionDir)
    243253set ProjectDir=$(ProjectDir)
    244254set SolutionDir=$(SolutionDir)
     
    247257call PreBuildEvent.cmd
    248258</PreBuildEvent>
     259<PreBuildEvent Condition=" '$(OS)' != 'Windows_NT' ">
     260export ProjectDir=$(ProjectDir)
     261export SolutionDir=$(SolutionDir)
     262
     263$SolutionDir/PreBuildEvent.sh
     264</PreBuildEvent>
    249265  </PropertyGroup>
    250266</Project>
  • branches/GP-MoveOperators/HeuristicLab.Problems.TravelingSalesman/3.3/Plugin.cs.frame

    r7558 r8660  
    2626  /// Plugin class for HeuristicLab.Problems.TravelingSalesman plugin
    2727  /// </summary>
    28   [Plugin("HeuristicLab.Problems.TravelingSalesman", "3.3.6.$WCREV$")]
     28  [Plugin("HeuristicLab.Problems.TravelingSalesman", "3.3.7.$WCREV$")]
    2929  [PluginFile("HeuristicLab.Problems.TravelingSalesman-3.3.dll", PluginFileType.Assembly)]
    3030  [PluginDependency("HeuristicLab.Analysis", "3.3")]
     
    3737  [PluginDependency("HeuristicLab.Operators", "3.3")]
    3838  [PluginDependency("HeuristicLab.Optimization", "3.3")]
     39  [PluginDependency("HeuristicLab.Optimization.Operators", "3.3")]
    3940  [PluginDependency("HeuristicLab.Parameters", "3.3")]
    4041  [PluginDependency("HeuristicLab.Persistence", "3.3")]
  • branches/GP-MoveOperators/HeuristicLab.Problems.TravelingSalesman/3.3/Properties/AssemblyInfo.cs.frame

    r7259 r8660  
    5353// by using the '*' as shown below:
    5454[assembly: AssemblyVersion("3.3.0.0")]
    55 [assembly: AssemblyFileVersion("3.3.6.$WCREV$")]
     55[assembly: AssemblyFileVersion("3.3.7.$WCREV$")]
  • branches/GP-MoveOperators/HeuristicLab.Problems.TravelingSalesman/3.3/TravelingSalesmanProblem.cs

    r8085 r8660  
    2424using System.IO;
    2525using System.Linq;
     26using HeuristicLab.Analysis;
    2627using HeuristicLab.Common;
    2728using HeuristicLab.Core;
     
    8485      get { return Operators.OfType<TSPPopulationDiversityAnalyzer>().FirstOrDefault(); }
    8586    }
     87    private SingleObjectivePopulationDiversityAnalyzer SingleObjectivePopulationDiversityAnalyzer {
     88      get { return Operators.OfType<SingleObjectivePopulationDiversityAnalyzer>().FirstOrDefault(); }
     89    }
    8690    #endregion
    8791
     
    112116      Parameters.Add(new OptionalValueParameter<DoubleMatrix>("Coordinates", "The x- and y-Coordinates of the cities."));
    113117      Parameters.Add(new OptionalValueParameter<DistanceMatrix>("DistanceMatrix", "The matrix which contains the distances between the cities."));
    114       Parameters.Add(new ValueParameter<BoolValue>("UseDistanceMatrix", "True if a distance matrix should be calculated and used for evaluation, otherwise false.", new BoolValue(true)));
     118      Parameters.Add(new ValueParameter<BoolValue>("UseDistanceMatrix", "True if the coordinates based evaluators should calculate the distance matrix from the coordinates and use it for evaluation similar to the distance matrix evaluator, otherwise false.", new BoolValue(true)));
    115119      Parameters.Add(new OptionalValueParameter<Permutation>("BestKnownSolution", "The best known solution of this TSP instance."));
    116120
    117121      Maximization.Value = false;
    118122      MaximizationParameter.Hidden = true;
     123      UseDistanceMatrixParameter.Hidden = true;
    119124      DistanceMatrixParameter.ReactOnValueToStringChangedAndValueItemImageChanged = false;
    120125
     
    151156      UpdateMoveEvaluators();
    152157      ParameterizeAnalyzers();
    153       ClearDistanceMatrix();
     158      if (Evaluator is ITSPCoordinatesPathEvaluator && Coordinates != null)
     159        ClearDistanceMatrix();
    154160    }
    155161    private void CoordinatesParameter_ValueChanged(object sender, EventArgs e) {
     
    158164        Coordinates.Reset += new EventHandler(Coordinates_Reset);
    159165      }
    160       ParameterizeSolutionCreator();
    161       ClearDistanceMatrix();
     166      if (Evaluator is ITSPCoordinatesPathEvaluator) {
     167        ParameterizeSolutionCreator();
     168        ClearDistanceMatrix();
     169      }
    162170    }
    163171    private void Coordinates_ItemChanged(object sender, EventArgs<int, int> e) {
    164       ClearDistanceMatrix();
     172      if (Evaluator is ITSPCoordinatesPathEvaluator) {
     173        ClearDistanceMatrix();
     174      }
    165175    }
    166176    private void Coordinates_Reset(object sender, EventArgs e) {
    167       ParameterizeSolutionCreator();
    168       ClearDistanceMatrix();
     177      if (Evaluator is ITSPCoordinatesPathEvaluator) {
     178        ParameterizeSolutionCreator();
     179        ClearDistanceMatrix();
     180      }
    169181    }
    170182    private void SolutionCreator_PermutationParameter_ActualNameChanged(object sender, EventArgs e) {
     
    222234
    223235    private void InitializeOperators() {
     236      Operators.Add(new TSPImprovementOperator());
     237      Operators.Add(new TSPMultipleGuidesPathRelinker());
     238      Operators.Add(new TSPPathRelinker());
     239      Operators.Add(new TSPSimultaneousPathRelinker());
     240      Operators.Add(new TSPSimilarityCalculator());
     241
    224242      Operators.Add(new BestTSPSolutionAnalyzer());
    225243      Operators.Add(new TSPAlleleFrequencyAnalyzer());
    226       Operators.Add(new TSPPopulationDiversityAnalyzer());
     244      Operators.Add(new SingleObjectivePopulationDiversityAnalyzer());
    227245      ParameterizeAnalyzers();
    228246      var operators = new HashSet<IPermutationOperator>(new IPermutationOperator[] {
     
    251269      else if (Evaluator is ITSPCoordinatesPathEvaluator && Coordinates != null)
    252270        SolutionCreator.LengthParameter.Value = new IntValue(Coordinates.Rows);
    253       else SolutionCreator.LengthParameter.Value = null;
     271      else {
     272        SolutionCreator.LengthParameter.Value = null;
     273        string error = "The given problem does not support the selected evaluator.";
     274        if (Evaluator is ITSPDistanceMatrixEvaluator)
     275          error += Environment.NewLine + "Please review that the " + DistanceMatrixParameter.Name + " parameter is defined or choose another evaluator.";
     276        else error += Environment.NewLine + "Please review that the " + CoordinatesParameter.Name + " parameter is defined or choose another evaluator.";
     277        PluginInfrastructure.ErrorHandling.ShowErrorDialog(error, null);
     278      }
    254279      SolutionCreator.LengthParameter.Hidden = SolutionCreator.LengthParameter.Value != null;
    255280      SolutionCreator.PermutationTypeParameter.Value = new PermutationType(PermutationTypes.RelativeUndirected);
     
    303328        TSPPopulationDiversityAnalyzer.QualityParameter.ActualName = Evaluator.QualityParameter.ActualName;
    304329        TSPPopulationDiversityAnalyzer.ResultsParameter.ActualName = "Results";
     330      }
     331
     332      if (SingleObjectivePopulationDiversityAnalyzer != null) {
     333        SingleObjectivePopulationDiversityAnalyzer.MaximizationParameter.ActualName = MaximizationParameter.Name;
     334        SingleObjectivePopulationDiversityAnalyzer.QualityParameter.ActualName = Evaluator.QualityParameter.ActualName;
     335        SingleObjectivePopulationDiversityAnalyzer.ResultsParameter.ActualName = "Results";
     336        SingleObjectivePopulationDiversityAnalyzer.SimilarityCalculator = Operators.OfType<TSPSimilarityCalculator>().SingleOrDefault();
    305337      }
    306338    }
     
    336368        op.PermutationParameter.Hidden = true;
    337369      }
     370      foreach (ISingleObjectiveImprovementOperator op in Operators.OfType<ISingleObjectiveImprovementOperator>()) {
     371        op.SolutionParameter.ActualName = SolutionCreator.PermutationParameter.ActualName;
     372        op.SolutionParameter.Hidden = true;
     373      }
     374      foreach (ISingleObjectivePathRelinker op in Operators.OfType<ISingleObjectivePathRelinker>()) {
     375        op.ParentsParameter.ActualName = SolutionCreator.PermutationParameter.ActualName;
     376        op.ParentsParameter.Hidden = true;
     377      }
     378      foreach (TSPSimilarityCalculator op in Operators.OfType<TSPSimilarityCalculator>()) {
     379        op.SolutionVariableName = SolutionCreator.PermutationParameter.ActualName;
     380        op.QualityVariableName = Evaluator.QualityParameter.ActualName;
     381      }
    338382    }
    339383
    340384    private void ClearDistanceMatrix() {
    341       if (!(Evaluator is ITSPDistanceMatrixEvaluator))
    342         DistanceMatrixParameter.Value = null;
     385      DistanceMatrixParameter.Value = null;
    343386    }
    344387    #endregion
     
    358401      Description = data.Description;
    359402
     403      bool clearCoordinates = false, clearDistanceMatrix = false;
    360404      if (data.Coordinates != null && data.Coordinates.GetLength(0) > 0)
    361405        Coordinates = new DoubleMatrix(data.Coordinates);
    362       else Coordinates = null;
     406      else clearCoordinates = true;
    363407
    364408      TSPEvaluator evaluator;
     
    375419        DistanceMatrix = new DistanceMatrix(data.Distances);
    376420      } else {
    377         DistanceMatrix = null;
     421        clearDistanceMatrix = true;
    378422        UseDistanceMatrix = new BoolValue(data.Dimension <= DistanceMatrixSizeLimit);
    379423        switch (data.DistanceMeasure) {
     
    394438      Evaluator = evaluator;
    395439
     440      // reset them after assigning the evaluator
     441      if (clearCoordinates) Coordinates = null;
     442      if (clearDistanceMatrix) DistanceMatrix = null;
     443
    396444      BestKnownSolution = null;
    397445      BestKnownQuality = null;
     
    400448        try {
    401449          EvaluateAndLoadTour(data.BestKnownTour);
    402         }
    403         catch (InvalidOperationException) {
     450        } catch (InvalidOperationException) {
    404451          if (data.BestKnownQuality.HasValue)
    405452            BestKnownQuality = new DoubleValue(data.BestKnownQuality.Value);
Note: See TracChangeset for help on using the changeset viewer.