Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/23/10 06:50:50 (14 years ago)
Author:
swagner
Message:

Operator architecture refactoring (#95)

  • worked on algorithms
Location:
trunk/sources/HeuristicLab.Routing.TSP/3.3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Routing.TSP/3.3/TSP.cs

    r2834 r2852  
    3131  [Creatable("Problems")]
    3232  [EmptyStorableClass]
    33   public sealed class TSP : Problem {
     33  public sealed class TSP : SingleObjectiveProblem {
    3434    private ValueParameter<DoubleMatrixData> CoordinatesParameter {
    3535      get { return (ValueParameter<DoubleMatrixData>)Parameters["Coordinates"]; }
    36     }
    37     private OperatorParameter SolutionCreatorParameter {
    38       get { return (OperatorParameter)Parameters["SolutionCreator"]; }
    39     }
    40     private OperatorParameter SolutionEvaluatorParameter {
    41       get { return (OperatorParameter)Parameters["SolutionEvaluator"]; }
    4236    }
    4337
     
    4640      set { CoordinatesParameter.Value = value; }
    4741    }
    48     public IOperator SolutionCreator {
    49       get { return SolutionCreatorParameter.Value; }
    50       set { SolutionCreatorParameter.Value = value; }
    51     }
    52     public IOperator SolutionEvaluator {
    53       get { return SolutionEvaluatorParameter.Value; }
    54       set { SolutionEvaluatorParameter.Value = value; }
    55     }
    5642
    5743    public TSP()
    5844      : base() {
    59       Parameters.Add(new ValueParameter<BoolData>("Maximization", "Set to false as the TSP is a minimization problem.", new BoolData(false)));
     45      Maximization = new BoolData(false);
    6046      Parameters.Add(new ValueParameter<DoubleMatrixData>("Coordinates", "The x- and y-Coordinates of the cities.", new DoubleMatrixData(0, 0)));
    6147      Parameters.Add(new ValueParameter<DoubleData>("BestKnownQuality", "The quality of the best known solution of this TSP instance."));
    62       Parameters.Add(new OperatorParameter("SolutionCreator", "The operator which should be used to create new solutions."));
    63       Parameters.Add(new OperatorParameter("SolutionEvaluator", "The operator which should be used to evaluate solutions."));
     48      RandomPermutationCreator creator = new RandomPermutationCreator();
     49      creator.LengthParameter.Value = new IntData(0);
     50      SolutionCreator = creator;
     51      Evaluator = new TSPRoundedEuclideanPathEvaluator();
    6452    }
    6553
     
    7361      SolutionCreator = creator;
    7462      TSPRoundedEuclideanPathEvaluator evaluator = new TSPRoundedEuclideanPathEvaluator();
    75       SolutionEvaluator = evaluator;
     63      Evaluator = evaluator;
    7664    }
    7765  }
  • trunk/sources/HeuristicLab.Routing.TSP/3.3/TSPPathEvaluator.cs

    r2834 r2852  
    2222using HeuristicLab.Core;
    2323using HeuristicLab.Data;
    24 using HeuristicLab.Operators;
     24using HeuristicLab.Optimization;
    2525using HeuristicLab.Parameters;
    2626using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     
    3232  [Item("TSPPathEvaluator", "A base class for operators which evaluate TSP solutions given in path representation.")]
    3333  [EmptyStorableClass]
    34   public abstract class TSPPathEvaluator : SingleSuccessorOperator {
     34  public abstract class TSPPathEvaluator : SingleObjectiveEvaluator {
    3535    public LookupParameter<DoubleMatrixData> CoordinatesParameter {
    3636      get { return (LookupParameter<DoubleMatrixData>)Parameters["Coordinates"]; }
     
    3939      get { return (LookupParameter<Permutation.Permutation>)Parameters["Permutation"]; }
    4040    }
    41     public LookupParameter<DoubleData> QualityParameter {
    42       get { return (LookupParameter<DoubleData>)Parameters["Quality"]; }
    43     }
    4441
    4542    protected TSPPathEvaluator()
     
    4744      Parameters.Add(new LookupParameter<DoubleMatrixData>("Coordinates", "The x- and y-Coordinates of the cities."));
    4845      Parameters.Add(new LookupParameter<Permutation.Permutation>("Permutation", "The TSP solution given in path representation which should be evaluated."));
    49       Parameters.Add(new LookupParameter<DoubleData>("Quality", "The evaluated quality of the given TSP solution."));
    5046    }
    5147
Note: See TracChangeset for help on using the changeset viewer.