Free cookie consent management tool by TermsFeed Policy Generator

Changeset 3155 for trunk


Ignore:
Timestamp:
03/22/10 01:41:59 (15 years ago)
Author:
swagner
Message:

Added additional TSP evaluation operators (#924).

Location:
trunk/sources/HeuristicLab.Problems.TSP/3.3
Files:
4 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.TSP/3.3/Evaluators/TSPEvaluator.cs

    r3048 r3155  
    3333  [StorableClass]
    3434  public abstract class TSPEvaluator : SingleSuccessorOperator, ITSPEvaluator {
     35    public override bool CanChangeName {
     36      get { return false; }
     37    }
     38
    3539    public ILookupParameter<DoubleValue> QualityParameter {
    3640      get { return (ILookupParameter<DoubleValue>)Parameters["Quality"]; }
  • trunk/sources/HeuristicLab.Problems.TSP/3.3/HeuristicLab.Problems.TSP-3.3.csproj

    r3153 r3155  
    8484  </ItemGroup>
    8585  <ItemGroup>
     86    <Compile Include="Evaluators\TSPEuclideanPathEvaluator.cs" />
     87    <Compile Include="Evaluators\TSPGeoPathEvaluator.cs" />
    8688    <Compile Include="TSPLIBTourParser.cs" />
    8789    <Compile Include="Interfaces\ICoordinatesTSPSolutionsVisualizer.cs" />
     
    159161    <None Include="ch130.tsp" />
    160162    <None Include="fl1400.tsp" />
     163    <None Include="gr666.opt.tour" />
     164    <None Include="gr666.tsp" />
    161165    <None Include="HeuristicLab.snk" />
    162166    <None Include="HeuristicLabProblemsTSPPlugin.cs.frame" />
  • trunk/sources/HeuristicLab.Problems.TSP/3.3/TSP.cs

    r3153 r3155  
    178178      if (!string.IsNullOrEmpty(tspParser.Comment)) Description = tspParser.Comment;
    179179      Coordinates = new DoubleMatrix(tspParser.Vertices);
     180      if (tspParser.WeightType == TSPLIBParser.TSPLIBEdgeWeightType.EUC_2D) {
     181        TSPRoundedEuclideanPathEvaluator evaluator = new TSPRoundedEuclideanPathEvaluator();
     182        evaluator.QualityParameter.ActualName = "TSPTourLength";
     183        Evaluator = evaluator;
     184      } else if (tspParser.WeightType == TSPLIBParser.TSPLIBEdgeWeightType.GEO) {
     185        TSPGeoPathEvaluator evaluator = new TSPGeoPathEvaluator();
     186        evaluator.QualityParameter.ActualName = "TSPTourLength";
     187        Evaluator = evaluator;
     188      }
    180189      BestKnownQuality = null;
    181190      BestKnownSolution = null;
     191
    182192      if (!string.IsNullOrEmpty(optimalTourFileName)) {
    183193        TSPLIBTourParser tourParser = new TSPLIBTourParser(optimalTourFileName);
  • trunk/sources/HeuristicLab.Problems.TSP/3.3/TSPLIBParser.cs

    r3151 r3155  
    2929  /// </summary>
    3030  public class TSPLIBParser {
     31    #region Inner Enum TSPLIBEdgeWeightType
     32    public enum TSPLIBEdgeWeightType {
     33      UNDEFINED,
     34      EUC_2D,
     35      GEO
     36    }
     37    #endregion
     38
    3139    private const int EOF = 0;
    3240    private const int NAME = 1;
     
    6169      get { return vertices; }
    6270    }
    63     private int weightType;
     71    private TSPLIBEdgeWeightType weightType;
    6472    /// <summary>
    6573    /// Gets the weight type of the parsed TSP.
    6674    /// </summary>
    67     public int WeightType {
     75    public TSPLIBEdgeWeightType WeightType {
    6876      get { return weightType; }
    6977    }
     
    8391      comment = string.Empty;
    8492      vertices = null;
    85       weightType = -1;
     93      weightType = TSPLIBEdgeWeightType.UNDEFINED;
    8694    }
    8795
     
    193201
    194202      if (type.Equals("euc_2d", StringComparison.OrdinalIgnoreCase))
    195         weightType = 0;
     203        weightType = TSPLIBEdgeWeightType.EUC_2D;
    196204      else if (type.Equals("geo", StringComparison.OrdinalIgnoreCase))
    197         weightType = 1;
     205        weightType = TSPLIBEdgeWeightType.GEO;
    198206      else
    199207        throw new InvalidDataException("Input file contains an unsupported edge weight type (only \"EUC_2D\" and \"GEO\" are supported).");
Note: See TracChangeset for help on using the changeset viewer.