Free cookie consent management tool by TermsFeed Policy Generator

Changeset 2865


Ignore:
Timestamp:
02/25/10 06:35:43 (15 years ago)
Author:
swagner
Message:

Operator architecture refactoring (#95)

  • worked on algorithms
Location:
trunk/sources
Files:
4 added
4 deleted
23 edited
4 moved

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/EngineAlgorithmView.Designer.cs

    r2864 r2865  
    6868      // problemTabPage
    6969      //
    70       this.problemTabPage.Size = new System.Drawing.Size(482, 148);
     70      this.problemTabPage.Size = new System.Drawing.Size(648, 252);
    7171      //
    7272      // parameterCollectionView
     
    9696      //
    9797      this.executionTimeLabel.Location = new System.Drawing.Point(430, 440);
    98       this.executionTimeLabel.TabIndex = 11;
     98      this.executionTimeLabel.TabIndex = 12;
    9999      //
    100100      // executionTimeTextBox
    101101      //
    102102      this.executionTimeTextBox.Location = new System.Drawing.Point(519, 437);
    103       this.executionTimeTextBox.TabIndex = 12;
     103      this.executionTimeTextBox.TabIndex = 13;
    104104      //
    105105      // nameTextBox
     
    150150      this.createUserDefinedAlgorithmButton.Location = new System.Drawing.Point(90, 433);
    151151      this.createUserDefinedAlgorithmButton.Name = "createUserDefinedAlgorithmButton";
    152       this.createUserDefinedAlgorithmButton.Size = new System.Drawing.Size(161, 24);
    153       this.createUserDefinedAlgorithmButton.TabIndex = 13;
     152      this.createUserDefinedAlgorithmButton.Size = new System.Drawing.Size(254, 24);
     153      this.createUserDefinedAlgorithmButton.TabIndex = 11;
    154154      this.createUserDefinedAlgorithmButton.Text = "&Create User Defined Algorithm";
    155155      this.toolTip.SetToolTip(this.createUserDefinedAlgorithmButton, "Create User Defined Algorithm from this Algorithm");
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/ProblemView.cs

    r2852 r2865  
    2727  /// The base class for visual representations of items.
    2828  /// </summary>
    29   [Content(typeof(Problem), true)]
    30   [Content(typeof(IProblem), false)]
     29  [Content(typeof(IProblem), true)]
    3130  public partial class ProblemView : ParameterizedNamedItemView {
    3231    public new IProblem Content {
  • trunk/sources/HeuristicLab.Optimization/3.3/HeuristicLab.Optimization-3.3.csproj

    r2864 r2865  
    5252    <None Include="HeuristicLabOptimizationPlugin.cs.frame" />
    5353    <Compile Include="Algorithm.cs" />
     54    <Compile Include="Interfaces\IMultiObjectiveProblem.cs" />
     55    <Compile Include="Interfaces\IMultiObjectiveEvaluator.cs" />
    5456    <Compile Include="Interfaces\IAlgorithm.cs" />
    55     <Compile Include="Interfaces\ICrossoverOperator.cs" />
     57    <Compile Include="Interfaces\ICrossover.cs" />
    5658    <Compile Include="Interfaces\IEvaluator.cs" />
    57     <Compile Include="Interfaces\IManipulationOperator.cs" />
     59    <Compile Include="Interfaces\IManipulator.cs" />
    5860    <Compile Include="Interfaces\IProblem.cs" />
    5961    <Compile Include="Interfaces\ISingleObjectiveEvaluator.cs" />
     
    6163    <Compile Include="Interfaces\ISolutionCreator.cs" />
    6264    <Compile Include="Interfaces\IStochasticOperator.cs" />
    63     <Compile Include="SingleObjectiveProblem.cs" />
    64     <Compile Include="SingleObjectiveEvaluator.cs" />
    6565    <Compile Include="UserDefinedAlgorithm.cs" />
    6666    <Compile Include="EngineAlgorithm.cs" />
    6767    <Compile Include="HeuristicLabOptimizationPlugin.cs" />
    68     <Compile Include="Problem.cs" />
    6968    <Compile Include="Properties\AssemblyInfo.cs" />
    7069  </ItemGroup>
  • trunk/sources/HeuristicLab.Optimization/3.3/Interfaces/ICrossover.cs

    r2864 r2865  
    2121
    2222using HeuristicLab.Core;
    23 using HeuristicLab.Data;
    2423
    2524namespace HeuristicLab.Optimization {
     
    2726  /// An interface which represents an operator for crossing solutions.
    2827  /// </summary>
    29   public interface ICrossoverOperator : IOperator { }
     28  public interface ICrossover : IOperator { }
    3029}
  • trunk/sources/HeuristicLab.Optimization/3.3/Interfaces/IEvaluator.cs

    r2864 r2865  
    2121
    2222using HeuristicLab.Core;
    23 using HeuristicLab.Data;
    2423
    2524namespace HeuristicLab.Optimization {
  • trunk/sources/HeuristicLab.Optimization/3.3/Interfaces/IManipulator.cs

    r2864 r2865  
    2121
    2222using HeuristicLab.Core;
    23 using HeuristicLab.Data;
    2423
    2524namespace HeuristicLab.Optimization {
     
    2726  /// An interface which represents an operator for manipulating solutions.
    2827  /// </summary>
    29   public interface IManipulationOperator : IOperator { }
     28  public interface IManipulator : IOperator { }
    3029}
  • trunk/sources/HeuristicLab.Optimization/3.3/Interfaces/IProblem.cs

    r2864 r2865  
    2020#endregion
    2121
     22using System;
    2223using HeuristicLab.Core;
    23 using System;
    24 using HeuristicLab.Common;
    2524
    2625namespace HeuristicLab.Optimization {
  • trunk/sources/HeuristicLab.Optimization/3.3/Interfaces/ISingleObjectiveProblem.cs

    r2864 r2865  
    2020#endregion
    2121
    22 using HeuristicLab.Core;
     22using System;
    2323using HeuristicLab.Data;
    24 using System;
    2524
    2625namespace HeuristicLab.Optimization {
     
    2928  /// </summary>
    3029  public interface ISingleObjectiveProblem : IProblem {
    31     BoolData Maximization { get; set; }
    32     new ISingleObjectiveEvaluator Evaluator { get; set; }
     30    BoolData Maximization { get; }
     31    new ISingleObjectiveEvaluator Evaluator { get; }
    3332
    3433    event EventHandler MaximizationChanged;
  • trunk/sources/HeuristicLab.Optimization/3.3/Interfaces/ISolutionCreator.cs

    r2864 r2865  
    2121
    2222using HeuristicLab.Core;
    23 using HeuristicLab.Data;
    2423
    2524namespace HeuristicLab.Optimization {
  • trunk/sources/HeuristicLab.Optimization/3.3/Interfaces/IStochasticOperator.cs

    r2864 r2865  
    2121
    2222using HeuristicLab.Core;
    23 using HeuristicLab.Data;
    2423
    2524namespace HeuristicLab.Optimization {
  • trunk/sources/HeuristicLab.Permutation/3.3/AbsolutePositionTopologicalCrossover.cs

    r2854 r2865  
    2121
    2222using System;
    23 using System.Collections.Generic;
    24 using System.Text;
    2523using HeuristicLab.Core;
    26 using HeuristicLab.Data;
    2724using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2825
  • trunk/sources/HeuristicLab.Permutation/3.3/CosaCrossover.cs

    r2856 r2865  
    2121
    2222using System;
    23 using System.Collections.Generic;
    24 using System.Text;
    2523using HeuristicLab.Core;
    26 using HeuristicLab.Data;
    2724using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2825
  • trunk/sources/HeuristicLab.Permutation/3.3/EdgeRecombinationCrossover.cs

    r2854 r2865  
    2121
    2222using System;
    23 using System.Collections.Generic;
    24 using System.Text;
    2523using HeuristicLab.Core;
    26 using HeuristicLab.Data;
    2724using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2825
  • trunk/sources/HeuristicLab.Permutation/3.3/HeuristicLab.Permutation-3.3.csproj

    r2857 r2865  
    8383    <None Include="HeuristicLabPermutationPlugin.cs.frame" />
    8484    <Compile Include="AbsolutePositionTopologicalCrossover.cs" />
     85    <Compile Include="IPermutationCreator.cs" />
     86    <Compile Include="IPermutationOperator.cs" />
    8587    <Compile Include="CosaCrossover.cs" />
    8688    <Compile Include="CyclicCrossover.cs" />
     
    9092      <SubType>Code</SubType>
    9193    </Compile>
    92     <Compile Include="IPermutationCrossoverOperator.cs" />
    93     <Compile Include="IPermutationManipulationOperator.cs" />
     94    <Compile Include="IPermutationCrossover.cs" />
     95    <Compile Include="IPermutationManipulator.cs" />
    9496    <Compile Include="MaximalPreservativeCrossover.cs" />
    9597    <Compile Include="OrderBasedCrossover.cs" />
  • trunk/sources/HeuristicLab.Permutation/3.3/IPermutationCrossover.cs

    r2862 r2865  
    2121
    2222using HeuristicLab.Core;
    23 using HeuristicLab.Data;
    2423using HeuristicLab.Optimization;
    2524
     
    2827  /// An interface which represents an operator for crossing permutations.
    2928  /// </summary>
    30   public interface IPermutationCrossoverOperator : ICrossoverOperator { }
     29  public interface IPermutationCrossover : IPermutationOperator, ICrossover {
     30    ILookupParameter<ItemArray<Permutation>> ParentsParameter { get; }
     31    ILookupParameter<Permutation> ChildParameter { get; }
     32  }
    3133}
  • trunk/sources/HeuristicLab.Permutation/3.3/IPermutationManipulator.cs

    r2862 r2865  
    2121
    2222using HeuristicLab.Core;
    23 using HeuristicLab.Data;
    2423using HeuristicLab.Optimization;
    2524
     
    2827  /// An interface which represents an operator for manipulating solutions.
    2928  /// </summary>
    30   public interface IPermutationManipulationOperator : IManipulationOperator { }
     29  public interface IPermutationManipulator : IPermutationOperator, IManipulator {
     30    ILookupParameter<Permutation> PermutationParameter { get; }
     31  }
    3132}
  • trunk/sources/HeuristicLab.Permutation/3.3/InsertionManipulator.cs

    r2854 r2865  
    2020#endregion
    2121
    22 using System;
    23 using System.Collections.Generic;
    24 using System.Text;
    2522using HeuristicLab.Core;
    2623using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
  • trunk/sources/HeuristicLab.Permutation/3.3/OrderBasedCrossover.cs

    r2854 r2865  
    2121
    2222using System;
    23 using System.Collections.Generic;
    24 using System.Text;
    2523using HeuristicLab.Core;
    26 using HeuristicLab.Data;
    2724using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2825
  • trunk/sources/HeuristicLab.Permutation/3.3/PermutationCrossover.cs

    r2857 r2865  
    3232  [Item("PermutationCrossover", "A base class for permutation crossover operators.")]
    3333  [EmptyStorableClass]
    34   public abstract class PermutationCrossover : SingleSuccessorOperator, IPermutationCrossoverOperator {
     34  public abstract class PermutationCrossover : SingleSuccessorOperator, IPermutationCrossover, IStochasticOperator {
    3535    public ILookupParameter<IRandom> RandomParameter {
    3636      get { return (LookupParameter<IRandom>)Parameters["Random"]; }
    3737    }
    38     public SubScopesLookupParameter<Permutation> ParentsParameter {
     38    public ILookupParameter<ItemArray<Permutation>> ParentsParameter {
    3939      get { return (SubScopesLookupParameter<Permutation>)Parameters["Parents"]; }
    4040    }
    41     public LookupParameter<Permutation> ChildParameter {
    42       get { return (LookupParameter<Permutation>)Parameters["Child"]; }
     41    public ILookupParameter<Permutation> ChildParameter {
     42      get { return (ILookupParameter<Permutation>)Parameters["Child"]; }
    4343    }
    4444
  • trunk/sources/HeuristicLab.Permutation/3.3/PermutationManipulator.cs

    r2857 r2865  
    3232  [Item("PermutationManipulator", "A base class for permutation manipulation operators.")]
    3333  [EmptyStorableClass]
    34   public abstract class PermutationManipulator : SingleSuccessorOperator, IPermutationManipulationOperator {
     34  public abstract class PermutationManipulator : SingleSuccessorOperator, IPermutationManipulator, IStochasticOperator {
    3535    public ILookupParameter<IRandom> RandomParameter {
    3636      get { return (LookupParameter<IRandom>)Parameters["Random"]; }
    3737    }
    38     public LookupParameter<Permutation> PermutationParameter {
    39       get { return (LookupParameter<Permutation>)Parameters["Permutation"]; }
     38    public ILookupParameter<Permutation> PermutationParameter {
     39      get { return (ILookupParameter<Permutation>)Parameters["Permutation"]; }
    4040    }
    4141
  • trunk/sources/HeuristicLab.Permutation/3.3/RandomPermutationCreator.cs

    r2852 r2865  
    3434  [EmptyStorableClass]
    3535  [Creatable("Test")]
    36   public sealed class RandomPermutationCreator : SingleSuccessorOperator, ISolutionCreator {
     36  public sealed class RandomPermutationCreator : SingleSuccessorOperator, IPermutationCreator, IStochasticOperator {
    3737    public ILookupParameter<IRandom> RandomParameter {
    3838      get { return (LookupParameter<IRandom>)Parameters["Random"]; }
    3939    }
    40     public ValueLookupParameter<IntData> LengthParameter {
    41       get { return (ValueLookupParameter<IntData>)Parameters["Length"]; }
     40    public IValueLookupParameter<IntData> LengthParameter {
     41      get { return (IValueLookupParameter<IntData>)Parameters["Length"]; }
    4242    }
    43     public LookupParameter<Permutation> PermutationParameter {
    44       get { return (LookupParameter<Permutation>)Parameters["Permutation"]; }
     43    public ILookupParameter<Permutation> PermutationParameter {
     44      get { return (ILookupParameter<Permutation>)Parameters["Permutation"]; }
    4545    }
    4646
  • trunk/sources/HeuristicLab.Routing.TSP/3.3/HeuristicLab.Routing.TSP-3.3.csproj

    r2834 r2865  
    8080    </Reference>
    8181    <Reference Include="System.Data" />
     82    <Reference Include="System.Drawing" />
    8283    <Reference Include="System.Xml" />
    8384  </ItemGroup>
    8485  <ItemGroup>
    8586    <None Include="HeuristicLabRoutingTSPPlugin.cs.frame" />
     87    <Compile Include="TSPEvaluator.cs" />
     88    <Compile Include="ITSPEvaluator.cs" />
    8689    <Compile Include="TSPDistanceMatrixPathEvaluator.cs" />
    8790    <Compile Include="TSPLIBParser.cs" />
     
    9699      <Project>{958B43BC-CC5C-4FA2-8628-2B3B01D890B6}</Project>
    97100      <Name>HeuristicLab.Collections-3.3</Name>
     101    </ProjectReference>
     102    <ProjectReference Include="..\..\HeuristicLab.Common.Resources\3.2\HeuristicLab.Common.Resources-3.2.csproj">
     103      <Project>{0E27A536-1C4A-4624-A65E-DC4F4F23E3E1}</Project>
     104      <Name>HeuristicLab.Common.Resources-3.2</Name>
    98105    </ProjectReference>
    99106    <ProjectReference Include="..\..\HeuristicLab.Core\3.3\HeuristicLab.Core-3.3.csproj">
  • trunk/sources/HeuristicLab.Routing.TSP/3.3/HeuristicLabRoutingTSPPlugin.cs.frame

    r2834 r2865  
    2929  [PluginFile("HeuristicLab.Routing.TSP-3.3.dll", PluginFileType.Assembly)]
    3030  [PluginDependency("HeuristicLab.Collections", "3.3")]
     31  [PluginDependency("HeuristicLab.Common.Resources", "3.2")]
    3132  [PluginDependency("HeuristicLab.Core", "3.3")]
    3233  [PluginDependency("HeuristicLab.Data", "3.3")]
  • trunk/sources/HeuristicLab.Routing.TSP/3.3/TSP.cs

    r2857 r2865  
    2020#endregion
    2121
     22using System;
     23using System.Drawing;
     24using System.Linq;
    2225using HeuristicLab.Core;
    2326using HeuristicLab.Data;
     
    2629using HeuristicLab.Permutation;
    2730using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    28 using System;
     31using HeuristicLab.PluginInfrastructure;
    2932
    3033namespace HeuristicLab.Routing.TSP {
     
    3235  [Creatable("Problems")]
    3336  [EmptyStorableClass]
    34   public sealed class TSP : SingleObjectiveProblem {
    35     private ValueParameter<DoubleMatrixData> CoordinatesParameter {
    36       get { return (ValueParameter<DoubleMatrixData>)Parameters["Coordinates"]; }
     37  public sealed class TSP : ParameterizedNamedItem, ISingleObjectiveProblem {
     38    public override Image ItemImage {
     39      get { return HeuristicLab.Common.Resources.VS2008ImageLibrary.Type; }
    3740    }
    3841
    39     public DoubleMatrixData Coordinates {
    40       get { return CoordinatesParameter.Value; }
    41       set { CoordinatesParameter.Value = value; }
     42    private IValueParameter<BoolData> MaximizationParameter {
     43      get { return (IValueParameter<BoolData>)Parameters["Maximization"]; }
     44    }
     45    public IValueParameter<DoubleMatrixData> CoordinatesParameter {
     46      get { return (IValueParameter<DoubleMatrixData>)Parameters["Coordinates"]; }
     47    }
     48    public IValueParameter<DoubleData> BestKnownQualityParameter {
     49      get { return (IValueParameter<DoubleData>)Parameters["BestKnownQuality"]; }
     50    }
     51    public IValueParameter<IPermutationCreator> SolutionCreatorParameter {
     52      get { return (IValueParameter<IPermutationCreator>)Parameters["SolutionCreator"]; }
     53    }
     54    public IValueParameter<ITSPEvaluator> EvaluatorParameter {
     55      get { return (IValueParameter<ITSPEvaluator>)Parameters["Evaluator"]; }
     56    }
     57
     58    public BoolData Maximization {
     59      get { return MaximizationParameter.Value; }
     60    }
     61    public ISolutionCreator SolutionCreator {
     62      get { return SolutionCreatorParameter.Value; }
     63    }
     64    public ISingleObjectiveEvaluator Evaluator {
     65      get { return EvaluatorParameter.Value; }
     66    }
     67    IEvaluator IProblem.Evaluator {
     68      get { return EvaluatorParameter.Value; }
     69    }
     70    private OperatorSet operators;
     71    public OperatorSet Operators {
     72      get { return operators; }
    4273    }
    4374
    4475    public TSP()
    4576      : base() {
    46       Maximization = new BoolData(false);
     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);
     80
    4781      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
    4891      Parameters.Add(new ValueParameter<DoubleData>("BestKnownQuality", "The quality of the best known solution of this TSP instance."));
     92
    4993      RandomPermutationCreator creator = new RandomPermutationCreator();
     94      creator.PermutationParameter.ActualName = "TSPTour";
    5095      creator.LengthParameter.Value = new IntData(0);
    51       SolutionCreator = creator;
    52       Evaluator = new TSPRoundedEuclideanPathEvaluator();
     96      SolutionCreatorParameter.Value = creator;
     97      TSPRoundedEuclideanPathEvaluator evaluator = new TSPRoundedEuclideanPathEvaluator();
     98      evaluator.CoordinatesParameter.ActualName = CoordinatesParameter.Name;
     99      evaluator.PermutationParameter.ActualName = creator.PermutationParameter.ActualName;
     100      evaluator.QualityParameter.ActualName = "TSPTourLength";
     101      EvaluatorParameter.Value = evaluator;
     102
     103      operators = new OperatorSet();
     104      var crossovers = ApplicationManager.Manager.GetInstances<IPermutationCrossover>().ToList();
     105      crossovers.ForEach(x => {
     106        x.ParentsParameter.ActualName = creator.PermutationParameter.ActualName;
     107        x.ChildParameter.ActualName = creator.PermutationParameter.ActualName;
     108      });
     109      var manipulators = ApplicationManager.Manager.GetInstances<IPermutationManipulator>().ToList();
     110      manipulators.ForEach(x => x.PermutationParameter.ActualName = creator.PermutationParameter.ActualName);
     111      operators = new OperatorSet(crossovers.Cast<IOperator>().Concat(manipulators.Cast<IOperator>()));
    53112    }
    54113
     
    56115      TSPLIBParser parser = new TSPLIBParser(filename);
    57116      parser.Parse();
    58       Coordinates = new DoubleMatrixData(parser.Vertices);
    59       int cities = Coordinates.Rows;
    60       RandomPermutationCreator creator = new RandomPermutationCreator();
    61       creator.LengthParameter.Value = new IntData(cities);
    62       SolutionCreator = creator;
    63       TSPRoundedEuclideanPathEvaluator evaluator = new TSPRoundedEuclideanPathEvaluator();
    64       Evaluator = evaluator;
     117      CoordinatesParameter.Value = new DoubleMatrixData(parser.Vertices);
     118      int cities = CoordinatesParameter.Value.Rows;
     119      SolutionCreatorParameter.Value.LengthParameter.Value = new IntData(cities);
     120    }
     121
     122    private void MaximizationParameter_ValueChanged(object sender, EventArgs e) {
     123      OnMaximizationChanged();
     124    }
     125    private void SolutionCreatorParameter_ValueChanged(object sender, EventArgs e) {
     126      OnSolutionCreatorChanged();
     127    }
     128    private void EvaluatorParameter_ValueChanged(object sender, EventArgs e) {
     129      OnEvaluatorChanged();
     130    }
     131
     132    public event EventHandler MaximizationChanged;
     133    private void OnMaximizationChanged() {
     134      if (MaximizationChanged != null)
     135        MaximizationChanged(this, EventArgs.Empty);
     136    }
     137    public event EventHandler SolutionCreatorChanged;
     138    private void OnSolutionCreatorChanged() {
     139      if (SolutionCreatorChanged != null)
     140        SolutionCreatorChanged(this, EventArgs.Empty);
     141    }
     142    public event EventHandler EvaluatorChanged;
     143    private void OnEvaluatorChanged() {
     144      if (EvaluatorChanged != null)
     145        EvaluatorChanged(this, EventArgs.Empty);
    65146    }
    66147  }
  • trunk/sources/HeuristicLab.Routing.TSP/3.3/TSPDistanceMatrixPathEvaluator.cs

    r2834 r2865  
    2222using HeuristicLab.Core;
    2323using HeuristicLab.Data;
    24 using HeuristicLab.Operators;
    2524using HeuristicLab.Parameters;
    2625using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     
    3332  [Creatable("Test")]
    3433  [EmptyStorableClass]
    35   public sealed class TSPDistanceMatrixPathEvaluator : SingleSuccessorOperator {
     34  public sealed class TSPDistanceMatrixPathEvaluator : TSPEvaluator {
    3635    public LookupParameter<DoubleMatrixData> DistanceMatrixParameter {
    3736      get { return (LookupParameter<DoubleMatrixData>)Parameters["DistanceMatrix"]; }
     
    4039      get { return (LookupParameter<Permutation.Permutation>)Parameters["Permutation"]; }
    4140    }
    42     public LookupParameter<DoubleData> QualityParameter {
    43       get { return (LookupParameter<DoubleData>)Parameters["Quality"]; }
    44     }
    4541
    4642    public TSPDistanceMatrixPathEvaluator()
     
    4844      Parameters.Add(new LookupParameter<DoubleMatrixData>("DistanceMatrix", "The distance matrix of the cities."));
    4945      Parameters.Add(new LookupParameter<Permutation.Permutation>("Permutation", "The TSP solution given in path representation which should be evaluated."));
    50       Parameters.Add(new LookupParameter<DoubleData>("Quality", "The evaluated quality of the given TSP solution."));
    5146    }
    5247
  • trunk/sources/HeuristicLab.Routing.TSP/3.3/TSPPathEvaluator.cs

    r2852 r2865  
    2222using HeuristicLab.Core;
    2323using HeuristicLab.Data;
    24 using HeuristicLab.Optimization;
    2524using HeuristicLab.Parameters;
    2625using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     
    3231  [Item("TSPPathEvaluator", "A base class for operators which evaluate TSP solutions given in path representation.")]
    3332  [EmptyStorableClass]
    34   public abstract class TSPPathEvaluator : SingleObjectiveEvaluator {
     33  public abstract class TSPPathEvaluator : TSPEvaluator {
    3534    public LookupParameter<DoubleMatrixData> CoordinatesParameter {
    3635      get { return (LookupParameter<DoubleMatrixData>)Parameters["Coordinates"]; }
  • trunk/sources/HeuristicLab.SGA/3.3/SGA.cs

    r2864 r2865  
    2020#endregion
    2121
     22using System;
     23using System.Linq;
    2224using HeuristicLab.Core;
    2325using HeuristicLab.Data;
     
    2729using HeuristicLab.Parameters;
    2830using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    29 using System;
    3031
    3132namespace HeuristicLab.SGA {
     
    4041    [Storable]
    4142    private SGAOperator sgaOperator;
     43
     44    private ConstrainedValueParameter<ICrossover> CrossoverOperatorParameter {
     45      get { return (ConstrainedValueParameter<ICrossover>)Parameters["CrossoverOperator"]; }
     46    }
     47    private ConstrainedValueParameter<IManipulator> MutationOperatorParameter {
     48      get { return (ConstrainedValueParameter<IManipulator>)Parameters["MutationOperator"]; }
     49    }
    4250
    4351    public override Type ProblemType {
     
    5462      Parameters.Add(new ValueParameter<BoolData>("SetSeedRandomly", "True if the random seed should be set to a random value, otherwise false.", new BoolData(true)));
    5563      Parameters.Add(new ValueParameter<IntData>("PopulationSize", "The size of the population of solutions.", new IntData(100)));
    56       Parameters.Add(new OperatorParameter("CrossoverOperator", "The operator used to cross solutions."));
     64      Parameters.Add(new ConstrainedValueParameter<ICrossover>("CrossoverOperator", "The operator used to cross solutions."));
    5765      Parameters.Add(new ValueParameter<DoubleData>("MutationProbability", "The probability that the mutation operator is applied on a solution.", new DoubleData(0.05)));
    58       Parameters.Add(new OperatorParameter("MutationOperator", "The operator used to mutate solutions."));
     66      Parameters.Add(new ConstrainedValueParameter<IManipulator>("MutationOperator", "The operator used to mutate solutions."));
    5967      Parameters.Add(new ValueParameter<IntData>("Elites", "The numer of elite solutions which are kept in each generation.", new IntData(1)));
    6068      Parameters.Add(new ValueParameter<IntData>("MaximumGenerations", "The maximum number of generations which should be processed.", new IntData(1000)));
     
    103111    protected override void OnProblemChanged() {
    104112      if (Problem.SolutionCreator is IStochasticOperator) ((IStochasticOperator)Problem.SolutionCreator).RandomParameter.ActualName = "Random";
     113      if (Problem.Evaluator is IStochasticOperator) ((IStochasticOperator)Problem.Evaluator).RandomParameter.ActualName = "Random";
     114      Problem.Operators.Where(x => x is IStochasticOperator).Select(x => (x as IStochasticOperator).RandomParameter.ActualName = "Random");
     115
    105116      populationCreator.SolutionCreatorParameter.Value = Problem.SolutionCreator;
    106117      populationCreator.SolutionEvaluatorParameter.Value = Problem.Evaluator;
    107118      sgaOperator.MaximizationParameter.Value = Problem.Maximization;
    108       sgaOperator.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.Name;
     119      sgaOperator.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;
    109120      sgaOperator.SolutionEvaluatorParameter.Value = Problem.Evaluator;
     121
     122      CrossoverOperatorParameter.ValidValues.Clear();
     123      var crossovers = from o in Problem.Operators
     124                       where o is ICrossover
     125                       select (ICrossover)o;
     126      foreach (ICrossover crossover in crossovers)
     127        CrossoverOperatorParameter.ValidValues.Add(crossover);
     128
     129      MutationOperatorParameter.ValidValues.Clear();
     130      var mutators = from o in Problem.Operators
     131                     where o is IManipulator
     132                     select (IManipulator)o;
     133      foreach (IManipulator mutator in mutators)
     134        MutationOperatorParameter.ValidValues.Add(mutator);
     135
    110136      base.OnProblemChanged();
    111137    }
     
    116142    }
    117143    protected override void Problem_EvaluatorChanged(object sender, EventArgs e) {
     144      if (Problem.Evaluator is IStochasticOperator) ((IStochasticOperator)Problem.Evaluator).RandomParameter.ActualName = "Random";
    118145      populationCreator.SolutionEvaluatorParameter.Value = Problem.Evaluator;
    119       sgaOperator.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.Name;
     146      sgaOperator.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;
    120147      sgaOperator.SolutionEvaluatorParameter.Value = Problem.Evaluator;
    121148      base.Problem_EvaluatorChanged(sender, e);
Note: See TracChangeset for help on using the changeset viewer.