Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/25/15 16:22:37 (9 years ago)
Author:
abeham
Message:

#2521:

  • Refactored QuadraticAssignmentProblem to use new SingleObjectiveProblem
    • Removed QAPEvaluator
    • Adapted RobustTabooSearch
  • Introduced several interfaces in PermutationEncoding necessary for wiring
  • Changed all Encodings to use IItem instead of IOperator in ConfigureOperators (name still unchanged)
  • Added a protected MaximizationParameter property in SingleObjectiveProblem (necessary for wiring)
  • Changed AlleleFrequnencyAnalyzer to use ISolution interface instead of IItem
  • Added a comment to ISolutionCreator<TSolution> of some changes that would be welcomed
Location:
branches/ProblemRefactoring
Files:
4 added
1 deleted
39 edited
4 copied
1 moved

Legend:

Unmodified
Added
Removed
  • branches/ProblemRefactoring/HeuristicLab.Analysis/3.3/AlleleFrequencyAnalysis/AlleleFrequencyAnalyzer.cs

    r12012 r13396  
    3737  [Item("AlleleFrequencyAnalyzer", "An operator for analyzing the frequency of alleles.")]
    3838  [StorableClass]
    39   public abstract class AlleleFrequencyAnalyzer<T> : SingleSuccessorOperator, IAnalyzer, ISingleObjectiveOperator where T : class, IItem {
     39  public abstract class AlleleFrequencyAnalyzer<T> : SingleSuccessorOperator, IAnalyzer, ISingleObjectiveOperator where T : class, ISolution {
    4040    public virtual bool EnabledByDefault {
    4141      get { return false; }
  • branches/ProblemRefactoring/HeuristicLab.Encodings.BinaryVectorEncoding/3.3/BinaryVectorEncoding.cs

    r13336 r13396  
    122122    #endregion
    123123
    124     public override void ConfigureOperators(IEnumerable<IOperator> operators) {
     124    public override void ConfigureOperators(IEnumerable<IItem> operators) {
    125125      ConfigureCreators(operators.OfType<IBinaryVectorCreator>());
    126126      ConfigureCrossovers(operators.OfType<IBinaryVectorCrossover>());
  • branches/ProblemRefactoring/HeuristicLab.Encodings.IntegerVectorEncoding/3.3/IntegerVectorEncoding.cs

    r13364 r13396  
    187187    #endregion
    188188
    189     public override void ConfigureOperators(IEnumerable<IOperator> operators) {
     189    public override void ConfigureOperators(IEnumerable<IItem> operators) {
    190190      ConfigureBoundedOperators(operators.OfType<IBoundedIntegerVectorOperator>());
    191191      ConfigureCreators(operators.OfType<IIntegerVectorCreator>());
  • branches/ProblemRefactoring/HeuristicLab.Encodings.LinearLinkageEncoding/3.3/LinearLinkageEncoding.cs

    r13372 r13396  
    123123    #endregion
    124124
    125     public override void ConfigureOperators(IEnumerable<IOperator> operators) {
     125    public override void ConfigureOperators(IEnumerable<IItem> operators) {
    126126      ConfigureCreators(operators.OfType<ILinearLinkageCreator>());
    127127      ConfigureCrossovers(operators.OfType<ILinearLinkageCrossover>());
  • branches/ProblemRefactoring/HeuristicLab.Encodings.PermutationEncoding/3.3/HeuristicLab.Encodings.PermutationEncoding-3.3.csproj

    r11961 r13396  
    128128    <Compile Include="Crossovers\PositionBasedCrossover.cs" />
    129129    <Compile Include="Crossovers\UniformLikeCrossover.cs" />
     130    <Compile Include="Interfaces\IPermutationInversionMoveQualityOperator.cs" />
     131    <Compile Include="Interfaces\IPermutationLocalImprovementOperator.cs" />
     132    <Compile Include="Interfaces\IPermutationScrambleMoveQualityOperator.cs" />
    130133    <Compile Include="Interfaces\IPermutationScrambleMoveOperator.cs" />
    131134    <Compile Include="Interfaces\IPermutationMultiNeighborhoodShakingOperator.cs" />
     135    <Compile Include="Interfaces\IPermutationSolutionsOperator.cs" />
     136    <Compile Include="Interfaces\IPermutationSolutionOperator.cs" />
     137    <Compile Include="Interfaces\IPermutationSwap2MoveQualityOperator.cs" />
    132138    <Compile Include="Interfaces\IPermutationSwap2MoveOperator.cs" />
    133139    <Compile Include="Interfaces\IPermutationCreator.cs" />
     
    136142    <Compile Include="Interfaces\IPermutationMoveOperator.cs" />
    137143    <Compile Include="Interfaces\IPermutationOperator.cs" />
     144    <Compile Include="Interfaces\IPermutationTranslocationMoveQualityOperator.cs" />
    138145    <Compile Include="Interfaces\IPermutationTranslocationMoveOperator.cs" />
    139146    <Compile Include="Interfaces\IPermutationInversionMoveOperator.cs" />
  • branches/ProblemRefactoring/HeuristicLab.Encodings.PermutationEncoding/3.3/Interfaces/IPermutationCreator.cs

    r13366 r13396  
    2828  /// An interface which represents an operator for creating permutations.
    2929  /// </summary>
    30   public interface IPermutationCreator : IPermutationOperator, ISolutionCreator<Permutation> {
     30  public interface IPermutationCreator : IPermutationSolutionOperator, ISolutionCreator<Permutation> {
    3131    IValueLookupParameter<IntValue> LengthParameter { get; }
    32     ILookupParameter<Permutation> PermutationParameter { get; }
    3332    IValueParameter<PermutationType> PermutationTypeParameter { get; }
    3433  }
  • branches/ProblemRefactoring/HeuristicLab.Encodings.PermutationEncoding/3.3/Interfaces/IPermutationInversionMoveQualityOperator.cs

    r13393 r13396  
    2121
    2222using HeuristicLab.Core;
     23using HeuristicLab.Data;
    2324
    2425namespace HeuristicLab.Encodings.PermutationEncoding {
    25   public interface IPermutationInversionMoveOperator : IPermutationMoveOperator {
    26     ILookupParameter<InversionMove> InversionMoveParameter { get; }
     26  public interface IPermutationInversionMoveQualityOperator : IPermutationInversionMoveOperator {
     27    ILookupParameter<DoubleValue> MoveQualityParameter { get; }
    2728  }
    2829}
  • branches/ProblemRefactoring/HeuristicLab.Encodings.PermutationEncoding/3.3/Interfaces/IPermutationManipulator.cs

    r12012 r13396  
    2020#endregion
    2121
    22 using HeuristicLab.Core;
    2322using HeuristicLab.Optimization;
    2423
     
    2726  /// An interface which represents an operator for manipulating solutions.
    2827  /// </summary>
    29   public interface IPermutationManipulator : IPermutationOperator, IManipulator {
    30     ILookupParameter<Permutation> PermutationParameter { get; }
    31   }
     28  public interface IPermutationManipulator : IPermutationSolutionOperator, IManipulator { }
    3229}
  • branches/ProblemRefactoring/HeuristicLab.Encodings.PermutationEncoding/3.3/Interfaces/IPermutationScrambleMoveQualityOperator.cs

    r13393 r13396  
    2121
    2222using HeuristicLab.Core;
     23using HeuristicLab.Data;
    2324
    2425namespace HeuristicLab.Encodings.PermutationEncoding {
    25   public interface IPermutationScrambleMoveOperator : IPermutationMoveOperator {
    26     ILookupParameter<ScrambleMove> ScrambleMoveParameter { get; }
     26  public interface IPermutationScrambleMoveQualityOperator : IPermutationScrambleMoveOperator {
     27    ILookupParameter<DoubleValue> MoveQualityParameter { get; }
    2728  }
    2829}
  • branches/ProblemRefactoring/HeuristicLab.Encodings.PermutationEncoding/3.3/Interfaces/IPermutationSwap2MoveQualityOperator.cs

    r13393 r13396  
    2121
    2222using HeuristicLab.Core;
     23using HeuristicLab.Data;
    2324
    2425namespace HeuristicLab.Encodings.PermutationEncoding {
    25   public interface IPermutationSwap2MoveOperator : IPermutationMoveOperator {
    26     ILookupParameter<Swap2Move> Swap2MoveParameter { get; }
     26  public interface IPermutationSwap2MoveQualityOperator : IPermutationSwap2MoveOperator {
     27    ILookupParameter<DoubleValue> MoveQualityParameter { get; }
    2728  }
    2829}
  • branches/ProblemRefactoring/HeuristicLab.Encodings.PermutationEncoding/3.3/Interfaces/IPermutationTranslocationMoveQualityOperator.cs

    r13393 r13396  
    2121
    2222using HeuristicLab.Core;
     23using HeuristicLab.Data;
    2324
    2425namespace HeuristicLab.Encodings.PermutationEncoding {
    25   public interface IPermutationTranslocationMoveOperator : IPermutationMoveOperator {
    26     ILookupParameter<TranslocationMove> TranslocationMoveParameter { get; }
     26  public interface IPermutationTranslocationMoveQualityOperator : IPermutationTranslocationMoveOperator {
     27    ILookupParameter<DoubleValue> MoveQualityParameter { get; }
    2728  }
    2829}
  • branches/ProblemRefactoring/HeuristicLab.Encodings.PermutationEncoding/3.3/Moves/Scramble/ScrambleMoveMaker.cs

    r12012 r13396  
    3131  [Item("ScrambleMoveMaker", "Peforms a scramble move on a given permutation and updates the quality.")]
    3232  [StorableClass]
    33   public class ScrambleMoveMaker : SingleSuccessorOperator, IPermutationScrambleMoveOperator, IMoveMaker, ISingleObjectiveOperator {
     33  public class ScrambleMoveMaker : SingleSuccessorOperator, IPermutationScrambleMoveQualityOperator, IMoveMaker, ISingleObjectiveOperator {
    3434    public override bool CanChangeName {
    3535      get { return false; }
  • branches/ProblemRefactoring/HeuristicLab.Encodings.PermutationEncoding/3.3/Moves/Swap2/Swap2MoveHardTabuCriterion.cs

    r12012 r13396  
    3535If the aspiration condition is activated, a move will not be considered tabu against a move in the tabu list if it leads to a better solution than the quality recorded with the move in the tabu list.")]
    3636  [StorableClass]
    37   public class Swap2MoveHardTabuCriterion : SingleSuccessorOperator, IPermutationSwap2MoveOperator, ITabuChecker {
     37  public class Swap2MoveHardTabuCriterion : SingleSuccessorOperator, IPermutationSwap2MoveQualityOperator, ITabuChecker {
    3838    public override bool CanChangeName {
    3939      get { return false; }
  • branches/ProblemRefactoring/HeuristicLab.Encodings.PermutationEncoding/3.3/Moves/Swap2/Swap2MoveMaker.cs

    r12012 r13396  
    3131  [Item("Swap2MoveMaker", "Peforms a swap-2 move on a given permutation and updates the quality.")]
    3232  [StorableClass]
    33   public class Swap2MoveMaker : SingleSuccessorOperator, IPermutationSwap2MoveOperator, IMoveMaker, ISingleObjectiveOperator {
     33  public class Swap2MoveMaker : SingleSuccessorOperator, IPermutationSwap2MoveQualityOperator, IMoveMaker, ISingleObjectiveOperator {
    3434    public override bool CanChangeName {
    3535      get { return false; }
  • branches/ProblemRefactoring/HeuristicLab.Encodings.PermutationEncoding/3.3/Moves/Swap2/Swap2MoveSoftTabuCriterion.cs

    r12012 r13396  
    3535If the aspiration condition is activated, a move will not be considered tabu against a move in the tabu list if it leads to a better solution than the quality recorded with the move in the tabu list.")]
    3636  [StorableClass]
    37   public class Swap2MoveSoftTabuCriterion : SingleSuccessorOperator, IPermutationSwap2MoveOperator, ITabuChecker {
     37  public class Swap2MoveSoftTabuCriterion : SingleSuccessorOperator, IPermutationSwap2MoveQualityOperator, ITabuChecker {
    3838    public override bool CanChangeName {
    3939      get { return false; }
  • branches/ProblemRefactoring/HeuristicLab.Encodings.PermutationEncoding/3.3/Moves/Swap2/Swap2MoveTabuMaker.cs

    r12012 r13396  
    2929  [Item("Swap2MoveTabuMaker", "Declares a given swap-2 move as tabu, by adding its attributes to the tabu list and also store the solution quality or the move quality (whichever is better).")]
    3030  [StorableClass]
    31   public class Swap2MoveTabuMaker : TabuMaker, IPermutationSwap2MoveOperator {
     31  public class Swap2MoveTabuMaker : TabuMaker, IPermutationSwap2MoveQualityOperator {
    3232    public ILookupParameter<Permutation> PermutationParameter {
    3333      get { return (ILookupParameter<Permutation>)Parameters["Permutation"]; }
  • branches/ProblemRefactoring/HeuristicLab.Encodings.PermutationEncoding/3.3/Moves/ThreeOpt/TranslocationMoveHardTabuCriterion.cs

    r12012 r13396  
    3434If the aspiration condition is activated, a move will not be considered tabu against a move in the tabu list if it leads to a better solution than the quality recorded with the move in the tabu list.")]
    3535  [StorableClass]
    36   public class TranslocationMoveHardTabuCriterion : SingleSuccessorOperator, IPermutationTranslocationMoveOperator, ITabuChecker {
     36  public class TranslocationMoveHardTabuCriterion : SingleSuccessorOperator, IPermutationTranslocationMoveQualityOperator, ITabuChecker {
    3737    public override bool CanChangeName {
    3838      get { return false; }
  • branches/ProblemRefactoring/HeuristicLab.Encodings.PermutationEncoding/3.3/Moves/ThreeOpt/TranslocationMoveMaker.cs

    r12012 r13396  
    3131  [Item("TranslocationMoveMaker", "Peforms a translocation or insertion move (3-opt) on a given permutation and updates the quality.")]
    3232  [StorableClass]
    33   public class TranslocationMoveMaker : SingleSuccessorOperator, IPermutationTranslocationMoveOperator, IMoveMaker, ISingleObjectiveOperator {
     33  public class TranslocationMoveMaker : SingleSuccessorOperator, IPermutationTranslocationMoveQualityOperator, IMoveMaker, ISingleObjectiveOperator {
    3434    public override bool CanChangeName {
    3535      get { return false; }
  • branches/ProblemRefactoring/HeuristicLab.Encodings.PermutationEncoding/3.3/Moves/ThreeOpt/TranslocationMoveSoftTabuCriterion.cs

    r12012 r13396  
    3434If the aspiration condition is activated, a move will not be considered tabu against a move in the tabu list if it leads to a better solution than the quality recorded with the move in the tabu list.")]
    3535  [StorableClass]
    36   public class TranslocationMoveSoftTabuCriterion : SingleSuccessorOperator, IPermutationTranslocationMoveOperator, ITabuChecker {
     36  public class TranslocationMoveSoftTabuCriterion : SingleSuccessorOperator, IPermutationTranslocationMoveQualityOperator, ITabuChecker {
    3737    public override bool CanChangeName {
    3838      get { return false; }
  • branches/ProblemRefactoring/HeuristicLab.Encodings.PermutationEncoding/3.3/Moves/ThreeOpt/TranslocationMoveTabuMaker.cs

    r12012 r13396  
    2929  [Item("TranslocationMoveTabuMaker", "Declares a given translocation or insertion move (3-opt) as tabu, by adding its attributes to the tabu list.")]
    3030  [StorableClass]
    31   public class TranslocationMoveTabuMaker : TabuMaker, IPermutationTranslocationMoveOperator {
     31  public class TranslocationMoveTabuMaker : TabuMaker, IPermutationTranslocationMoveQualityOperator {
    3232    public ILookupParameter<Permutation> PermutationParameter {
    3333      get { return (ILookupParameter<Permutation>)Parameters["Permutation"]; }
  • branches/ProblemRefactoring/HeuristicLab.Encodings.PermutationEncoding/3.3/Moves/TwoOpt/InversionMoveHardTabuCriterion.cs

    r12012 r13396  
    3535If the aspiration condition is activated, a move will not be considered tabu against a move in the tabu list if it leads to a better solution than the quality recorded with the move in the tabu list.")]
    3636  [StorableClass]
    37   public class InversionMoveHardTabuCriterion : SingleSuccessorOperator, IPermutationInversionMoveOperator, ITabuChecker {
     37  public class InversionMoveHardTabuCriterion : SingleSuccessorOperator, IPermutationInversionMoveQualityOperator, ITabuChecker {
    3838    public override bool CanChangeName {
    3939      get { return false; }
  • branches/ProblemRefactoring/HeuristicLab.Encodings.PermutationEncoding/3.3/Moves/TwoOpt/InversionMoveMaker.cs

    r12012 r13396  
    3131  [Item("InversionMoveMaker", "Peforms an inversion move (2-opt) on a given permutation and updates the quality.")]
    3232  [StorableClass]
    33   public class InversionMoveMaker : SingleSuccessorOperator, IPermutationInversionMoveOperator, IMoveMaker, ISingleObjectiveOperator {
     33  public class InversionMoveMaker : SingleSuccessorOperator, IPermutationInversionMoveQualityOperator, IMoveMaker, ISingleObjectiveOperator {
    3434    public override bool CanChangeName {
    3535      get { return false; }
  • branches/ProblemRefactoring/HeuristicLab.Encodings.PermutationEncoding/3.3/Moves/TwoOpt/InversionMoveSoftTabuCriterion.cs

    r12012 r13396  
    3535If the aspiration condition is activated, a move will not be considered tabu against a move in the tabu list if it leads to a better solution than the quality recorded with the move in the tabu list.")]
    3636  [StorableClass]
    37   public class InversionMoveSoftTabuCriterion : SingleSuccessorOperator, IPermutationInversionMoveOperator, ITabuChecker {
     37  public class InversionMoveSoftTabuCriterion : SingleSuccessorOperator, IPermutationInversionMoveQualityOperator, ITabuChecker {
    3838    public override bool CanChangeName {
    3939      get { return false; }
  • branches/ProblemRefactoring/HeuristicLab.Encodings.PermutationEncoding/3.3/Moves/TwoOpt/InversionMoveTabuMaker.cs

    r12012 r13396  
    2929  [Item("InversionMoveTabuMaker", "Declares a given inversion move (2-opt) as tabu, by adding its attributes to the tabu list and also store the solution quality or the move quality (whichever is better).")]
    3030  [StorableClass]
    31   public class InversionMoveTabuMaker : TabuMaker, IPermutationInversionMoveOperator {
     31  public class InversionMoveTabuMaker : TabuMaker, IPermutationInversionMoveQualityOperator {
    3232    public ILookupParameter<Permutation> PermutationParameter {
    3333      get { return (ILookupParameter<Permutation>)Parameters["Permutation"]; }
  • branches/ProblemRefactoring/HeuristicLab.Encodings.PermutationEncoding/3.3/PermutationEncoding.cs

    r13366 r13396  
    145145          typeof (IPermutationScrambleMoveOperator),
    146146          typeof (IPermutationSwap2MoveOperator),                   
    147           typeof (IPermutationTranslocationMoveOperator)
     147          typeof (IPermutationTranslocationMoveOperator),
     148          typeof (IPermutationLocalImprovementOperator),
     149          typeof (IPermutationSolutionOperator),
     150          typeof (IPermutationSolutionsOperator),
    148151      };
    149152    }
     
    160163    #endregion
    161164
    162     public override void ConfigureOperators(IEnumerable<IOperator> operators) {
     165    public override void ConfigureOperators(IEnumerable<IItem> operators) {
    163166      ConfigureCreators(operators.OfType<IPermutationCreator>());
    164167      ConfigureCrossovers(operators.OfType<IPermutationCrossover>());
     
    170173      ConfigureSwap2MoveOperators(operators.OfType<IPermutationSwap2MoveOperator>());
    171174      ConfigureTranslocationMoveOperators(operators.OfType<IPermutationTranslocationMoveOperator>());
     175      ConfigureLocalImprovementOperators(operators.OfType<IPermutationLocalImprovementOperator>());
     176      ConfigureSolutionOperators(operators.OfType<IPermutationSolutionOperator>());
     177      ConfigureSolutionsOperators(operators.OfType<IPermutationSolutionsOperator>());
    172178    }
    173179
     
    176182      foreach (var creator in creators) {
    177183        creator.LengthParameter.ActualName = LengthParameter.Name;
    178         creator.PermutationParameter.ActualName = Name;
    179184        creator.PermutationTypeParameter.Value.Value = Type;
    180185      }
     
    187192    }
    188193    private void ConfigureManipulators(IEnumerable<IPermutationManipulator> manipulators) {
    189       foreach (var manipulator in manipulators) {
    190         manipulator.PermutationParameter.ActualName = Name;
    191       }
     194      // IPermutationManipulator does not contain additional parameters (already contained in IPermutationSolutionOperator)
    192195    }
    193196    private void ConfigureShakingOperators(IEnumerable<IPermutationMultiNeighborhoodShakingOperator> shakingOperators) {
     
    221224      }
    222225    }
    223 
     226    private void ConfigureLocalImprovementOperators(IEnumerable<IPermutationLocalImprovementOperator> localImprovementOperators) {
     227      // IPermutationLocalImprovementOperator does not contain additional parameters (already contained in IPermutationSolutionOperator)
     228    }
     229    private void ConfigureSolutionOperators(IEnumerable<IPermutationSolutionOperator> solutionOperators) {
     230      foreach (var solutionOperator in solutionOperators) {
     231        solutionOperator.PermutationParameter.ActualName = Name;
     232      }
     233    }
     234    private void ConfigureSolutionsOperators(IEnumerable<IPermutationSolutionsOperator> solutionsOperators) {
     235      foreach (var solutionsOperator in solutionsOperators) {
     236        solutionsOperator.PermutationsParameter.ActualName = Name;
     237      }
     238    }
    224239    #endregion
    225240  }
  • branches/ProblemRefactoring/HeuristicLab.Encodings.RealVectorEncoding/3.3/RealVectorEncoding.cs

    r13361 r13396  
    197197    }
    198198
    199     public override void ConfigureOperators(IEnumerable<IOperator> operators) {
     199    public override void ConfigureOperators(IEnumerable<IItem> operators) {
    200200      ConfigureCreators(operators.OfType<IRealVectorCreator>());
    201201      ConfigureCrossovers(operators.OfType<IRealVectorCrossover>());
  • branches/ProblemRefactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionTreeEncoding.cs

    r13382 r13396  
    282282    #region Specific operator wiring
    283283
    284     public override void ConfigureOperators(IEnumerable<IOperator> operators) {
     284    public override void ConfigureOperators(IEnumerable<IItem> operators) {
    285285      ConfigureTreeOperators(operators.OfType<ISymbolicExpressionTreeOperator>());
    286286      ConfigureSizeConstraintOperators(operators.OfType<ISymbolicExpressionTreeSizeConstraintOperator>());
  • branches/ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/CombinedEncoding.cs

    r13376 r13396  
    8888    }
    8989
    90     public override void ConfigureOperators(IEnumerable<IOperator> operators) {
     90    public override void ConfigureOperators(IEnumerable<IItem> operators) {
    9191      foreach (var encOp in operators.OfType<IMultiEncodingOperator>())
    9292        encOp.SolutionParameter.ActualName = Name;
  • branches/ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Encoding.cs

    r13351 r13396  
    100100    }
    101101
    102     public void ConfigureOperator(IOperator @operator) { ConfigureOperators(new[] { @operator }); }
    103     public abstract void ConfigureOperators(IEnumerable<IOperator> operators);
     102    public void ConfigureOperator(IItem @operator) { ConfigureOperators(new[] { @operator }); }
     103    public abstract void ConfigureOperators(IEnumerable<IItem> operators);
    104104
    105105    public event EventHandler SolutionCreatorChanged;
  • branches/ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Interfaces/IEncoding.cs

    r13351 r13396  
    2929    IEnumerable<IOperator> Operators { get; set; }
    3030
    31     void ConfigureOperator(IOperator @operator);
    32     void ConfigureOperators(IEnumerable<IOperator> operators);
     31    void ConfigureOperator(IItem @operator);
     32    void ConfigureOperators(IEnumerable<IItem> operators);
    3333
    3434    event EventHandler SolutionCreatorChanged;
  • branches/ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Problem.cs

    r13376 r13396  
    3535    where TEvaluator : class, IEvaluator {
    3636
    37     public string Filename { get; set; }
     37    public string Filename { get; set; } // TODO: Really okay here?
    3838
    3939    protected IValueParameter<TEncoding> EncodingParameter {
     
    7171        Parameterize();
    7272      }
     73      RegisterEvents();
     74    }
     75    protected Problem(TEncoding encoding) {
     76      if (encoding == null) throw new ArgumentNullException("encoding");
     77      Parameters.Add(new ValueParameter<TEncoding>("Encoding", "Describes the configuration of the encoding, what the variables are called, what type they are and their bounds if any.", encoding));
     78      oldEncoding = Encoding;
     79      SolutionCreator = Encoding.SolutionCreator;
     80      Parameterize();
     81
    7382      RegisterEvents();
    7483    }
  • branches/ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/SingleObjectiveProblem.cs

    r13388 r13396  
    4141    }
    4242
     43    protected IFixedValueParameter<BoolValue> MaximizationParameter {
     44      get { return (IFixedValueParameter<BoolValue>)Parameters["Maximization"]; }
     45    }
     46
    4347    public double BestKnownQuality {
    4448      get {
     
    6266    protected SingleObjectiveProblem()
    6367      : base() {
     68      Parameters.Add(new FixedValueParameter<BoolValue>("Maximization", "Set to false if the problem should be minimized.", (BoolValue)new BoolValue(Maximization).AsReadOnly()) { Hidden = true });
     69      Parameters.Add(new OptionalValueParameter<DoubleValue>("BestKnownQuality", "The quality of the best known solution of this problem."));
     70
     71      Operators.Add(Evaluator);
     72      Operators.Add(new SingleObjectiveAnalyzer<TSolution>());
     73      Operators.Add(new SingleObjectiveImprover<TSolution>());
     74      Operators.Add(new SingleObjectiveMoveEvaluator<TSolution>());
     75      Operators.Add(new SingleObjectiveMoveGenerator<TSolution>());
     76      Operators.Add(new SingleObjectiveMoveMaker<TSolution>());
     77
     78      ParameterizeOperators();
     79    }
     80
     81    protected SingleObjectiveProblem(TEncoding encoding)
     82      : base(encoding) {
    6483      Parameters.Add(new FixedValueParameter<BoolValue>("Maximization", "Set to false if the problem should be minimized.", (BoolValue)new BoolValue(Maximization).AsReadOnly()) { Hidden = true });
    6584      Parameters.Add(new OptionalValueParameter<DoubleValue>("BestKnownQuality", "The quality of the best known solution of this problem."));
  • branches/ProblemRefactoring/HeuristicLab.Optimization/3.3/Interfaces/ISolutionCreator.cs

    r13336 r13396  
    2828  public interface ISolutionCreator : IOperator { }
    2929
    30   public interface ISolutionCreator<TSolution> : ISolutionCreator where TSolution : class, ISolution { }
     30  public interface ISolutionCreator<TSolution> : ISolutionCreator where TSolution : class, ISolution {
     31    //ILookupParameter<TSolution> SolutionParameter { get; } // TODO: unify encoding specific parameters by defining ISolutionOperator and ISolutionsOperator
     32  }
    3133}
  • branches/ProblemRefactoring/HeuristicLab.Problems.QuadraticAssignment.Algorithms/3.3/RobustTabooSeachOperator.cs

    r12855 r13396  
    3131
    3232namespace HeuristicLab.Problems.QuadraticAssignment.Algorithms {
    33   [Item("RobustTabooSearchOperator", "Performs an iteration of the robust taboo search algorithm as descrbied in Taillard 1991.")]
     33  [Item("RobustTabooSearchOperator", "Performs an iteration of the robust taboo search algorithm as described in Taillard 1991.")]
    3434  [StorableClass]
    35   public sealed class RobustTabooSeachOperator : SingleSuccessorOperator, IIterationBasedOperator, IStochasticOperator, ISingleObjectiveOperator {
     35  public sealed class RobustTabooSeachOperator : SingleSuccessorOperator, IIterationBasedOperator, IStochasticOperator, ISingleObjectiveOperator, IPermutationSolutionOperator {
    3636
    3737    #region Parameter Properties
  • branches/ProblemRefactoring/HeuristicLab.Problems.QuadraticAssignment.Algorithms/3.3/RobustTabooSearch.cs

    r13173 r13396  
    401401
    402402        mainOperator.DistancesParameter.ActualName = Problem.DistancesParameter.Name;
    403         mainOperator.PermutationParameter.ActualName = Problem.SolutionCreator.PermutationParameter.ActualName;
    404403        mainOperator.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;
    405404        mainOperator.WeightsParameter.ActualName = Problem.WeightsParameter.Name;
     405
     406        Problem.Encoding.ConfigureOperators(new IOperator[] { mainOperator });
    406407      }
    407408    }
  • branches/ProblemRefactoring/HeuristicLab.Problems.QuadraticAssignment/3.3/Analyzers/BestQAPSolutionAnalyzer.cs

    r12012 r13396  
    3636  [Item("BestQAPSolutionAnalyzer", "An operator for analyzing the best solution of Quadratic Assignment Problems.")]
    3737  [StorableClass]
    38   public sealed class BestQAPSolutionAnalyzer : SingleSuccessorOperator, IAnalyzer, ISingleObjectiveOperator {
     38  public sealed class BestQAPSolutionAnalyzer : SingleSuccessorOperator, IAnalyzer, ISingleObjectiveOperator, IPermutationSolutionsOperator {
    3939    public bool EnabledByDefault {
    4040      get { return true; }
    4141    }
    4242
    43     public LookupParameter<BoolValue> MaximizationParameter {
    44       get { return (LookupParameter<BoolValue>)Parameters["Maximization"]; }
     43    public ILookupParameter<BoolValue> MaximizationParameter {
     44      get { return (ILookupParameter<BoolValue>)Parameters["Maximization"]; }
    4545    }
    46     public LookupParameter<DoubleMatrix> DistancesParameter {
    47       get { return (LookupParameter<DoubleMatrix>)Parameters["Distances"]; }
     46    public ILookupParameter<DoubleMatrix> DistancesParameter {
     47      get { return (ILookupParameter<DoubleMatrix>)Parameters["Distances"]; }
    4848    }
    49     public LookupParameter<DoubleMatrix> WeightsParameter {
    50       get { return (LookupParameter<DoubleMatrix>)Parameters["Weights"]; }
     49    public ILookupParameter<DoubleMatrix> WeightsParameter {
     50      get { return (ILookupParameter<DoubleMatrix>)Parameters["Weights"]; }
    5151    }
    52     public ScopeTreeLookupParameter<Permutation> PermutationParameter {
    53       get { return (ScopeTreeLookupParameter<Permutation>)Parameters["Permutation"]; }
     52    public IScopeTreeLookupParameter<Permutation> PermutationsParameter {
     53      get { return (IScopeTreeLookupParameter<Permutation>)Parameters["Permutations"]; }
    5454    }
    55     public ScopeTreeLookupParameter<DoubleValue> QualityParameter {
    56       get { return (ScopeTreeLookupParameter<DoubleValue>)Parameters["Quality"]; }
     55    public IScopeTreeLookupParameter<DoubleValue> QualityParameter {
     56      get { return (IScopeTreeLookupParameter<DoubleValue>)Parameters["Quality"]; }
    5757    }
    58     public LookupParameter<QAPAssignment> BestSolutionParameter {
    59       get { return (LookupParameter<QAPAssignment>)Parameters["BestSolution"]; }
     58    public ILookupParameter<QAPAssignment> BestSolutionParameter {
     59      get { return (ILookupParameter<QAPAssignment>)Parameters["BestSolution"]; }
    6060    }
    61     public ValueLookupParameter<ResultCollection> ResultsParameter {
    62       get { return (ValueLookupParameter<ResultCollection>)Parameters["Results"]; }
     61    public IValueLookupParameter<ResultCollection> ResultsParameter {
     62      get { return (IValueLookupParameter<ResultCollection>)Parameters["Results"]; }
    6363    }
    64     public LookupParameter<DoubleValue> BestKnownQualityParameter {
    65       get { return (LookupParameter<DoubleValue>)Parameters["BestKnownQuality"]; }
     64    public ILookupParameter<DoubleValue> BestKnownQualityParameter {
     65      get { return (ILookupParameter<DoubleValue>)Parameters["BestKnownQuality"]; }
    6666    }
    67     public LookupParameter<ItemSet<Permutation>> BestKnownSolutionsParameter {
    68       get { return (LookupParameter<ItemSet<Permutation>>)Parameters["BestKnownSolutions"]; }
     67    public ILookupParameter<ItemSet<Permutation>> BestKnownSolutionsParameter {
     68      get { return (ILookupParameter<ItemSet<Permutation>>)Parameters["BestKnownSolutions"]; }
    6969    }
    70     public LookupParameter<Permutation> BestKnownSolutionParameter {
    71       get { return (LookupParameter<Permutation>)Parameters["BestKnownSolution"]; }
     70    public ILookupParameter<Permutation> BestKnownSolutionParameter {
     71      get { return (ILookupParameter<Permutation>)Parameters["BestKnownSolution"]; }
    7272    }
    7373
     
    8383      Parameters.Add(new LookupParameter<DoubleMatrix>("Distances", "The distances between the locations."));
    8484      Parameters.Add(new LookupParameter<DoubleMatrix>("Weights", "The weights between the facilities."));
    85       Parameters.Add(new ScopeTreeLookupParameter<Permutation>("Permutation", "The QAP solutions from which the best solution should be analyzed."));
     85      Parameters.Add(new ScopeTreeLookupParameter<Permutation>("Permutations", "The QAP solutions from which the best solution should be analyzed."));
    8686      Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Quality", "The qualities of the QAP solutions which should be analyzed."));
    8787      Parameters.Add(new LookupParameter<QAPAssignment>("BestSolution", "The best QAP solution."));
     
    109109      DoubleMatrix distances = DistancesParameter.ActualValue;
    110110      DoubleMatrix weights = WeightsParameter.ActualValue;
    111       ItemArray<Permutation> permutations = PermutationParameter.ActualValue;
     111      ItemArray<Permutation> permutations = PermutationsParameter.ActualValue;
    112112      ItemArray<DoubleValue> qualities = QualityParameter.ActualValue;
    113113      ResultCollection results = ResultsParameter.ActualValue;
  • branches/ProblemRefactoring/HeuristicLab.Problems.QuadraticAssignment/3.3/Analyzers/QAPAlleleFrequencyAnalyzer.cs

    r12012 r13396  
    3636  [StorableClass]
    3737  public sealed class QAPAlleleFrequencyAnalyzer : AlleleFrequencyAnalyzer<Permutation> {
    38     public LookupParameter<DoubleMatrix> WeightsParameter {
    39       get { return (LookupParameter<DoubleMatrix>)Parameters["Weights"]; }
     38    public ILookupParameter<DoubleMatrix> WeightsParameter {
     39      get { return (ILookupParameter<DoubleMatrix>)Parameters["Weights"]; }
    4040    }
    41     public LookupParameter<DoubleMatrix> DistancesParameter {
    42       get { return (LookupParameter<DoubleMatrix>)Parameters["Distances"]; }
     41    public ILookupParameter<DoubleMatrix> DistancesParameter {
     42      get { return (ILookupParameter<DoubleMatrix>)Parameters["Distances"]; }
    4343    }
    4444
  • branches/ProblemRefactoring/HeuristicLab.Problems.QuadraticAssignment/3.3/HeuristicLab.Problems.QuadraticAssignment-3.3.csproj

    r11623 r13396  
    124124    <Compile Include="Evaluators\QAPScrambleMoveEvaluator.cs" />
    125125    <Compile Include="Evaluators\QAPSwap2MoveEvaluator.cs" />
    126     <Compile Include="Evaluators\QAPEvaluator.cs" />
    127126    <Compile Include="Evaluators\QAPInversionMoveEvaluator.cs" />
    128127    <Compile Include="Evaluators\QAPMoveEvaluator.cs" />
     
    130129      <SubType>Code</SubType>
    131130    </Compile>
    132     <Compile Include="Interfaces\IQAPEvaluator.cs" />
     131    <Compile Include="Interfaces\IQAPLocalImprovementOperator.cs" />
    133132    <Compile Include="Interfaces\IQAPMoveEvaluator.cs" />
    134133    <Compile Include="LocalImprovement\QAPExhaustiveInsertionLocalImprovement.cs" />
     
    224223    </ProjectReference>
    225224  </ItemGroup>
     225  <ItemGroup>
     226    <Folder Include="SimilarityCalculators\" />
     227  </ItemGroup>
    226228  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
    227229  <PropertyGroup>
  • branches/ProblemRefactoring/HeuristicLab.Problems.QuadraticAssignment/3.3/Interfaces/IQAPLocalImprovementOperator.cs

    r13393 r13396  
    2323using HeuristicLab.Data;
    2424using HeuristicLab.Encodings.PermutationEncoding;
    25 using HeuristicLab.Optimization;
    2625
    2726namespace HeuristicLab.Problems.QuadraticAssignment {
    28   public interface IQAPEvaluator : ISingleObjectiveEvaluator {
    29     ILookupParameter<Permutation> PermutationParameter { get; }
     27  public interface IQAPLocalImprovementOperator : IPermutationLocalImprovementOperator {
    3028    ILookupParameter<DoubleMatrix> DistancesParameter { get; }
     29    ILookupParameter<BoolValue> MaximizationParameter { get; }
     30    ILookupParameter<DoubleValue> QualityParameter { get; }
    3131    ILookupParameter<DoubleMatrix> WeightsParameter { get; }
    3232  }
  • branches/ProblemRefactoring/HeuristicLab.Problems.QuadraticAssignment/3.3/LocalImprovement/QAPExhaustiveInsertionLocalImprovement.cs

    r12012 r13396  
    3434  [Item("QAPExhaustiveInsertionLocalImprovement", "Takes a solution and finds the local optimum with respect to the insertion neighborhood by decending along the steepest gradient.")]
    3535  [StorableClass]
    36   public class QAPExhaustiveInsertionLocalImprovement : SingleSuccessorOperator, ILocalImprovementOperator, ISingleObjectiveOperator {
     36  public class QAPExhaustiveInsertionLocalImprovement : SingleSuccessorOperator, IQAPLocalImprovementOperator, ISingleObjectiveOperator {
    3737
    3838    public ILookupParameter<IntValue> LocalIterationsParameter {
     
    5252    }
    5353
    54     public ILookupParameter<Permutation> AssignmentParameter {
    55       get { return (ILookupParameter<Permutation>)Parameters["Assignment"]; }
     54    public ILookupParameter<Permutation> PermutationParameter {
     55      get { return (ILookupParameter<Permutation>)Parameters["Permutation"]; }
    5656    }
    5757
     
    8383      Parameters.Add(new LookupParameter<IntValue>("EvaluatedSolutions", "The amount of evaluated solutions (here a move is counted only as 4/n evaluated solutions with n being the length of the permutation)."));
    8484      Parameters.Add(new LookupParameter<ResultCollection>("Results", "The collection where to store results."));
    85       Parameters.Add(new LookupParameter<Permutation>("Assignment", "The permutation that is to be locally optimized."));
     85      Parameters.Add(new LookupParameter<Permutation>("Permutation", "The permutation that is to be locally optimized."));
    8686      Parameters.Add(new LookupParameter<DoubleValue>("Quality", "The quality value of the assignment."));
    8787      Parameters.Add(new LookupParameter<BoolValue>("Maximization", "True if the problem should be maximized or minimized."));
     
    122122    public override IOperation Apply() {
    123123      var maxIterations = MaximumIterationsParameter.ActualValue.Value;
    124       var assignment = AssignmentParameter.ActualValue;
     124      var assignment = PermutationParameter.ActualValue;
    125125      var maximization = MaximizationParameter.ActualValue.Value;
    126126      var weights = WeightsParameter.ActualValue;
  • branches/ProblemRefactoring/HeuristicLab.Problems.QuadraticAssignment/3.3/LocalImprovement/QAPExhaustiveInversionLocalImprovement.cs

    r12811 r13396  
    3434  [Item("QAPExhaustiveInversionLocalImprovement", "Takes a solution and finds the local optimum with respect to the inversion neighborhood by decending along the steepest gradient.")]
    3535  [StorableClass]
    36   public class QAPExhaustiveInversionLocalImprovement : SingleSuccessorOperator, ILocalImprovementOperator, ISingleObjectiveOperator {
     36  public class QAPExhaustiveInversionLocalImprovement : SingleSuccessorOperator, IQAPLocalImprovementOperator, ISingleObjectiveOperator {
    3737
    3838    public ILookupParameter<IntValue> LocalIterationsParameter {
     
    5252    }
    5353
    54     public ILookupParameter<Permutation> AssignmentParameter {
    55       get { return (ILookupParameter<Permutation>)Parameters["Assignment"]; }
     54    public ILookupParameter<Permutation> PermutationParameter {
     55      get { return (ILookupParameter<Permutation>)Parameters["Permutation"]; }
    5656    }
    5757
     
    8383      Parameters.Add(new LookupParameter<IntValue>("EvaluatedSolutions", "The amount of evaluated solutions (here a move is counted only as 4/n evaluated solutions with n being the length of the permutation)."));
    8484      Parameters.Add(new LookupParameter<ResultCollection>("Results", "The collection where to store results."));
    85       Parameters.Add(new LookupParameter<Permutation>("Assignment", "The permutation that is to be locally optimized."));
     85      Parameters.Add(new LookupParameter<Permutation>("Permutation", "The permutation that is to be locally optimized."));
    8686      Parameters.Add(new LookupParameter<DoubleValue>("Quality", "The quality value of the assignment."));
    8787      Parameters.Add(new LookupParameter<BoolValue>("Maximization", "True if the problem should be maximized or minimized."));
     
    119119    public override IOperation Apply() {
    120120      var maxIterations = MaximumIterationsParameter.ActualValue.Value;
    121       var assignment = AssignmentParameter.ActualValue;
     121      var assignment = PermutationParameter.ActualValue;
    122122      var maximization = MaximizationParameter.ActualValue.Value;
    123123      var weights = WeightsParameter.ActualValue;
  • branches/ProblemRefactoring/HeuristicLab.Problems.QuadraticAssignment/3.3/LocalImprovement/QAPExhaustiveSwap2LocalImprovement.cs

    r12012 r13396  
    3434  [Item("QAPExhaustiveSwap2LocalImprovement", "Takes a solution and finds the local optimum with respect to the swap2 neighborhood by decending along the steepest gradient.")]
    3535  [StorableClass]
    36   public class QAPExhaustiveSwap2LocalImprovement : SingleSuccessorOperator, ILocalImprovementOperator, ISingleObjectiveOperator {
     36  public class QAPExhaustiveSwap2LocalImprovement : SingleSuccessorOperator, IQAPLocalImprovementOperator, ISingleObjectiveOperator {
    3737
    3838    public ILookupParameter<IntValue> LocalIterationsParameter {
     
    5252    }
    5353
    54     public ILookupParameter<Permutation> AssignmentParameter {
    55       get { return (ILookupParameter<Permutation>)Parameters["Assignment"]; }
     54    public ILookupParameter<Permutation> PermutationParameter {
     55      get { return (ILookupParameter<Permutation>)Parameters["Permutation"]; }
    5656    }
    5757
     
    8787      Parameters.Add(new LookupParameter<IntValue>("EvaluatedSolutions", "The amount of evaluated solutions (here a move is counted only as 4/n evaluated solutions with n being the length of the permutation)."));
    8888      Parameters.Add(new LookupParameter<ResultCollection>("Results", "The collection where to store results."));
    89       Parameters.Add(new LookupParameter<Permutation>("Assignment", "The permutation that is to be locally optimized."));
     89      Parameters.Add(new LookupParameter<Permutation>("Permutation", "The permutation that is to be locally optimized."));
    9090      Parameters.Add(new LookupParameter<DoubleValue>("Quality", "The quality value of the assignment."));
    9191      Parameters.Add(new LookupParameter<BoolValue>("Maximization", "True if the problem should be maximized or minimized."));
     
    175175    public override IOperation Apply() {
    176176      var maxIterations = MaximumIterationsParameter.ActualValue.Value;
    177       var assignment = AssignmentParameter.ActualValue;
     177      var assignment = PermutationParameter.ActualValue;
    178178      var maximization = MaximizationParameter.ActualValue.Value;
    179179      var weights = WeightsParameter.ActualValue;
  • branches/ProblemRefactoring/HeuristicLab.Problems.QuadraticAssignment/3.3/LocalImprovement/QAPStochasticScrambleLocalImprovement.cs

    r12811 r13396  
    3434  [Item("QAPStochasticScrambleLocalImprovement", "Takes a solution and finds the local optimum with respect to the scramble neighborhood by decending along the steepest gradient.")]
    3535  [StorableClass]
    36   public class QAPStochasticScrambleLocalImprovement : SingleSuccessorOperator, ILocalImprovementOperator, IStochasticOperator, ISingleObjectiveOperator {
     36  public class QAPStochasticScrambleLocalImprovement : SingleSuccessorOperator, IQAPLocalImprovementOperator, IStochasticOperator, ISingleObjectiveOperator {
    3737
    3838    public ILookupParameter<IntValue> LocalIterationsParameter {
     
    5656    }
    5757
    58     public ILookupParameter<Permutation> AssignmentParameter {
    59       get { return (ILookupParameter<Permutation>)Parameters["Assignment"]; }
     58    public ILookupParameter<Permutation> PermutationParameter {
     59      get { return (ILookupParameter<Permutation>)Parameters["Permutation"]; }
    6060    }
    6161
     
    9292      Parameters.Add(new LookupParameter<IntValue>("EvaluatedSolutions", "The amount of evaluated solutions (here a move is counted only as 4/n evaluated solutions with n being the length of the permutation)."));
    9393      Parameters.Add(new LookupParameter<ResultCollection>("Results", "The collection where to store results."));
    94       Parameters.Add(new LookupParameter<Permutation>("Assignment", "The permutation that is to be locally optimized."));
     94      Parameters.Add(new LookupParameter<Permutation>("Permutation", "The permutation that is to be locally optimized."));
    9595      Parameters.Add(new LookupParameter<DoubleValue>("Quality", "The quality value of the assignment."));
    9696      Parameters.Add(new LookupParameter<BoolValue>("Maximization", "True if the problem should be maximized or minimized."));
     
    132132      var maxIterations = MaximumIterationsParameter.ActualValue.Value;
    133133      var neighborhoodSize = NeighborhoodSizeParameter.ActualValue.Value;
    134       var assignment = AssignmentParameter.ActualValue;
     134      var assignment = PermutationParameter.ActualValue;
    135135      var maximization = MaximizationParameter.ActualValue.Value;
    136136      var weights = WeightsParameter.ActualValue;
  • branches/ProblemRefactoring/HeuristicLab.Problems.QuadraticAssignment/3.3/QuadraticAssignmentProblem.cs

    r13377 r13396  
    3838  [Creatable(CreatableAttribute.Categories.CombinatorialProblems, Priority = 140)]
    3939  [StorableClass]
    40   public sealed class QuadraticAssignmentProblem : SingleObjectiveHeuristicOptimizationProblem<IQAPEvaluator, IPermutationCreator>,
    41     ISingleObjectiveProblem<PermutationEncoding, Permutation>, IStorableContent,
     40  public sealed class QuadraticAssignmentProblem : SingleObjectiveProblem<PermutationEncoding, Permutation>,
    4241    IProblemInstanceConsumer<QAPData>,
    4342    IProblemInstanceConsumer<TSPData> {
    44     public string Filename { get; set; }
    4543
    4644    public static new Image StaticItemImage {
    47       get { return HeuristicLab.Common.Resources.VSImageLibrary.Type; }
    48     }
     45      get { return Common.Resources.VSImageLibrary.Type; }
     46    }
     47
     48    public override bool Maximization { get { return false; } }
    4949
    5050    #region Parameter Properties
     
    115115    }
    116116    public QuadraticAssignmentProblem()
    117       : base(new QAPEvaluator(), new RandomPermutationCreator()) {
     117      : base(new PermutationEncoding("Assignment") { Length = 5 }) {
    118118      Parameters.Add(new OptionalValueParameter<ItemSet<Permutation>>("BestKnownSolutions", "The list of best known solutions which is updated whenever a new better solution is found or may be the optimal solution if it is known beforehand.", null));
    119119      Parameters.Add(new OptionalValueParameter<Permutation>("BestKnownSolution", "The best known solution which is updated whenever a new better solution is found or may be the optimal solution if it is known beforehand.", null));
     
    122122      Parameters.Add(new OptionalValueParameter<DoubleValue>("LowerBound", "The Gilmore-Lawler lower bound to the solution quality."));
    123123      Parameters.Add(new OptionalValueParameter<DoubleValue>("AverageQuality", "The expected quality of a random solution."));
    124 
    125       Maximization.Value = false;
    126       MaximizationParameter.Hidden = true;
    127124
    128125      WeightsParameter.GetsCollected = false;
     
    144141      });
    145142
    146       SolutionCreator.PermutationParameter.ActualName = "Assignment";
    147       ParameterizeSolutionCreator();
    148       ParameterizeEvaluator();
    149 
    150143      InitializeOperators();
    151144      RegisterEventHandlers();
    152145    }
    153146
     147    public override double Evaluate(Permutation assignment, IRandom random) {
     148      return Evaluate(assignment);
     149    }
     150
     151    public double Evaluate(Permutation assignment) {
     152      double quality = 0;
     153      for (int i = 0; i < assignment.Length; i++) {
     154        for (int j = 0; j < assignment.Length; j++) {
     155          quality += Weights[i, j] * Distances[assignment[i], assignment[j]];
     156        }
     157      }
     158      return quality;
     159    }
     160
    154161    public override IDeepCloneable Clone(Cloner cloner) {
    155162      return new QuadraticAssignmentProblem(this, cloner);
     
    158165    [StorableHook(HookType.AfterDeserialization)]
    159166    private void AfterDeserialization() {
    160       // BackwardsCompatibility3.3
    161       #region Backwards compatible code, remove with 3.4
    162       if (!Parameters.ContainsKey("BestKnownSolutions")) {
    163         Parameters.Add(new OptionalValueParameter<ItemSet<Permutation>>("BestKnownSolutions", "The list of best known solutions which is updated whenever a new better solution is found or may be the optimal solution if it is known beforehand.", null));
    164       } else if (Parameters["BestKnownSolutions"].GetType().Equals(typeof(OptionalValueParameter<ItemList<Permutation>>))) {
    165         ItemList<Permutation> list = ((OptionalValueParameter<ItemList<Permutation>>)Parameters["BestKnownSolutions"]).Value;
    166         Parameters.Remove("BestKnownSolutions");
    167         Parameters.Add(new OptionalValueParameter<ItemSet<Permutation>>("BestKnownSolutions", "The list of best known solutions which is updated whenever a new better solution is found or may be the optimal solution if it is known beforehand.", (list != null ? new ItemSet<Permutation>(list) : null)));
    168       }
    169       if (Parameters.ContainsKey("DistanceMatrix")) {
    170         DoubleMatrix d = ((ValueParameter<DoubleMatrix>)Parameters["DistanceMatrix"]).Value;
    171         Parameters.Remove("DistanceMatrix");
    172         Parameters.Add(new ValueParameter<DoubleMatrix>("Distances", "The distance matrix which can either be specified directly without the coordinates, or can be calculated automatically from the coordinates.", d));
    173       }
    174       if (!Parameters.ContainsKey("LowerBound")) {
    175         Parameters.Add(new OptionalValueParameter<DoubleValue>("LowerBound", "The Gilmore-Lawler lower bound to the solution quality."));
    176         LowerBound = new DoubleValue(GilmoreLawlerBoundCalculator.CalculateLowerBound(Weights, Distances));
    177       }
    178       if (!Parameters.ContainsKey("AverageQuality")) {
    179         Parameters.Add(new OptionalValueParameter<DoubleValue>("AverageQuality", "The expected quality of a random solution."));
    180         AverageQuality = new DoubleValue(ComputeAverageQuality());
    181       }
    182       #endregion
    183167      RegisterEventHandlers();
    184168    }
     
    186170    #region Events
    187171    protected override void OnSolutionCreatorChanged() {
    188       SolutionCreator.PermutationParameter.ActualNameChanged += new EventHandler(SolutionCreator_PermutationParameter_ActualNameChanged);
    189       ParameterizeSolutionCreator();
    190       ParameterizeEvaluator();
    191       ParameterizeAnalyzers();
    192       ParameterizeOperators();
     172      Parameterize();
    193173      base.OnSolutionCreatorChanged();
    194174    }
    195175    protected override void OnEvaluatorChanged() {
    196       Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
    197       ParameterizeEvaluator();
    198       ParameterizeAnalyzers();
    199       ParameterizeOperators();
     176      Evaluator.QualityParameter.ActualNameChanged += Evaluator_QualityParameter_ActualNameChanged;
     177      Parameterize();
    200178      base.OnEvaluatorChanged();
    201179    }
    202 
    203     private void SolutionCreator_PermutationParameter_ActualNameChanged(object sender, EventArgs e) {
    204       ParameterizeEvaluator();
    205       ParameterizeAnalyzers();
    206       ParameterizeOperators();
    207     }
    208180    private void Evaluator_QualityParameter_ActualNameChanged(object sender, EventArgs e) {
    209       ParameterizeAnalyzers();
    210       ParameterizeOperators();
     181      Parameterize();
    211182    }
    212183    private void WeightsParameter_ValueChanged(object sender, EventArgs e) {
    213       Weights.RowsChanged += new EventHandler(Weights_RowsChanged);
    214       Weights.ColumnsChanged += new EventHandler(Weights_ColumnsChanged);
    215       Weights.ToStringChanged += new EventHandler(Weights_ToStringChanged);
    216       ParameterizeSolutionCreator();
    217       ParameterizeEvaluator();
    218       ParameterizeOperators();
     184      Weights.RowsChanged += Weights_RowsChanged;
     185      Weights.ColumnsChanged += Weights_ColumnsChanged;
     186      Weights.ToStringChanged += Weights_ToStringChanged;
    219187      AdjustDistanceMatrix();
    220188    }
     
    223191        ((IStringConvertibleMatrix)Weights).Columns = Weights.Rows;
    224192      else {
    225         ParameterizeSolutionCreator();
    226         ParameterizeEvaluator();
    227         ParameterizeOperators();
    228193        AdjustDistanceMatrix();
    229194      }
     
    233198        ((IStringConvertibleMatrix)Weights).Rows = Weights.Columns;
    234199      else {
    235         ParameterizeSolutionCreator();
    236         ParameterizeEvaluator();
    237         ParameterizeOperators();
    238200        AdjustDistanceMatrix();
    239201      }
     
    243205    }
    244206    private void DistancesParameter_ValueChanged(object sender, EventArgs e) {
    245       Distances.RowsChanged += new EventHandler(Distances_RowsChanged);
    246       Distances.ColumnsChanged += new EventHandler(Distances_ColumnsChanged);
    247       Distances.ToStringChanged += new EventHandler(Distances_ToStringChanged);
    248       ParameterizeSolutionCreator();
    249       ParameterizeEvaluator();
    250       ParameterizeOperators();
     207      Distances.RowsChanged += Distances_RowsChanged;
     208      Distances.ColumnsChanged += Distances_ColumnsChanged;
     209      Distances.ToStringChanged += Distances_ToStringChanged;
    251210      AdjustWeightsMatrix();
    252211    }
     
    255214        ((IStringConvertibleMatrix)Distances).Columns = Distances.Rows;
    256215      else {
    257         ParameterizeSolutionCreator();
    258         ParameterizeEvaluator();
    259         ParameterizeOperators();
    260216        AdjustWeightsMatrix();
    261217      }
     
    265221        ((IStringConvertibleMatrix)Distances).Rows = Distances.Columns;
    266222      else {
    267         ParameterizeSolutionCreator();
    268         ParameterizeEvaluator();
    269         ParameterizeOperators();
    270223        AdjustWeightsMatrix();
    271224      }
     
    277230
    278231    private void RegisterEventHandlers() {
    279       SolutionCreator.PermutationParameter.ActualNameChanged += new EventHandler(SolutionCreator_PermutationParameter_ActualNameChanged);
    280       Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
    281       WeightsParameter.ValueChanged += new EventHandler(WeightsParameter_ValueChanged);
    282       Weights.RowsChanged += new EventHandler(Weights_RowsChanged);
    283       Weights.ColumnsChanged += new EventHandler(Weights_ColumnsChanged);
    284       Weights.ToStringChanged += new EventHandler(Weights_ToStringChanged);
    285       DistancesParameter.ValueChanged += new EventHandler(DistancesParameter_ValueChanged);
    286       Distances.RowsChanged += new EventHandler(Distances_RowsChanged);
    287       Distances.ColumnsChanged += new EventHandler(Distances_ColumnsChanged);
    288       Distances.ToStringChanged += new EventHandler(Distances_ToStringChanged);
     232      WeightsParameter.ValueChanged += WeightsParameter_ValueChanged;
     233      Weights.RowsChanged += Weights_RowsChanged;
     234      Weights.ColumnsChanged += Weights_ColumnsChanged;
     235      Weights.ToStringChanged += Weights_ToStringChanged;
     236      DistancesParameter.ValueChanged += DistancesParameter_ValueChanged;
     237      Distances.RowsChanged += Distances_RowsChanged;
     238      Distances.ColumnsChanged += Distances_ColumnsChanged;
     239      Distances.ToStringChanged += Distances_ToStringChanged;
    289240    }
    290241
     
    297248      });
    298249      Operators.AddRange(defaultOperators);
    299       Operators.AddRange(ApplicationManager.Manager.GetInstances<IPermutationOperator>().Except(defaultOperators, new TypeEqualityComparer<IPermutationOperator>()));
    300       Operators.RemoveAll(x => x is ISingleObjectiveMoveEvaluator);
    301250      Operators.AddRange(ApplicationManager.Manager.GetInstances<IQAPMoveEvaluator>());
     251      Operators.AddRange(ApplicationManager.Manager.GetInstances<IQAPLocalImprovementOperator>());
    302252      Operators.Add(new BestQAPSolutionAnalyzer());
    303253      Operators.Add(new QAPAlleleFrequencyAnalyzer());
    304254      Operators.Add(new QAPPopulationDiversityAnalyzer());
    305255
    306       Operators.Add(new QAPExhaustiveInsertionLocalImprovement());
    307       Operators.Add(new QAPExhaustiveInversionLocalImprovement());
    308       Operators.Add(new QAPStochasticScrambleLocalImprovement());
    309       Operators.Add(new QAPExhaustiveSwap2LocalImprovement());
    310 
    311256      Operators.Add(new QAPSimilarityCalculator());
    312       ParameterizeAnalyzers();
    313       ParameterizeOperators();
    314     }
    315     private void ParameterizeSolutionCreator() {
    316       if (SolutionCreator != null) {
    317         SolutionCreator.PermutationTypeParameter.Value = new PermutationType(PermutationTypes.Absolute);
    318         SolutionCreator.LengthParameter.Value = new IntValue(Weights.Rows);
    319       }
    320     }
    321     private void ParameterizeEvaluator() {
    322       if (Evaluator != null) {
    323         Evaluator.PermutationParameter.ActualName = SolutionCreator.PermutationParameter.ActualName;
    324         Evaluator.DistancesParameter.ActualName = DistancesParameter.Name;
    325         Evaluator.WeightsParameter.ActualName = WeightsParameter.Name;
    326       }
    327     }
    328     private void ParameterizeAnalyzers() {
     257      Parameterize();
     258    }
     259    private void Parameterize() {
     260      var operators = new List<IItem>();
    329261      if (BestQAPSolutionAnalyzer != null) {
     262        operators.Add(BestQAPSolutionAnalyzer);
    330263        BestQAPSolutionAnalyzer.QualityParameter.ActualName = Evaluator.QualityParameter.ActualName;
    331264        BestQAPSolutionAnalyzer.DistancesParameter.ActualName = DistancesParameter.Name;
    332265        BestQAPSolutionAnalyzer.WeightsParameter.ActualName = WeightsParameter.Name;
    333         BestQAPSolutionAnalyzer.PermutationParameter.ActualName = SolutionCreator.PermutationParameter.ActualName;
    334         BestQAPSolutionAnalyzer.ResultsParameter.ActualName = "Results";
    335266        BestQAPSolutionAnalyzer.BestKnownQualityParameter.ActualName = BestKnownQualityParameter.Name;
    336267        BestQAPSolutionAnalyzer.BestKnownSolutionsParameter.ActualName = BestKnownSolutionsParameter.Name;
     
    338269      }
    339270      if (QAPAlleleFrequencyAnalyzer != null) {
     271        operators.Add(QAPAlleleFrequencyAnalyzer);
    340272        QAPAlleleFrequencyAnalyzer.QualityParameter.ActualName = Evaluator.QualityParameter.ActualName;
    341273        QAPAlleleFrequencyAnalyzer.BestKnownSolutionParameter.ActualName = BestKnownSolutionParameter.Name;
    342274        QAPAlleleFrequencyAnalyzer.DistancesParameter.ActualName = DistancesParameter.Name;
    343275        QAPAlleleFrequencyAnalyzer.MaximizationParameter.ActualName = MaximizationParameter.Name;
    344         QAPAlleleFrequencyAnalyzer.ResultsParameter.ActualName = "Results";
    345         QAPAlleleFrequencyAnalyzer.SolutionParameter.ActualName = SolutionCreator.PermutationParameter.ActualName;
    346276        QAPAlleleFrequencyAnalyzer.WeightsParameter.ActualName = WeightsParameter.Name;
    347277      }
    348278      if (QAPPopulationDiversityAnalyzer != null) {
     279        operators.Add(QAPPopulationDiversityAnalyzer);
    349280        QAPPopulationDiversityAnalyzer.MaximizationParameter.ActualName = MaximizationParameter.Name;
    350281        QAPPopulationDiversityAnalyzer.QualityParameter.ActualName = Evaluator.QualityParameter.ActualName;
    351         QAPPopulationDiversityAnalyzer.ResultsParameter.ActualName = "Results";
    352         QAPPopulationDiversityAnalyzer.SolutionParameter.ActualName = SolutionCreator.PermutationParameter.ActualName;
    353       }
    354     }
    355     private void ParameterizeOperators() {
    356       foreach (IPermutationCrossover op in Operators.OfType<IPermutationCrossover>()) {
    357         op.ParentsParameter.ActualName = SolutionCreator.PermutationParameter.ActualName;
    358         op.ChildParameter.ActualName = SolutionCreator.PermutationParameter.ActualName;
    359       }
    360       foreach (IPermutationManipulator op in Operators.OfType<IPermutationManipulator>()) {
    361         op.PermutationParameter.ActualName = SolutionCreator.PermutationParameter.ActualName;
    362       }
    363       foreach (IPermutationMoveOperator op in Operators.OfType<IPermutationMoveOperator>()) {
    364         op.PermutationParameter.ActualName = SolutionCreator.PermutationParameter.ActualName;
    365       }
    366       if (Operators.OfType<IMoveGenerator>().Any()) {
    367         if (Operators.OfType<IMoveGenerator>().OfType<IPermutationInversionMoveOperator>().Any()) {
    368           string inversionMove = Operators.OfType<IMoveGenerator>().OfType<IPermutationInversionMoveOperator>().First().InversionMoveParameter.ActualName;
    369           foreach (IPermutationInversionMoveOperator op in Operators.OfType<IPermutationInversionMoveOperator>())
    370             op.InversionMoveParameter.ActualName = inversionMove;
    371         }
    372         if (Operators.OfType<IMoveGenerator>().OfType<IPermutationTranslocationMoveOperator>().Any()) {
    373           string translocationMove = Operators.OfType<IMoveGenerator>().OfType<IPermutationTranslocationMoveOperator>().First().TranslocationMoveParameter.ActualName;
    374           foreach (IPermutationTranslocationMoveOperator op in Operators.OfType<IPermutationTranslocationMoveOperator>())
    375             op.TranslocationMoveParameter.ActualName = translocationMove;
    376         }
    377         if (Operators.OfType<IMoveGenerator>().OfType<IPermutationSwap2MoveOperator>().Any()) {
    378           string swapMove = Operators.OfType<IMoveGenerator>().OfType<IPermutationSwap2MoveOperator>().First().Swap2MoveParameter.ActualName;
    379           foreach (IPermutationSwap2MoveOperator op in Operators.OfType<IPermutationSwap2MoveOperator>()) {
    380             op.Swap2MoveParameter.ActualName = swapMove;
    381           }
    382         }
    383       }
    384       foreach (var op in Operators.OfType<IPermutationMultiNeighborhoodShakingOperator>())
    385         op.PermutationParameter.ActualName = SolutionCreator.PermutationParameter.ActualName;
    386 
    387       QAPExhaustiveSwap2LocalImprovement localOpt = Operators.OfType<QAPExhaustiveSwap2LocalImprovement>().SingleOrDefault();
    388       if (localOpt != null) {
    389         localOpt.AssignmentParameter.ActualName = SolutionCreator.PermutationParameter.ActualName;
     282      }
     283      foreach (var localOpt in Operators.OfType<IQAPLocalImprovementOperator>()) {
     284        operators.Add(localOpt);
    390285        localOpt.DistancesParameter.ActualName = DistancesParameter.Name;
    391286        localOpt.MaximizationParameter.ActualName = MaximizationParameter.Name;
     
    394289      }
    395290
    396       QAPSimilarityCalculator similarityCalculator = Operators.OfType<QAPSimilarityCalculator>().SingleOrDefault();
     291      foreach (var moveOp in Operators.OfType<IQAPMoveEvaluator>()) {
     292        operators.Add(moveOp);
     293        moveOp.DistancesParameter.ActualName = DistancesParameter.Name;
     294        moveOp.WeightsParameter.ActualName = WeightsParameter.Name;
     295        moveOp.QualityParameter.ActualName = Evaluator.QualityParameter.Name;
     296
     297        var swaMoveOp = moveOp as QAPSwap2MoveEvaluator;
     298        if (swaMoveOp != null) {
     299          var moveQualityName = swaMoveOp.MoveQualityParameter.ActualName;
     300          foreach (var o in Encoding.Operators.OfType<IPermutationSwap2MoveQualityOperator>())
     301            o.MoveQualityParameter.ActualName = moveQualityName;
     302        }
     303        var invMoveOp = moveOp as QAPInversionMoveEvaluator;
     304        if (invMoveOp != null) {
     305          var moveQualityName = invMoveOp.MoveQualityParameter.ActualName;
     306          foreach (var o in Encoding.Operators.OfType<IPermutationInversionMoveQualityOperator>())
     307            o.MoveQualityParameter.ActualName = moveQualityName;
     308        }
     309        var traMoveOp = moveOp as QAPTranslocationMoveEvaluator;
     310        if (traMoveOp != null) {
     311          var moveQualityName = traMoveOp.MoveQualityParameter.ActualName;
     312          foreach (var o in Encoding.Operators.OfType<IPermutationTranslocationMoveQualityOperator>())
     313            o.MoveQualityParameter.ActualName = moveQualityName;
     314        }
     315        var scrMoveOp = moveOp as QAPScrambleMoveEvaluator;
     316        if (scrMoveOp != null) {
     317          var moveQualityName = scrMoveOp.MoveQualityParameter.ActualName;
     318          foreach (var o in Encoding.Operators.OfType<IPermutationScrambleMoveQualityOperator>())
     319            o.MoveQualityParameter.ActualName = moveQualityName;
     320        }
     321      }
     322      var similarityCalculator = Operators.OfType<QAPSimilarityCalculator>().SingleOrDefault();
    397323      if (similarityCalculator != null) {
    398         similarityCalculator.SolutionVariableName = SolutionCreator.PermutationParameter.ActualName;
     324        similarityCalculator.SolutionVariableName = Encoding.Name;
    399325        similarityCalculator.QualityVariableName = Evaluator.QualityParameter.ActualName;
    400326      }
     327
     328      if (operators.Count > 0) Encoding.ConfigureOperators(operators);
    401329    }
    402330
     
    404332      if (Distances.Rows != Weights.Rows || Distances.Columns != Weights.Columns) {
    405333        ((IStringConvertibleMatrix)Distances).Rows = Weights.Rows;
     334        Encoding.Length = Weights.Rows;
    406335      }
    407336    }
     
    410339      if (Weights.Rows != Distances.Rows || Weights.Columns != Distances.Columns) {
    411340        ((IStringConvertibleMatrix)Weights).Rows = Distances.Rows;
     341        Encoding.Length = Distances.Rows;
    412342      }
    413343    }
     
    418348      LowerBound = new DoubleValue(GilmoreLawlerBoundCalculator.CalculateLowerBound(Weights, Distances, out lbSolution));
    419349      // evalute the LAP optimal solution as if it was a QAP solution
    420       var lbSolutionQuality = QAPEvaluator.Apply(lbSolution, Weights, Distances);
     350      var lbSolutionQuality = Evaluate(lbSolution);
    421351      // in case both qualities are the same it means that the LAP optimum is also a QAP optimum
    422352      if (LowerBound.Value.IsAlmost(lbSolutionQuality)) {
    423353        BestKnownSolution = lbSolution;
    424         BestKnownQuality = new DoubleValue(LowerBound.Value);
     354        BestKnownQuality = LowerBound.Value;
    425355      }
    426356      AverageQuality = new DoubleValue(ComputeAverageQuality());
     
    451381      Description = data.Description;
    452382      Load(weights, distances);
    453       if (data.BestKnownQuality.HasValue) BestKnownQuality = new DoubleValue(data.BestKnownQuality.Value);
     383      if (data.BestKnownQuality.HasValue) BestKnownQuality = data.BestKnownQuality.Value;
    454384      EvaluateAndLoadAssignment(data.BestKnownAssignment);
    455385      OnReset();
     
    466396      Description = data.Description;
    467397      Load(weights, distances);
    468       if (data.BestKnownQuality.HasValue) BestKnownQuality = new DoubleValue(data.BestKnownQuality.Value);
     398      if (data.BestKnownQuality.HasValue) BestKnownQuality = data.BestKnownQuality.Value;
    469399      EvaluateAndLoadAssignment(data.BestKnownTour);
    470400      OnReset();
     
    485415      Weights = weights;
    486416      Distances = distances;
    487 
    488       BestKnownQuality = null;
     417      Encoding.Length = weights.Rows;
     418
     419      BestKnownQualityParameter.Value = null;
    489420      BestKnownSolution = null;
    490421      BestKnownSolutions = null;
     
    495426      if (assignment == null || assignment.Length == 0) return;
    496427      var vector = new Permutation(PermutationTypes.Absolute, assignment);
    497       var result = QAPEvaluator.Apply(vector, Weights, Distances);
    498       BestKnownQuality = new DoubleValue(result);
     428      var result = Evaluate(vector);
     429      BestKnownQuality = result;
    499430      BestKnownSolution = vector;
    500       BestKnownSolutions = new ItemSet<Permutation>();
    501       BestKnownSolutions.Add((Permutation)vector.Clone());
     431      BestKnownSolutions = new ItemSet<Permutation> { (Permutation)vector.Clone() };
    502432    }
    503433  }
Note: See TracChangeset for help on using the changeset viewer.