Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/01/10 03:01:01 (14 years ago)
Author:
swagner
Message:

Operator architecture refactoring (#95)

  • worked on algorithms, problems and parameters
File:
1 edited

Legend:

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

    r2883 r2890  
    7575    public TSP()
    7676      : base() {
    77       ValueParameter<BoolData> maximizationParameter = new ValueParameter<BoolData>("Maximization", "Set to false as the Traveling Salesman Problem is a minimization problem.", new BoolData(false));
    78       maximizationParameter.ValueChanged += new EventHandler(MaximizationParameter_ValueChanged);
    79       Parameters.Add(maximizationParameter);
     77      Parameters.Add(new OptionalValueParameter<BoolData>("Maximization", "Set to false as the Traveling Salesman Problem is a minimization problem.", new BoolData(false)));
     78      Parameters.Add(new OptionalValueParameter<DoubleMatrixData>("Coordinates", "The x- and y-Coordinates of the cities.", new DoubleMatrixData(0, 0)));
     79      Parameters.Add(new OptionalValueParameter<IPermutationCreator>("SolutionCreator", "The operator which should be used to create new TSP solutions."));
     80      Parameters.Add(new OptionalValueParameter<ITSPEvaluator>("Evaluator", "The operator which should be used to evaluate TSP solutions."));
     81      Parameters.Add(new OptionalValueParameter<DoubleData>("BestKnownQuality", "The quality of the best known solution of this TSP instance."));
    8082
    81       Parameters.Add(new ValueParameter<DoubleMatrixData>("Coordinates", "The x- and y-Coordinates of the cities.", new DoubleMatrixData(0, 0)));
    82 
    83       ValueParameter<IPermutationCreator> solutionCreatorParameter = new ValueParameter<IPermutationCreator>("SolutionCreator", "The operator which should be used to create new TSP solutions.");
    84       solutionCreatorParameter.ValueChanged += new EventHandler(SolutionCreatorParameter_ValueChanged);
    85       Parameters.Add(solutionCreatorParameter);
    86 
    87       ValueParameter<ITSPEvaluator> evaluatorParameter = new ValueParameter<ITSPEvaluator>("Evaluator", "The operator which should be used to evaluate TSP solutions.");
    88       evaluatorParameter.ValueChanged += new EventHandler(EvaluatorParameter_ValueChanged);
    89       Parameters.Add(evaluatorParameter);
    90 
    91       Parameters.Add(new ValueParameter<DoubleData>("BestKnownQuality", "The quality of the best known solution of this TSP instance."));
     83      MaximizationParameter.ValueChanged += new EventHandler(MaximizationParameter_ValueChanged);
     84      SolutionCreatorParameter.ValueChanged += new EventHandler(SolutionCreatorParameter_ValueChanged);
     85      EvaluatorParameter.ValueChanged += new EventHandler(EvaluatorParameter_ValueChanged);
    9286
    9387      RandomPermutationCreator creator = new RandomPermutationCreator();
     
    10195      EvaluatorParameter.Value = evaluator;
    10296
    103       var ops = ApplicationManager.Manager.GetInstances<IPermutationOperator>().ToList();
    104       ops.ForEach(x => {
    105         IPermutationCrossover y = x as IPermutationCrossover;
    106         if (y != null) {
    107           y.ParentsParameter.ActualName = creator.PermutationParameter.ActualName;
    108           y.ChildParameter.ActualName = creator.PermutationParameter.ActualName;
    109         }
    110       });
    111       ops.ForEach(x => {
    112         IPermutationManipulator y = x as IPermutationManipulator;
    113         if (y != null)
    114           y.PermutationParameter.ActualName = creator.PermutationParameter.ActualName;
    115       });
     97      var ops = ApplicationManager.Manager.GetInstances<IPermutationOperator>();
     98      foreach (IPermutationCrossover op in ops.OfType<IPermutationCrossover>()) {
     99        op.ParentsParameter.ActualName = creator.PermutationParameter.ActualName;
     100        op.ChildParameter.ActualName = creator.PermutationParameter.ActualName;
     101      }
     102      foreach (IPermutationManipulator op in ops.OfType<IPermutationManipulator>()) {
     103        op.PermutationParameter.ActualName = creator.PermutationParameter.ActualName;
     104      }
    116105      operators = new OperatorSet(ops.Cast<IOperator>());
    117106    }
Note: See TracChangeset for help on using the changeset viewer.