Free cookie consent management tool by TermsFeed Policy Generator

Changeset 6476


Ignore:
Timestamp:
06/24/11 17:51:06 (12 years ago)
Author:
gkronber
Message:

#1553: added remaining unit tests to create and run optimizer samples.

Location:
trunk/sources
Files:
12 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Algorithms.GeneticAlgorithm/3.3/IslandGeneticAlgorithm.cs

    r6051 r6476  
    7070      get { return (ValueParameter<PercentValue>)Parameters["MigrationRate"]; }
    7171    }
    72     private ConstrainedValueParameter<IMigrator> MigratorParameter {
     72    public ConstrainedValueParameter<IMigrator> MigratorParameter {
    7373      get { return (ConstrainedValueParameter<IMigrator>)Parameters["Migrator"]; }
    7474    }
    75     private ConstrainedValueParameter<ISelector> EmigrantsSelectorParameter {
     75    public ConstrainedValueParameter<ISelector> EmigrantsSelectorParameter {
    7676      get { return (ConstrainedValueParameter<ISelector>)Parameters["EmigrantsSelector"]; }
    7777    }
    78     private ConstrainedValueParameter<IReplacer> ImmigrationReplacerParameter {
     78    public ConstrainedValueParameter<IReplacer> ImmigrationReplacerParameter {
    7979      get { return (ConstrainedValueParameter<IReplacer>)Parameters["ImmigrationReplacer"]; }
    8080    }
     
    8585      get { return (ValueParameter<IntValue>)Parameters["MaximumGenerations"]; }
    8686    }
    87     private ConstrainedValueParameter<ISelector> SelectorParameter {
     87    public ConstrainedValueParameter<ISelector> SelectorParameter {
    8888      get { return (ConstrainedValueParameter<ISelector>)Parameters["Selector"]; }
    8989    }
    90     private ConstrainedValueParameter<ICrossover> CrossoverParameter {
     90    public ConstrainedValueParameter<ICrossover> CrossoverParameter {
    9191      get { return (ConstrainedValueParameter<ICrossover>)Parameters["Crossover"]; }
    9292    }
     
    9494      get { return (ValueParameter<PercentValue>)Parameters["MutationProbability"]; }
    9595    }
    96     private OptionalConstrainedValueParameter<IManipulator> MutatorParameter {
     96    public OptionalConstrainedValueParameter<IManipulator> MutatorParameter {
    9797      get { return (OptionalConstrainedValueParameter<IManipulator>)Parameters["Mutator"]; }
    9898    }
  • trunk/sources/HeuristicLab.Algorithms.LocalSearch/3.3/LocalSearch.cs

    r6053 r6476  
    5858      get { return (ValueParameter<BoolValue>)Parameters["SetSeedRandomly"]; }
    5959    }
    60     private ConstrainedValueParameter<IMoveGenerator> MoveGeneratorParameter {
     60    public ConstrainedValueParameter<IMoveGenerator> MoveGeneratorParameter {
    6161      get { return (ConstrainedValueParameter<IMoveGenerator>)Parameters["MoveGenerator"]; }
    6262    }
    63     private ConstrainedValueParameter<IMoveMaker> MoveMakerParameter {
     63    public ConstrainedValueParameter<IMoveMaker> MoveMakerParameter {
    6464      get { return (ConstrainedValueParameter<IMoveMaker>)Parameters["MoveMaker"]; }
    6565    }
    66     private ConstrainedValueParameter<ISingleObjectiveMoveEvaluator> MoveEvaluatorParameter {
     66    public ConstrainedValueParameter<ISingleObjectiveMoveEvaluator> MoveEvaluatorParameter {
    6767      get { return (ConstrainedValueParameter<ISingleObjectiveMoveEvaluator>)Parameters["MoveEvaluator"]; }
    6868    }
  • trunk/sources/HeuristicLab.Algorithms.ParticleSwarmOptimization/3.3/ParticleSwarmOptimization.cs

    r5941 r6476  
    3939  [StorableClass]
    4040  public sealed class ParticleSwarmOptimization : HeuristicOptimizationEngineAlgorithm, IStorableContent {
    41 
    42     #region Problem Properties
     41    #region Parameter Properties
     42    public IValueParameter<IntValue> SeedParameter {
     43      get { return (IValueParameter<IntValue>)Parameters["Seed"]; }
     44    }
     45    public IValueParameter<BoolValue> SetSeedRandomlyParameter {
     46      get { return (IValueParameter<BoolValue>)Parameters["SetSeedRandomly"]; }
     47    }
     48    public IValueParameter<IntValue> SwarmSizeParameter {
     49      get { return (IValueParameter<IntValue>)Parameters["SwarmSize"]; }
     50    }
     51    public IValueParameter<IntValue> MaxIterationsParameter {
     52      get { return (IValueParameter<IntValue>)Parameters["MaxIterations"]; }
     53    }
     54    public IValueParameter<DoubleValue> InertiaParameter {
     55      get { return (IValueParameter<DoubleValue>)Parameters["Inertia"]; }
     56    }
     57    public IValueParameter<DoubleValue> PersonalBestAttractionParameter {
     58      get { return (IValueParameter<DoubleValue>)Parameters["PersonalBestAttraction"]; }
     59    }
     60    public IValueParameter<DoubleValue> NeighborBestAttractionParameter {
     61      get { return (IValueParameter<DoubleValue>)Parameters["NeighborBestAttraction"]; }
     62    }
     63    public IValueParameter<MultiAnalyzer> AnalyzerParameter {
     64      get { return (IValueParameter<MultiAnalyzer>)Parameters["Analyzer"]; }
     65    }
     66    public ConstrainedValueParameter<IParticleCreator> ParticleCreatorParameter {
     67      get { return (ConstrainedValueParameter<IParticleCreator>)Parameters["ParticleCreator"]; }
     68    }
     69    public ConstrainedValueParameter<IParticleUpdater> ParticleUpdaterParameter {
     70      get { return (ConstrainedValueParameter<IParticleUpdater>)Parameters["ParticleUpdater"]; }
     71    }
     72    public OptionalConstrainedValueParameter<ITopologyInitializer> TopologyInitializerParameter {
     73      get { return (OptionalConstrainedValueParameter<ITopologyInitializer>)Parameters["TopologyInitializer"]; }
     74    }
     75    public OptionalConstrainedValueParameter<ITopologyUpdater> TopologyUpdaterParameter {
     76      get { return (OptionalConstrainedValueParameter<ITopologyUpdater>)Parameters["TopologyUpdater"]; }
     77    }
     78    public OptionalConstrainedValueParameter<IDiscreteDoubleValueModifier> InertiaUpdaterParameter {
     79      get { return (OptionalConstrainedValueParameter<IDiscreteDoubleValueModifier>)Parameters["InertiaUpdater"]; }
     80    }
     81    public ConstrainedValueParameter<ISwarmUpdater> SwarmUpdaterParameter {
     82      get { return (ConstrainedValueParameter<ISwarmUpdater>)Parameters["SwarmUpdater"]; }
     83
     84    }
     85    #endregion
     86
     87    #region Properties
     88
     89    public string Filename { get; set; }
     90
     91    [Storable]
     92    private BestAverageWorstQualityAnalyzer qualityAnalyzer;
     93
     94    [Storable]
     95    private SolutionsCreator solutionsCreator;
     96
     97    [Storable]
     98    private ParticleSwarmOptimizationMainLoop mainLoop;
     99   
    43100    public override Type ProblemType {
    44101      get { return typeof(ISingleObjectiveHeuristicOptimizationProblem); }
     
    48105      set { base.Problem = value; }
    49106    }
     107    public IntValue Seed {
     108      get { return SeedParameter.Value; }
     109      set { SeedParameter.Value = value; }
     110    }
     111    public BoolValue SetSeedRandomly {
     112      get { return SetSeedRandomlyParameter.Value; }
     113      set { SetSeedRandomlyParameter.Value = value; }
     114    }
     115    public IntValue SwarmSize {
     116      get { return SwarmSizeParameter.Value; }
     117      set { SwarmSizeParameter.Value = value; }
     118    }
     119    public IntValue MaxIterations {
     120      get { return MaxIterationsParameter.Value; }
     121      set { MaxIterationsParameter.Value = value; }
     122    }
     123    public DoubleValue Inertia {
     124      get { return InertiaParameter.Value; }
     125      set { InertiaParameter.Value = value; }
     126    }
     127    public DoubleValue PersonalBestAttraction {
     128      get { return PersonalBestAttractionParameter.Value; }
     129      set { PersonalBestAttractionParameter.Value = value; }
     130    }
     131    public DoubleValue NeighborBestAttraction {
     132      get { return NeighborBestAttractionParameter.Value; }
     133      set { NeighborBestAttractionParameter.Value = value; }
     134    }
    50135    public MultiAnalyzer Analyzer {
    51136      get { return AnalyzerParameter.Value; }
    52137      set { AnalyzerParameter.Value = value; }
    53138    }
     139    public IParticleCreator ParticleCreator {
     140      get { return ParticleCreatorParameter.Value; }
     141      set { ParticleCreatorParameter.Value = value; }
     142    }
     143    public IParticleUpdater ParticleUpdater {
     144      get { return ParticleUpdaterParameter.Value; }
     145      set { ParticleUpdaterParameter.Value = value; }
     146    }
     147    public ITopologyInitializer TopologyInitializer {
     148      get { return TopologyInitializerParameter.Value; }
     149      set { TopologyInitializerParameter.Value = value; }
     150    }
     151    public ITopologyUpdater TopologyUpdater {
     152      get { return TopologyUpdaterParameter.Value; }
     153      set { TopologyUpdaterParameter.Value = value; }
     154    }
    54155    public IDiscreteDoubleValueModifier InertiaUpdater {
    55156      get { return InertiaUpdaterParameter.Value; }
    56157      set { InertiaUpdaterParameter.Value = value; }
    57158    }
    58     #endregion
    59 
    60     #region Parameter Properties
    61     public IValueParameter<IntValue> SeedParameter {
    62       get { return (IValueParameter<IntValue>)Parameters["Seed"]; }
    63     }
    64     public IValueParameter<BoolValue> SetSeedRandomlyParameter {
    65       get { return (IValueParameter<BoolValue>)Parameters["SetSeedRandomly"]; }
    66     }
    67     public IValueParameter<IntValue> SwarmSizeParameter {
    68       get { return (IValueParameter<IntValue>)Parameters["SwarmSize"]; }
    69     }
    70     public IValueParameter<IntValue> MaxIterationsParameter {
    71       get { return (IValueParameter<IntValue>)Parameters["MaxIterations"]; }
    72     }
    73     public IValueParameter<DoubleValue> InertiaParameter {
    74       get { return (IValueParameter<DoubleValue>)Parameters["Inertia"]; }
    75     }
    76     public IValueParameter<DoubleValue> PersonalBestAttractionParameter {
    77       get { return (IValueParameter<DoubleValue>)Parameters["PersonalBestAttraction"]; }
    78     }
    79     public IValueParameter<DoubleValue> NeighborBestAttractionParameter {
    80       get { return (IValueParameter<DoubleValue>)Parameters["NeighborBestAttraction"]; }
    81     }
    82     public IValueParameter<MultiAnalyzer> AnalyzerParameter {
    83       get { return (IValueParameter<MultiAnalyzer>)Parameters["Analyzer"]; }
    84     }
    85     public ConstrainedValueParameter<IParticleCreator> ParticleCreatorParameter {
    86       get { return (ConstrainedValueParameter<IParticleCreator>)Parameters["ParticleCreator"]; }
    87     }
    88     public ConstrainedValueParameter<IParticleUpdater> ParticleUpdaterParameter {
    89       get { return (ConstrainedValueParameter<IParticleUpdater>)Parameters["ParticleUpdater"]; }
    90     }
    91     public OptionalConstrainedValueParameter<ITopologyInitializer> TopologyInitializerParameter {
    92       get { return (OptionalConstrainedValueParameter<ITopologyInitializer>)Parameters["TopologyInitializer"]; }
    93     }
    94     public OptionalConstrainedValueParameter<ITopologyUpdater> TopologyUpdaterParameter {
    95       get { return (OptionalConstrainedValueParameter<ITopologyUpdater>)Parameters["TopologyUpdater"]; }
    96     }
    97     public OptionalConstrainedValueParameter<IDiscreteDoubleValueModifier> InertiaUpdaterParameter {
    98       get { return (OptionalConstrainedValueParameter<IDiscreteDoubleValueModifier>)Parameters["InertiaUpdater"]; }
    99     }
    100     public ConstrainedValueParameter<ISwarmUpdater> SwarmUpdaterParameter {
    101       get { return (ConstrainedValueParameter<ISwarmUpdater>)Parameters["SwarmUpdater"]; }
    102 
    103     }
    104     #endregion
    105 
    106     #region Properties
    107 
    108     public string Filename { get; set; }
    109 
    110     [Storable]
    111     private BestAverageWorstQualityAnalyzer qualityAnalyzer;
    112 
    113     [Storable]
    114     private SolutionsCreator solutionsCreator;
    115 
    116     [Storable]
    117     private ParticleSwarmOptimizationMainLoop mainLoop;
    118 
    119     public ITopologyInitializer TopologyInitializer {
    120       get { return TopologyInitializerParameter.Value; }
    121       set { TopologyInitializerParameter.Value = value; }
    122     }
    123 
    124     public ITopologyUpdater TopologyUpdater {
    125       get { return TopologyUpdaterParameter.Value; }
    126       set { TopologyUpdaterParameter.Value = value; }
    127     }
    128 
    129     public IParticleCreator ParticleCreator {
    130       get { return ParticleCreatorParameter.Value; }
    131       set { ParticleCreatorParameter.Value = value; }
    132     }
    133 
    134     public IParticleUpdater ParticleUpdater {
    135       get { return ParticleUpdaterParameter.Value; }
    136       set { ParticleUpdaterParameter.Value = value; }
     159    public ISwarmUpdater SwarmUpdater {
     160      get { return SwarmUpdaterParameter.Value; }
     161      set { SwarmUpdaterParameter.Value = value; }
    137162    }
    138163    #endregion
     
    333358    }
    334359
     360    private void ParameterizeTopologyUpdaters() {
     361      foreach (var updater in TopologyUpdaterParameter.ValidValues) {
     362        var multiPsoUpdater = updater as MultiPSOTopologyUpdater;
     363        if (multiPsoUpdater != null) {
     364          multiPsoUpdater.CurrentIterationParameter.ActualName = "Iterations";
     365        }
     366      }
     367    }
     368
    335369    private void UpdateTopologyParameters() {
    336370      ITopologyUpdater oldTopologyUpdater = TopologyUpdater;
     
    355389          if (newParticleUpdater != null) ParticleUpdater = newParticleUpdater;
    356390        }
     391
     392        ParameterizeTopologyUpdaters();
    357393      }
    358394    }
  • trunk/sources/HeuristicLab.Algorithms.SimulatedAnnealing/3.3/SimulatedAnnealing.cs

    r6053 r6476  
    5959      get { return (ValueParameter<BoolValue>)Parameters["SetSeedRandomly"]; }
    6060    }
    61     private ConstrainedValueParameter<IMultiMoveGenerator> MoveGeneratorParameter {
     61    public ConstrainedValueParameter<IMultiMoveGenerator> MoveGeneratorParameter {
    6262      get { return (ConstrainedValueParameter<IMultiMoveGenerator>)Parameters["MoveGenerator"]; }
    6363    }
    64     private ConstrainedValueParameter<IMoveMaker> MoveMakerParameter {
     64    public ConstrainedValueParameter<IMoveMaker> MoveMakerParameter {
    6565      get { return (ConstrainedValueParameter<IMoveMaker>)Parameters["MoveMaker"]; }
    6666    }
    67     private ConstrainedValueParameter<ISingleObjectiveMoveEvaluator> MoveEvaluatorParameter {
     67    public ConstrainedValueParameter<ISingleObjectiveMoveEvaluator> MoveEvaluatorParameter {
    6868      get { return (ConstrainedValueParameter<ISingleObjectiveMoveEvaluator>)Parameters["MoveEvaluator"]; }
    6969    }
    70     private ConstrainedValueParameter<IDiscreteDoubleValueModifier> AnnealingOperatorParameter {
     70    public ConstrainedValueParameter<IDiscreteDoubleValueModifier> AnnealingOperatorParameter {
    7171      get { return (ConstrainedValueParameter<IDiscreteDoubleValueModifier>)Parameters["AnnealingOperator"]; }
    7272    }
     
    108108      get { return MoveEvaluatorParameter.Value; }
    109109      set { MoveEvaluatorParameter.Value = value; }
     110    }
     111    public IDiscreteDoubleValueModifier AnnealingOperator {
     112      get { return AnnealingOperatorParameter.Value; }
     113      set { AnnealingOperatorParameter.Value = value; }
    110114    }
    111115    public IntValue MaximumIterations {
  • trunk/sources/HeuristicLab.Algorithms.TabuSearch/3.3/TabuSearch.cs

    r6053 r6476  
    5858      get { return (ValueParameter<BoolValue>)Parameters["SetSeedRandomly"]; }
    5959    }
    60     private ConstrainedValueParameter<IMoveGenerator> MoveGeneratorParameter {
     60    public ConstrainedValueParameter<IMoveGenerator> MoveGeneratorParameter {
    6161      get { return (ConstrainedValueParameter<IMoveGenerator>)Parameters["MoveGenerator"]; }
    6262    }
    63     private ConstrainedValueParameter<IMoveMaker> MoveMakerParameter {
     63    public ConstrainedValueParameter<IMoveMaker> MoveMakerParameter {
    6464      get { return (ConstrainedValueParameter<IMoveMaker>)Parameters["MoveMaker"]; }
    6565    }
    66     private ConstrainedValueParameter<ISingleObjectiveMoveEvaluator> MoveEvaluatorParameter {
     66    public ConstrainedValueParameter<ISingleObjectiveMoveEvaluator> MoveEvaluatorParameter {
    6767      get { return (ConstrainedValueParameter<ISingleObjectiveMoveEvaluator>)Parameters["MoveEvaluator"]; }
    6868    }
    69     private ConstrainedValueParameter<ITabuChecker> TabuCheckerParameter {
     69    public ConstrainedValueParameter<ITabuChecker> TabuCheckerParameter {
    7070      get { return (ConstrainedValueParameter<ITabuChecker>)Parameters["TabuChecker"]; }
    7171    }
    72     private ConstrainedValueParameter<ITabuMaker> TabuMakerParameter {
     72    public ConstrainedValueParameter<ITabuMaker> TabuMakerParameter {
    7373      get { return (ConstrainedValueParameter<ITabuMaker>)Parameters["TabuMaker"]; }
    7474    }
     
    123123      get { return MaximumIterationsParameter.Value; }
    124124      set { MaximumIterationsParameter.Value = value; }
     125    }
     126    public IntValue SampleSize {
     127      get { return SampleSizeParameter.Value; }
     128      set { SampleSizeParameter.Value = value; }
    125129    }
    126130    public MultiAnalyzer Analyzer {
  • trunk/sources/HeuristicLab.Algorithms.VariableNeighborhoodSearch/3.3/VariableNeighborhoodSearch.cs

    r6057 r6476  
    5858      get { return (FixedValueParameter<BoolValue>)Parameters["SetSeedRandomly"]; }
    5959    }
    60     private ConstrainedValueParameter<ILocalImprovementOperator> LocalImprovementParameter {
     60    public ConstrainedValueParameter<ILocalImprovementOperator> LocalImprovementParameter {
    6161      get { return (ConstrainedValueParameter<ILocalImprovementOperator>)Parameters["LocalImprovement"]; }
    6262    }
    63     private ConstrainedValueParameter<IMultiNeighborhoodShakingOperator> ShakingOperatorParameter {
     63    public ConstrainedValueParameter<IMultiNeighborhoodShakingOperator> ShakingOperatorParameter {
    6464      get { return (ConstrainedValueParameter<IMultiNeighborhoodShakingOperator>)Parameters["ShakingOperator"]; }
    6565    }
     
    8888    private VariableNeighborhoodSearchMainLoop MainLoop {
    8989      get { return FindMainLoop(SolutionsCreator.Successor); }
     90    }
     91    public int Seed {
     92      get { return SeedParameter.Value.Value; }
     93      set { SeedParameter.Value.Value = value; }
     94    }
     95    public bool SetSeedRandomly {
     96      get { return SetSeedRandomlyParameter.Value.Value; }
     97      set { SetSeedRandomlyParameter.Value.Value = value; }
     98    }
     99    public ILocalImprovementOperator LocalImprovement {
     100      get { return LocalImprovementParameter.Value; }
     101      set { LocalImprovementParameter.Value = value; }
     102    }
     103    public IMultiNeighborhoodShakingOperator ShakingOperator {
     104      get { return ShakingOperatorParameter.Value; }
     105      set { ShakingOperatorParameter.Value = value; }
     106    }
     107    public int MaximumIterations {
     108      get { return MaximumIterationsParameter.Value.Value; }
     109      set { MaximumIterationsParameter.Value.Value = value; }
     110    }
     111    public int LocalImprovementMaximumIterations {
     112      get { return LocalImprovementMaximumIterationsParameter.Value.Value; }
     113      set { LocalImprovementMaximumIterationsParameter.Value.Value = value; }
    90114    }
    91115    #endregion
  • trunk/sources/HeuristicLab.Optimization.Operators/3.3/DiscreteDoubleValueModifier.cs

    r5445 r6476  
    3434  [StorableClass]
    3535  public abstract class DiscreteDoubleValueModifier : SingleSuccessorOperator, IDiscreteDoubleValueModifier {
     36    #region parameter properties
    3637    /// <summary>
    3738    /// The parameter that should be modified.
     
    7071      get { return (IValueLookupParameter<IntValue>)Parameters["EndIndex"]; }
    7172    }
    72 
     73    #endregion
    7374    [StorableConstructor]
    7475    protected DiscreteDoubleValueModifier(bool deserializing) : base(deserializing) { }
  • trunk/sources/HeuristicLab.Problems.Knapsack/3.3/KnapsackProblem.cs

    r6053 r6476  
    8787
    8888    #region Properties
     89    public BoolValue Maximization {
     90      get { return MaximizationParameter.Value; }
     91      set { MaximizationParameter.Value = value; }
     92    }
    8993    public IntValue KnapsackCapacity {
    9094      get { return KnapsackCapacityParameter.Value; }
  • trunk/sources/HeuristicLab/3.3/Tests/HeuristicLab-3.3.Tests.csproj

    r6441 r6476  
    126126    <Compile Include="CollectObjectGraphTest.cs" />
    127127    <Compile Include="ContentViewTests.cs" />
    128     <Compile Include="GeneticAlgorithmSamplesTest.cs" />
    129128    <Compile Include="Properties\Resources.Designer.cs">
    130129      <AutoGen>True</AutoGen>
     
    132131      <DependentUpon>Resources.resx</DependentUpon>
    133132    </Compile>
     133    <Compile Include="SamplesTest.cs" />
    134134    <Compile Include="SymbolicRegressionTest.cs" />
    135135    <Compile Include="PluginDependenciesTest.cs" />
     
    554554      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    555555    </None>
    556     <None Include="Resources\ch130.opt.tour" />
    557     <None Include="Resources\ch130.tsp" />
    558   </ItemGroup>
    559   <ItemGroup>
    560     <Content Include="Resources\C101.opt.txt" />
    561     <Content Include="Resources\C101.txt" />
     556    <Content Include="Resources\ch130.opt.tour">
     557      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     558    </Content>
     559    <Content Include="Resources\ch130.tsp">
     560      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     561    </Content>
     562  </ItemGroup>
     563  <ItemGroup>
     564    <EmbeddedResource Include="Properties\Resources.resx">
     565      <Generator>ResXFileCodeGenerator</Generator>
     566      <LastGenOutput>Resources.Designer.cs</LastGenOutput>
     567    </EmbeddedResource>
     568  </ItemGroup>
     569  <ItemGroup>
     570    <Content Include="Resources\C101.opt.txt">
     571      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     572    </Content>
     573    <Content Include="Resources\C101.txt">
     574      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     575    </Content>
    562576    <Content Include="Resources\mammographic_masses.txt">
    563577      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     
    567581    </Content>
    568582  </ItemGroup>
    569   <ItemGroup>
    570     <EmbeddedResource Include="Properties\Resources.resx">
    571       <Generator>ResXFileCodeGenerator</Generator>
    572       <LastGenOutput>Resources.Designer.cs</LastGenOutput>
    573     </EmbeddedResource>
    574   </ItemGroup>
     583  <ItemGroup />
    575584  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
    576585  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
  • trunk/sources/HeuristicLab/3.3/Tests/Properties/Resources.Designer.cs

    r6441 r6476  
    6060            }
    6161        }
    62        
    63         /// <summary>
    64         ///   Looks up a localized string similar to C101
    65         ///
    66         ///VEHICLE
    67         ///NUMBER     CAPACITY
    68         ///  25         200
    69         ///
    70         ///CUSTOMER
    71         ///CUST NO.  XCOORD.   YCOORD.    DEMAND   READY TIME  DUE DATE   SERVICE   TIME
    72         ///
    73         ///    0      40         50          0          0       1236          0   
    74         ///    1      45         68         10        912        967         90   
    75         ///    2      45         70         30        825        870         90   
    76         ///    3      42         66         10         65        146         90   
    77         ///    4      42         68         10        727        782         90   [rest of string was truncated]&quot;;.
    78         /// </summary>
    79         internal static string C101 {
    80             get {
    81                 return ResourceManager.GetString("C101", resourceCulture);
    82             }
    83         }
    84        
    85         /// <summary>
    86         ///   Looks up a localized string similar to Route #1: 67 65 63 62 74 72 61 64 68 66 69
    87         ///Route #2: 98 96 95 94 92 93 97 100 99
    88         ///Route #3: 32 33 31 35 37 38 39 36 34
    89         ///Route #4: 90 87 86 83 82 84 85 88 89 91
    90         ///Route #5: 81 78 76 71 70 73 77 79 80
    91         ///Route #6: 57 55 54 53 56 58 60 59
    92         ///Route #7: 20 24 25 27 29 30 28 26 23 22 21
    93         ///Route #8: 43 42 41 40 44 46 45 48 51 50 52 49 47
    94         ///Route #9: 5 3 7 8 10 11 9 6 4 2 1 75
    95         ///Route #10: 13 17 18 19 15 16 14 12
    96         ///cost 1828.9368669428336.
    97         /// </summary>
    98         internal static string C101_opt {
    99             get {
    100                 return ResourceManager.GetString("C101_opt", resourceCulture);
    101             }
    102         }
    103        
    104         /// <summary>
    105         ///   Looks up a localized string similar to NAME: ch130
    106         ///TYPE: TSP
    107         ///COMMENT: 130 city problem (Churritz)
    108         ///DIMENSION: 130
    109         ///EDGE_WEIGHT_TYPE: EUC_2D
    110         ///NODE_COORD_SECTION
    111         ///1 334.5909245845 161.7809319139
    112         ///2 397.6446634067 262.8165330708
    113         ///3 503.8741827107 172.8741151168
    114         ///4 444.0479403502 384.6491809647
    115         ///5 311.6137146746 2.0091699828
    116         ///6 662.8551011379 549.2301263653
    117         ///7 40.0979030612 187.2375430791
    118         ///8 526.8941409181 215.7079092185
    119         ///9 209.1887938487 691.0262291948
    120         ///10 683.2674131973 414.2096286906
    121         ///11 280.7494438748 5.9206392047
    122         ///12 252.7493090080 535.7430385019
    123         ///13 698.78504 [rest of string was truncated]&quot;;.
    124         /// </summary>
    125         internal static string ch130 {
    126             get {
    127                 return ResourceManager.GetString("ch130", resourceCulture);
    128             }
    129         }
    130        
    131         /// <summary>
    132         ///   Looks up a localized string similar to NAME : ch130.opt.tour
    133         ///COMMENT : Length 6110
    134         ///TYPE : TOUR
    135         ///DIMENSION : 130
    136         ///TOUR_SECTION
    137         ///1
    138         ///41
    139         ///39
    140         ///117
    141         ///112
    142         ///115
    143         ///28
    144         ///62
    145         ///105
    146         ///128
    147         ///16
    148         ///45
    149         ///5
    150         ///11
    151         ///76
    152         ///109
    153         ///61
    154         ///129
    155         ///124
    156         ///64
    157         ///69
    158         ///86
    159         ///88
    160         ///26
    161         ///7
    162         ///97
    163         ///70
    164         ///107
    165         ///127
    166         ///104
    167         ///43
    168         ///34
    169         ///17
    170         ///31
    171         ///27
    172         ///19
    173         ///100
    174         ///15
    175         ///29
    176         ///24
    177         ///116
    178         ///95
    179         ///79
    180         ///87
    181         ///12
    182         ///81
    183         ///103
    184         ///77
    185         ///94
    186         ///89
    187         ///110
    188         ///98
    189         ///68
    190         ///63
    191         ///48
    192         ///25
    193         ///113
    194         ///32
    195         ///36
    196         ///84
    197         ///119
    198         ///111
    199         ///123
    200         ///101
    201         ///82
    202         ///57
    203         ///9
    204         ///56
    205         ///65
    206         ///52
    207         ///75
    208         ///74
    209         ///99
    210         ///73
    211         ///92
    212         ///38
    213         ///106
    214         ///53
    215         ///120
    216         ///58
    217         ///49
    218         ///72
    219         ///91
    220         ///6
    221         ///102
    222         ///10
    223         ///14
    224         ///67
    225         ///13
    226         ///96
    227         ///122
    228         ///55
    229         ///60
    230         ///51
    231         ///42
    232         ///44
    233         ///93
    234         ///37
    235         ///22
    236         ///47
    237         ///40
    238         ///23
    239         ///33
    240         ///21
    241         ///126
    242         ///121
    243         ///78
    244         ///66
    245         ///85
    246         ///125
    247         ///90
    248         ///59
    249         ///30
    250         ///83
    251         ///3
    252         ///114
    253         ///108
    254         ///8
    255         ///18
    256         ///46
    257         ///80
    258         ///118
    259         ///20
    260         ///4
    261         ///35
    262         ///54
    263         ///2
    264         ///50
    265         ///130
    266         ///71
    267         ///-1
    268         ///.
    269         /// </summary>
    270         internal static string ch130_opt {
    271             get {
    272                 return ResourceManager.GetString("ch130_opt", resourceCulture);
    273             }
    274         }
    275        
    276         /// <summary>
    277         ///   Looks up a localized string similar to BI-RADS; Age; Shape; Margin; Density; Severity
    278         ///5;67;3;5;3;1
    279         ///4;43;1;1;3;1
    280         ///5;58;4;5;3;1
    281         ///4;28;1;1;3;0
    282         ///5;74;1;5;3;1
    283         ///4;65;1;3;3;0
    284         ///4;70;3;3;3;0
    285         ///5;42;1;3;3;0
    286         ///5;57;1;5;3;1
    287         ///5;60;3;5;1;1
    288         ///5;76;1;4;3;1
    289         ///3;42;2;1;3;1
    290         ///4;64;1;3;3;0
    291         ///4;36;3;1;2;0
    292         ///4;60;2;1;2;0
    293         ///4;54;1;1;3;0
    294         ///3;52;3;4;3;0
    295         ///4;59;2;1;3;1
    296         ///4;54;1;1;3;1
    297         ///4;40;1;3;3;0
    298         ///4;66;3;3;1;1
    299         ///5;56;4;3;1;1
    300         ///4;43;1;3;3;0
    301         ///5;42;4;4;3;1
    302         ///4;59;2;4;3;1
    303         ///5;75;4;5;3;1
    304         ///2;66;1;1;3;0
    305         ///5;63;3;3;3;0
    306         ///5;45;4;5;3;1
    307         ///5;55;4;4;3;0
    308         ///4;46;1;5;2;0
    309         ///5;54;4;4;3;1
    310         ///5;57;4;4;3;1
    311         ///4; [rest of string was truncated]&quot;;.
    312         /// </summary>
    313         internal static string MammographicMasses {
    314             get {
    315                 return ResourceManager.GetString("MammographicMasses", resourceCulture);
    316             }
    317         }
    318        
    319         /// <summary>
    320         ///   Looks up a localized string similar to x1;x2;x3;x4;x5;x6;x7;x8;x9;x10;x11;x12;x13;x14;x15;x16;x17;x18;x19;x20;x21;x22;x23;x24;x25;towerResponse
    321         ///28.0784464518229;13.939023844401;87.6339436848958;20.0777689615885;63.0026733398437;70.0181884765625;59.5551432291667;8.80629475911458;94.8240641276042;1.50430590311686;473.995963541667;165.433089192708;163.806526692708;161.395735677083;140.468115234375;129.394759114583;173.246484375;29.12998046875;7.02796274820964;124.702001953125;122.926342773437;51.7155436197917;90.4672119140625;129.585375976562;8.80 [rest of string was truncated]&quot;;.
    322         /// </summary>
    323         internal static string TowerData {
    324             get {
    325                 return ResourceManager.GetString("TowerData", resourceCulture);
    326             }
    327         }
    32862    }
    32963}
  • trunk/sources/HeuristicLab/3.3/Tests/Properties/Resources.resx

    r6441 r6476  
    118118    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
    119119  </resheader>
    120   <assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
    121   <data name="C101" type="System.Resources.ResXFileRef, System.Windows.Forms">
    122     <value>..\resources\c101.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
    123   </data>
    124   <data name="C101_opt" type="System.Resources.ResXFileRef, System.Windows.Forms">
    125     <value>..\resources\c101.opt.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
    126   </data>
    127   <data name="ch130" type="System.Resources.ResXFileRef, System.Windows.Forms">
    128     <value>..\resources\ch130.tsp;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
    129   </data>
    130   <data name="ch130_opt" type="System.Resources.ResXFileRef, System.Windows.Forms">
    131     <value>..\resources\ch130.opt.tour;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
    132   </data>
    133   <data name="MammographicMasses" type="System.Resources.ResXFileRef, System.Windows.Forms">
    134     <value>..\resources\mammographic_masses.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
    135   </data>
    136   <data name="TowerData" type="System.Resources.ResXFileRef, System.Windows.Forms">
    137     <value>..\resources\towerdata.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
    138   </data>
    139120</root>
  • trunk/sources/HeuristicLab/3.3/Tests/SamplesTest.cs

    r6474 r6476  
    2424using HeuristicLab.Problems.VehicleRouting.Encodings;
    2525using HeuristicLab.Problems.VehicleRouting.Encodings.General;
     26using HeuristicLab.Algorithms.EvolutionStrategy;
     27using HeuristicLab.Encodings.RealVectorEncoding;
     28using HeuristicLab.Problems.TestFunctions;
     29using HeuristicLab.Optimization.Operators;
     30using HeuristicLab.Algorithms.LocalSearch;
     31using HeuristicLab.Problems.Knapsack;
     32using HeuristicLab.Encodings.BinaryVectorEncoding;
     33using HeuristicLab.Algorithms.ParticleSwarmOptimization;
     34using HeuristicLab.Algorithms.SimulatedAnnealing;
     35using HeuristicLab.Algorithms.TabuSearch;
     36using HeuristicLab.Algorithms.VariableNeighborhoodSearch;
    2637
    2738namespace HeuristicLab_33.Tests {
    2839  [TestClass]
    29   public class GeneticAlgorithmSamplesTest {
     40  [DeploymentItem(@"Resources/C101.opt.txt")]
     41  [DeploymentItem(@"Resources/C101.txt")]
     42  [DeploymentItem(@"Resources/ch130.tsp")]
     43  [DeploymentItem(@"Resources/ch130.opt.tour")]
     44  [DeploymentItem(@"Resources/mammographic_masses.txt")]
     45  [DeploymentItem(@"Resources/towerData.txt")]
     46  public class SamplesTest {
     47    #region GA
    3048    #region TSP
    3149    [TestMethod]
    32     public void CreateTSPSampleTest() {
    33       var ga = CreateTSPSample();
     50    public void CreateGaTspSampleTest() {
     51      var ga = CreateGaTspSample();
    3452      XmlGenerator.Serialize(ga, "../../GA_TSP.hl");
    3553    }
    3654    [TestMethod]
    37     public void RunTSPSampleTest() {
    38       var ga = CreateTSPSample();
     55    public void RunGaTspSampleTest() {
     56      var ga = CreateGaTspSample();
    3957      ga.SetSeedRandomly.Value = false;
    4058      RunAlgorithm(ga);
     
    4563    }
    4664
    47     private GeneticAlgorithm CreateTSPSample() {
     65    private GeneticAlgorithm CreateGaTspSample() {
    4866      GeneticAlgorithm ga = new GeneticAlgorithm();
    4967      #region problem configuration
    5068      TravelingSalesmanProblem tspProblem = new TravelingSalesmanProblem();
    51       // import and configure TSP data
    52       string ch130FileName = Path.GetTempFileName() + ".tsp";// for silly parser constraints
    53       using (var writer = File.CreateText(ch130FileName)) {
    54         writer.Write(HeuristicLab_33.Tests.Properties.Resources.ch130);
    55       }
    56       string ch130OptTourFileName = Path.GetTempFileName() + ".opt.tour"; // for silly parser constraints
    57       using (var writer = File.CreateText(ch130OptTourFileName)) {
    58         writer.Write(HeuristicLab_33.Tests.Properties.Resources.ch130_opt);
    59       }
    60 
    61       tspProblem.ImportFromTSPLIB(ch130FileName, ch130OptTourFileName, 6110);
     69      tspProblem.ImportFromTSPLIB("ch130.tsp", "ch130.opt.tour", 6110);
    6270      tspProblem.Evaluator = new TSPRoundedEuclideanPathEvaluator();
    6371      tspProblem.SolutionCreator = new RandomPermutationCreator();
     
    8694    #region VRP
    8795    [TestMethod]
    88     public void CreateVRPSampleTest() {
    89       var ga = CreateVRPSample();
     96    public void CreateGaVrpSampleTest() {
     97      var ga = CreateGaVrpSample();
    9098      XmlGenerator.Serialize(ga, "../../GA_VRP.hl");
    9199    }
    92100
    93101    [TestMethod]
    94     public void RunVRPSampleTest() {
    95       var ga = CreateVRPSample();
     102    public void RunGaVrpSampleTest() {
     103      var ga = CreateGaVrpSample();
    96104      ga.SetSeedRandomly.Value = false;
    97105      RunAlgorithm(ga);
    98106      Assert.AreEqual(1828.9368669428336, GetDoubleResult(ga, "BestQuality"));
    99       Assert.AreEqual(1832.7272021720889, GetDoubleResult(ga, "CurrentAverageQuality"));
    100       Assert.AreEqual(1929.5220133155044, GetDoubleResult(ga, "CurrentWorstQuality"));
     107      Assert.AreEqual(1829.6829520983711, GetDoubleResult(ga, "CurrentAverageQuality"));
     108      Assert.AreEqual(1867.8378222145707, GetDoubleResult(ga, "CurrentWorstQuality"));
    101109      Assert.AreEqual(99100, GetIntResult(ga, "EvaluatedSolutions"));
    102110    }
    103111
    104     private GeneticAlgorithm CreateVRPSample() {
     112    private GeneticAlgorithm CreateGaVrpSample() {
    105113      GeneticAlgorithm ga = new GeneticAlgorithm();
    106114      #region problem configuration
    107115      VehicleRoutingProblem vrpProblem = new VehicleRoutingProblem();
    108       // import and configure VRP data
    109       string c101FileName = Path.GetTempFileName();
    110       using (var writer = File.CreateText(c101FileName)) {
    111         writer.Write(HeuristicLab_33.Tests.Properties.Resources.C101);
    112       }
    113       // import and configure VRP data
    114       string c101BestSolutionFileName = Path.GetTempFileName();
    115       using (var writer = File.CreateText(c101BestSolutionFileName)) {
    116         writer.Write(HeuristicLab_33.Tests.Properties.Resources.C101_opt);
    117       }
    118 
    119       vrpProblem.ImportFromSolomon(c101FileName);
    120       vrpProblem.ImportSolution(c101BestSolutionFileName);
     116
     117      vrpProblem.ImportFromSolomon("C101.txt");
     118      vrpProblem.ImportSolution("C101.opt.txt");
    121119      vrpProblem.Name = "C101 VRP (imported from Solomon)";
    122120      vrpProblem.Description = "Represents a Vehicle Routing Problem.";
     
    168166
    169167    [TestMethod]
    170     public void CreateArtificialAntSampleTest() {
    171       var ga = CreateArtificialAntSample();
     168    public void CreateGpArtificialAntSampleTest() {
     169      var ga = CreateGpArtificialAntSample();
    172170      XmlGenerator.Serialize(ga, "../../SGP_SantaFe.hl");
    173171    }
    174172
    175173    [TestMethod]
    176     public void RunArtificialAntSampleTest() {
    177       var ga = CreateArtificialAntSample();
     174    public void RunGpArtificialAntSampleTest() {
     175      var ga = CreateGpArtificialAntSample();
    178176      ga.SetSeedRandomly.Value = false;
    179177      RunAlgorithm(ga);
     
    184182    }
    185183
    186     public GeneticAlgorithm CreateArtificialAntSample() {
     184    public GeneticAlgorithm CreateGpArtificialAntSample() {
    187185      GeneticAlgorithm ga = new GeneticAlgorithm();
    188186      #region problem configuration
     
    221219    #region symbolic regression
    222220    [TestMethod]
    223     public void CreateSymbolicRegressionSampleTest() {
    224       var ga = CreateSymbolicRegressionSample();
     221    public void CreateGpSymbolicRegressionSampleTest() {
     222      var ga = CreateGpSymbolicRegressionSample();
    225223      XmlGenerator.Serialize(ga, "../../SGP_SymbReg.hl");
    226224    }
    227225    [TestMethod]
    228     public void RunSymbolicRegressionSampleTest() {
    229       var ga = CreateSymbolicRegressionSample();
     226    public void RunGpSymbolicRegressionSampleTest() {
     227      var ga = CreateGpSymbolicRegressionSample();
    230228      ga.SetSeedRandomly.Value = false;
    231229      RunAlgorithm(ga);
     
    236234    }
    237235
    238     private GeneticAlgorithm CreateSymbolicRegressionSample() {
     236    private GeneticAlgorithm CreateGpSymbolicRegressionSample() {
    239237      GeneticAlgorithm ga = new GeneticAlgorithm();
    240238      #region problem configuration
     
    242240      symbRegProblem.Name = "Tower Symbolic Regression Problem";
    243241      symbRegProblem.Description = "Tower Dataset (downloaded from: http://vanillamodeling.com/realproblems.html)";
    244       // import and configure problem data
    245       string filename = Path.GetTempFileName();
    246       using (var writer = File.CreateText(filename)) {
    247         writer.Write(HeuristicLab_33.Tests.Properties.Resources.TowerData);
    248       }
    249       var towerProblemData = RegressionProblemData.ImportFromFile(filename);
     242      var towerProblemData = RegressionProblemData.ImportFromFile("towerData.txt");
    250243      towerProblemData.TargetVariableParameter.Value = towerProblemData.TargetVariableParameter.ValidValues
    251244        .First(v => v.Value == "towerResponse");
     
    341334
    342335    [TestMethod]
    343     public void CreateSymbolicClassificationSampleTest() {
    344       var ga = CreateSymbolicClassificationSample();
     336    public void CreateGpSymbolicClassificationSampleTest() {
     337      var ga = CreateGpSymbolicClassificationSample();
    345338      XmlGenerator.Serialize(ga, "../../SGP_SymbClass.hl");
    346339    }
    347340
    348341    [TestMethod]
    349     public void RunSymbolicClassificationSampleTest() {
    350       var ga = CreateSymbolicClassificationSample();
     342    public void RunGpSymbolicClassificationSampleTest() {
     343      var ga = CreateGpSymbolicClassificationSample();
    351344      ga.SetSeedRandomly.Value = false;
    352345      RunAlgorithm(ga);
     
    357350    }
    358351
    359     private GeneticAlgorithm CreateSymbolicClassificationSample() {
     352    private GeneticAlgorithm CreateGpSymbolicClassificationSample() {
    360353      GeneticAlgorithm ga = new GeneticAlgorithm();
    361354      #region problem configuration
     
    363356      symbClassProblem.Name = "Mammography Classification Problem";
    364357      symbClassProblem.Description = "Mammography dataset imported from the UCI machine learning repository (http://archive.ics.uci.edu/ml/datasets/Mammographic+Mass)";
    365       // import and configure problem data
    366       string filename = Path.GetTempFileName();
    367       using (var writer = File.CreateText(filename)) {
    368         writer.Write(HeuristicLab_33.Tests.Properties.Resources.MammographicMasses);
    369       }
    370       var mammoData = ClassificationProblemData.ImportFromFile(filename);
     358      var mammoData = ClassificationProblemData.ImportFromFile("mammographic_masses.txt");
    371359      mammoData.TargetVariableParameter.Value = mammoData.TargetVariableParameter.ValidValues
    372360        .First(v => v.Value == "Severity");
     
    454442    }
    455443    #endregion
     444    #endregion
     445
     446    #region ES
     447    #region Griewank
     448    [TestMethod]
     449    public void CreateEsGriewankSampleTest() {
     450      var es = CreateEsGriewankSample();
     451      XmlGenerator.Serialize(es, "../../ES_Griewank.hl");
     452    }
     453    [TestMethod]
     454    public void RunEsGriewankSampleTest() {
     455      var es = CreateEsGriewankSample();
     456      es.SetSeedRandomly.Value = false;
     457      RunAlgorithm(es);
     458      Assert.AreEqual(0, GetDoubleResult(es, "BestQuality"));
     459      Assert.AreEqual(0, GetDoubleResult(es, "CurrentAverageQuality"));
     460      Assert.AreEqual(0, GetDoubleResult(es, "CurrentWorstQuality"));
     461      Assert.AreEqual(100020, GetIntResult(es, "EvaluatedSolutions"));
     462    }
     463
     464    private EvolutionStrategy CreateEsGriewankSample() {
     465      EvolutionStrategy es = new EvolutionStrategy();
     466      #region problem configuration
     467      SingleObjectiveTestFunctionProblem problem = new SingleObjectiveTestFunctionProblem();
     468
     469      problem.ProblemSize.Value = 10;
     470      problem.Evaluator = new GriewankEvaluator();
     471      problem.SolutionCreator = new UniformRandomRealVectorCreator();
     472      problem.Maximization.Value = false;
     473      problem.Bounds = new DoubleMatrix(new double[,] { { -600, 600 } });
     474      problem.BestKnownQuality.Value = 0;
     475      problem.BestKnownSolutionParameter.Value = new RealVector(10);
     476      problem.Name = "Single Objective Test Function";
     477      problem.Description = "Test function with real valued inputs and a single objective.";
     478      #endregion
     479      #region algorithm configuration
     480      es.Name = "Evolution Strategy - Griewank";
     481      es.Description = "An evolution strategy which solves the 10-dimensional Griewank test function";
     482      es.Problem = problem;
     483      ConfigureEvolutionStrategyParameters<AverageCrossover, NormalAllPositionsManipulator,
     484        StdDevStrategyVectorCreator, StdDevStrategyVectorCrossover, StdDevStrategyVectorManipulator>(
     485        es, 20, 500, 2, 200, false);
     486
     487      StdDevStrategyVectorCreator strategyCreator = (StdDevStrategyVectorCreator)es.StrategyParameterCreator;
     488      strategyCreator.BoundsParameter.Value = new DoubleMatrix(new double[,] { { 1, 20 } });
     489
     490      StdDevStrategyVectorManipulator strategyManipulator = (StdDevStrategyVectorManipulator)es.StrategyParameterManipulator;
     491      strategyManipulator.BoundsParameter.Value = new DoubleMatrix(new double[,] { { 1E-12, 30 } });
     492      strategyManipulator.GeneralLearningRateParameter.Value = new DoubleValue(0.22360679774997896);
     493      strategyManipulator.LearningRateParameter.Value = new DoubleValue(0.39763536438352531);
     494      #endregion
     495      return es;
     496    }
     497
     498    #endregion
     499    #endregion
     500
     501    #region Island GA
     502    #region TSP
     503    [TestMethod]
     504    public void CreateIslandGaTspSampleTest() {
     505      var ga = CreateIslandGaTspSample();
     506      XmlGenerator.Serialize(ga, "../../IslandGA_TSP.hl");
     507    }
     508    [TestMethod]
     509    public void RunIslandGaTspSampleTest() {
     510      var ga = CreateIslandGaTspSample();
     511      ga.SetSeedRandomly.Value = false;
     512      RunAlgorithm(ga);
     513      Assert.AreEqual(10469, GetDoubleResult(ga, "BestQuality"));
     514      Assert.AreEqual(11184.87, GetDoubleResult(ga, "CurrentAverageQuality"));
     515      Assert.AreEqual(13420, GetDoubleResult(ga, "CurrentWorstQuality"));
     516      Assert.AreEqual(495500, GetIntResult(ga, "EvaluatedSolutions"));
     517    }
     518
     519    private IslandGeneticAlgorithm CreateIslandGaTspSample() {
     520      IslandGeneticAlgorithm ga = new IslandGeneticAlgorithm();
     521      #region problem configuration
     522      TravelingSalesmanProblem tspProblem = new TravelingSalesmanProblem();
     523      tspProblem.ImportFromTSPLIB("ch130.tsp", "ch130.opt.tour", 6110);
     524      tspProblem.Evaluator = new TSPRoundedEuclideanPathEvaluator();
     525      tspProblem.SolutionCreator = new RandomPermutationCreator();
     526      tspProblem.UseDistanceMatrix.Value = true;
     527      tspProblem.Name = "ch130 TSP (imported from TSPLIB)";
     528      tspProblem.Description = "130 city problem (Churritz)";
     529      #endregion
     530      #region algorithm configuration
     531      ga.Name = "Island Genetic Algorithm - TSP";
     532      ga.Description = "An island genetic algorithm which solves the \"ch130\" traveling salesman problem (imported from TSPLIB)";
     533      ga.Problem = tspProblem;
     534      ConfigureIslandGeneticAlgorithmParameters<ProportionalSelector, OrderCrossover2, InversionManipulator,
     535        UnidirectionalRingMigrator, BestSelector, WorstReplacer>(
     536        ga, 100, 1, 1000, 0.05, 5, 50, 0.25);
     537
     538      ga.Analyzer.Operators.SetItemCheckedState(ga.Analyzer.Operators
     539        .OfType<TSPAlleleFrequencyAnalyzer>()
     540        .Single(), false);
     541      ga.Analyzer.Operators.SetItemCheckedState(ga.Analyzer.Operators
     542        .OfType<TSPPopulationDiversityAnalyzer>()
     543        .Single(), false);
     544      #endregion
     545      return ga;
     546    }
     547
     548    #endregion
     549    #endregion
     550
     551    #region LS
     552    #region Knapsack
     553    [TestMethod]
     554    public void CreateLocalSearchKnapsackSampleTest() {
     555      var ls = CreateLocalSearchKnapsackSample();
     556      XmlGenerator.Serialize(ls, "../../LS_Knapsack.hl");
     557    }
     558    [TestMethod]
     559    public void RunLocalSearchKnapsackSampleTest() {
     560      var ls = CreateLocalSearchKnapsackSample();
     561      ls.SetSeedRandomly.Value = false;
     562      RunAlgorithm(ls);
     563      Assert.AreEqual(345, GetDoubleResult(ls, "BestQuality"));
     564      Assert.AreEqual(340.70731707317071, GetDoubleResult(ls, "CurrentAverageQuality"));
     565      Assert.AreEqual(337, GetDoubleResult(ls, "CurrentWorstQuality"));
     566      Assert.AreEqual(82000, GetIntResult(ls, "EvaluatedMoves"));
     567    }
     568
     569    private LocalSearch CreateLocalSearchKnapsackSample() {
     570      LocalSearch ls = new LocalSearch();
     571      #region problem configuration
     572      KnapsackProblem problem = new KnapsackProblem();
     573      problem.BestKnownQuality = new DoubleValue(362);
     574      problem.BestKnownSolution = new HeuristicLab.Encodings.BinaryVectorEncoding.BinaryVector(new bool[] {
     575       true , false, false, true , true , true , true , true , false, true , true , true , true , true , true , false, true , false, true , true , false, true , true , false, true , false, true , true , true , false, true , true , false, true , true , false, true , false, true , true , true , true , true , true , true , true , true , true , true , true , true , false, true , false, false, true , true , false, true , true , true , true , true , true , true , true , false, true , false, true , true , true , true , false, true , true , true , true , true , true , true , true});
     576      problem.Evaluator = new KnapsackEvaluator();
     577      problem.SolutionCreator = new RandomBinaryVectorCreator();
     578      problem.KnapsackCapacity.Value = 297;
     579      problem.Maximization.Value = true;
     580      problem.Penalty.Value = 1;
     581      problem.Values = new IntArray(new int[] {
     582  6, 1, 1, 6, 7, 8, 7, 4, 2, 5, 2, 6, 7, 8, 7, 1, 7, 1, 9, 4, 2, 6, 5,  3, 5, 3, 3, 6, 5, 2, 4, 9, 4, 5, 7, 1, 4, 3, 5, 5, 8, 3, 6, 7, 3, 9, 7, 7, 5, 5, 7, 1, 4, 4, 3, 9, 5, 1, 6, 2, 2, 6, 1, 6, 5, 4, 4, 7, 1,  8, 9, 9, 7, 4, 3, 8, 7, 5, 7, 4, 4, 5});
     583      problem.Weights = new IntArray(new int[] {
     584 1, 9, 3, 6, 5, 3, 8, 1, 7, 4, 2, 1, 2, 7, 9, 9, 8, 4, 9, 2, 4, 8, 3, 7, 5, 7, 5, 5, 1, 9, 8, 7, 8, 9, 1, 3, 3, 8, 8, 5, 1, 2, 4, 3, 6, 9, 4, 4, 9, 7, 4, 5, 1, 9, 7, 6, 7, 4, 7, 1, 2, 1, 2, 9, 8, 6, 8, 4, 7, 6, 7, 5, 3, 9, 4, 7, 4, 6, 1, 2, 5, 4});
     585      problem.Name = "Knapsack Problem";
     586      problem.Description = "Represents a Knapsack problem.";
     587      #endregion
     588      #region algorithm configuration
     589      ls.Name = "Local Search - Knapsack";
     590      ls.Description = "A local search algorithm that solves a randomly generated Knapsack problem";
     591      ls.Problem = problem;
     592      ls.MaximumIterations.Value = 1000;
     593      ls.MoveEvaluator = ls.MoveEvaluatorParameter.ValidValues
     594        .OfType<KnapsackOneBitflipMoveEvaluator>()
     595        .Single();
     596      ls.MoveGenerator = ls.MoveGeneratorParameter.ValidValues
     597        .OfType<ExhaustiveOneBitflipMoveGenerator>()
     598        .Single();
     599      ls.MoveMaker = ls.MoveMakerParameter.ValidValues
     600        .OfType<OneBitflipMoveMaker>()
     601        .Single();
     602      ls.SampleSize.Value = 100;
     603      ls.Seed.Value = 0;
     604      ls.SetSeedRandomly.Value = true;
     605
     606      #endregion
     607      ls.Engine = new ParallelEngine();
     608      return ls;
     609    }
     610
     611    #endregion
     612    #endregion
     613
     614    #region PSO
     615    #region Schwefel
     616    [TestMethod]
     617    public void CreatePsoSchwefelSampleTest() {
     618      var pso = CreatePsoSchwefelSample();
     619      XmlGenerator.Serialize(pso, "../../PSO_Schwefel.hl");
     620    }
     621    [TestMethod]
     622    public void RunPsoSchwefelSampleTest() {
     623      var pso = CreatePsoSchwefelSample();
     624      pso.SetSeedRandomly.Value = false;
     625      RunAlgorithm(pso);
     626      Assert.AreEqual(119.33873327772062, GetDoubleResult(pso, "BestQuality"));
     627      Assert.AreEqual(140.71570105946438, GetDoubleResult(pso, "CurrentAverageQuality"));
     628      Assert.AreEqual(220.956806502853, GetDoubleResult(pso, "CurrentWorstQuality"));
     629      Assert.AreEqual(1000, GetIntResult(pso, "Iterations"));
     630    }
     631    private ParticleSwarmOptimization CreatePsoSchwefelSample() {
     632      ParticleSwarmOptimization pso = new ParticleSwarmOptimization();
     633      #region problem configuration
     634      var problem = new SingleObjectiveTestFunctionProblem();
     635      problem.BestKnownQuality.Value = 0.0;
     636      problem.BestKnownSolutionParameter.Value = new RealVector(new double[] { 420.968746, 420.968746 });
     637      problem.Bounds = new DoubleMatrix(new double[,] { { -500, 500 } });
     638      problem.Evaluator = new SchwefelEvaluator();
     639      problem.Maximization.Value = false;
     640      problem.ProblemSize.Value = 2;
     641      problem.SolutionCreator = new UniformRandomRealVectorCreator();
     642      #endregion
     643      #region algorithm configuration
     644      pso.Name = "Particle Swarm Optimization - Schwefel";
     645      pso.Description = "A particle swarm optimization algorithm which solves the 2-dimensional Schwefel test function (based on the description in Pedersen, M.E.H. (2010). PhD thesis. University of Southampton)";
     646      pso.Problem = problem;
     647      pso.Inertia.Value = 10;
     648      pso.MaxIterations.Value = 1000;
     649      pso.NeighborBestAttraction.Value = 0.5;
     650      pso.PersonalBestAttraction.Value = -0.01;
     651      pso.SwarmSize.Value = 50;
     652
     653      var inertiaUpdater = pso.InertiaUpdaterParameter.ValidValues
     654        .OfType<ExponentialDiscreteDoubleValueModifier>()
     655        .Single();
     656      inertiaUpdater.StartValueParameter.Value = new DoubleValue(10);
     657      inertiaUpdater.EndValueParameter.Value = new DoubleValue(1);
     658      pso.InertiaUpdater = inertiaUpdater;
     659
     660      pso.ParticleCreator = pso.ParticleCreatorParameter.ValidValues
     661        .OfType<RealVectorParticleCreator>()
     662        .Single();
     663      var swarmUpdater = pso.SwarmUpdaterParameter.ValidValues
     664        .OfType<RealVectorSwarmUpdater>()
     665        .Single();
     666      swarmUpdater.VelocityBoundsIndexParameter.ActualName = "Iterations";
     667      swarmUpdater.VelocityBoundsParameter.Value = new DoubleMatrix(new double[,] { { -10, 10 } });
     668      swarmUpdater.VelocityBoundsStartValueParameter.Value = new DoubleValue(10.0);
     669      swarmUpdater.VelocityBoundsEndValueParameter.Value = new DoubleValue(1.0);
     670      swarmUpdater.VelocityBoundsScalingOperatorParameter.Value = swarmUpdater.VelocityBoundsScalingOperatorParameter.ValidValues
     671        .OfType<ExponentialDiscreteDoubleValueModifier>()
     672        .Single();
     673
     674      pso.TopologyInitializer = null;
     675      pso.TopologyUpdater = null;
     676      pso.SwarmUpdater = swarmUpdater;
     677      pso.Seed.Value = 0;
     678      pso.SetSeedRandomly.Value = true;
     679
     680      #endregion
     681      pso.Engine = new ParallelEngine();
     682      return pso;
     683    }
     684    #endregion
     685    #endregion
     686
     687    #region SA
     688    #region Rastrigin
     689    [TestMethod]
     690    public void CreateSimulatedAnnealingRastriginSampleTest() {
     691      var sa = CreateSimulatedAnnealingRastriginSample();
     692      XmlGenerator.Serialize(sa, "../../SA_Rastrigin.hl");
     693    }
     694    [TestMethod]
     695    public void RunSimulatedAnnealingRastriginSampleTest() {
     696      var sa = CreateSimulatedAnnealingRastriginSample();
     697      sa.SetSeedRandomly.Value = false;
     698      RunAlgorithm(sa);
     699      Assert.AreEqual(0.00014039606034543795, GetDoubleResult(sa, "BestQuality"));
     700      Assert.AreEqual(5000, GetIntResult(sa, "EvaluatedMoves"));
     701    }
     702    private SimulatedAnnealing CreateSimulatedAnnealingRastriginSample() {
     703      SimulatedAnnealing sa = new SimulatedAnnealing();
     704      #region problem configuration
     705      var problem = new SingleObjectiveTestFunctionProblem();
     706      problem.BestKnownQuality.Value = 0.0;
     707      problem.BestKnownSolutionParameter.Value = new RealVector(new double[] { 0, 0 });
     708      problem.Bounds = new DoubleMatrix(new double[,] { { -5.12, 5.12 } });
     709      problem.Evaluator = new RastriginEvaluator();
     710      problem.Maximization.Value = false;
     711      problem.ProblemSize.Value = 2;
     712      problem.SolutionCreator = new UniformRandomRealVectorCreator();
     713      #endregion
     714      #region algorithm configuration
     715      sa.Name = "Simulated Annealing - Rastrigin";
     716      sa.Description = "A simulated annealing algorithm that solves the 2-dimensional Rastrigin test function";
     717      sa.Problem = problem;
     718      var annealingOperator = sa.AnnealingOperatorParameter.ValidValues
     719        .OfType<ExponentialDiscreteDoubleValueModifier>()
     720        .Single();
     721      annealingOperator.StartIndexParameter.Value = new IntValue(0);
     722      sa.AnnealingOperator = annealingOperator;
     723
     724      sa.EndTemperature.Value = 1E-6;
     725      sa.InnerIterations.Value = 50;
     726      sa.MaximumIterations.Value = 100;
     727      var moveEvaluator = sa.MoveEvaluatorParameter.ValidValues
     728        .OfType<RastriginAdditiveMoveEvaluator>()
     729        .Single();
     730      moveEvaluator.A.Value = 10;
     731      sa.MoveEvaluator = moveEvaluator;
     732
     733      var moveGenerator = sa.MoveGeneratorParameter.ValidValues
     734        .OfType<StochasticNormalMultiMoveGenerator>()
     735        .Single();
     736      moveGenerator.SigmaParameter.Value = new DoubleValue(1);
     737      sa.MoveGenerator = moveGenerator;
     738
     739      sa.MoveMaker = sa.MoveMakerParameter.ValidValues
     740        .OfType<AdditiveMoveMaker>()
     741        .Single();
     742
     743      sa.Seed.Value = 0;
     744      sa.SetSeedRandomly.Value = true;
     745      sa.StartTemperature.Value = 1;
     746      #endregion
     747      sa.Engine = new ParallelEngine();
     748      return sa;
     749    }
     750    #endregion
     751    #endregion
     752
     753    #region TS
     754    #region TSP
     755    [TestMethod]
     756    public void CreateTabuSearchTspSampleTest() {
     757      var ts = CreateTabuSearchTspSample();
     758      XmlGenerator.Serialize(ts, "../../TS_TSP.hl");
     759    }
     760    [TestMethod]
     761    public void RunTabuSearchTspSampleTest() {
     762      var ts = CreateTabuSearchTspSample();
     763      ts.SetSeedRandomly.Value = false;
     764      RunAlgorithm(ts);
     765      Assert.AreEqual(6441, GetDoubleResult(ts, "BestQuality"));
     766      Assert.AreEqual(7401.666666666667, GetDoubleResult(ts, "CurrentAverageQuality"));
     767      Assert.AreEqual(8418, GetDoubleResult(ts, "CurrentWorstQuality"));
     768      Assert.AreEqual(750000, GetIntResult(ts, "EvaluatedMoves"));
     769    }
     770
     771    private TabuSearch CreateTabuSearchTspSample() {
     772      TabuSearch ts = new TabuSearch();
     773      #region problem configuration
     774      var tspProblem = new TravelingSalesmanProblem();
     775      tspProblem.ImportFromTSPLIB("ch130.tsp", "ch130.opt.tour", 6110);
     776      tspProblem.Evaluator = new TSPRoundedEuclideanPathEvaluator();
     777      tspProblem.SolutionCreator = new RandomPermutationCreator();
     778      tspProblem.UseDistanceMatrix.Value = true;
     779      tspProblem.Name = "ch130 TSP (imported from TSPLIB)";
     780      tspProblem.Description = "130 city problem (Churritz)";
     781      #endregion
     782      #region algorithm configuration
     783      ts.Name = "Tabu Search - TSP";
     784      ts.Description = "A tabu search algorithm that solves the \"ch130\" TSP (imported from TSPLIB)";
     785      ts.Problem = tspProblem;
     786
     787      ts.MaximumIterations.Value = 1000;
     788      // move generator has to be set first
     789      var moveGenerator = ts.MoveGeneratorParameter.ValidValues
     790        .OfType<StochasticInversionMultiMoveGenerator>()
     791        .Single();
     792      ts.MoveGenerator = moveGenerator;
     793      var moveEvaluator = ts.MoveEvaluatorParameter.ValidValues
     794        .OfType<TSPInversionMoveRoundedEuclideanPathEvaluator>()
     795        .Single();
     796      ts.MoveEvaluator = moveEvaluator;
     797      var moveMaker = ts.MoveMakerParameter.ValidValues
     798        .OfType<InversionMoveMaker>()
     799        .Single();
     800      ts.MoveMaker = moveMaker;
     801      ts.SampleSize.Value = 750;
     802      ts.Seed.Value = 0;
     803      ts.SetSeedRandomly.Value = true;
     804
     805      var tabuChecker = ts.TabuCheckerParameter.ValidValues
     806        .OfType<InversionMoveSoftTabuCriterion>()
     807        .Single();
     808      tabuChecker.UseAspirationCriterion.Value = true;
     809      ts.TabuChecker = tabuChecker;
     810
     811      var tabuMaker = ts.TabuMakerParameter.ValidValues
     812        .OfType<InversionMoveTabuMaker>()
     813        .Single();
     814      ts.TabuMaker = tabuMaker;
     815      ts.TabuTenure.Value = 60;
     816
     817      ts.Analyzer.Operators.SetItemCheckedState(ts.Analyzer.Operators
     818        .OfType<TSPAlleleFrequencyAnalyzer>()
     819        .Single(), false);
     820      ts.Analyzer.Operators.SetItemCheckedState(ts.Analyzer.Operators
     821        .OfType<TSPPopulationDiversityAnalyzer>()
     822        .Single(), false);
     823      #endregion
     824      ts.Engine = new ParallelEngine();
     825      return ts;
     826    }
     827
     828    #endregion
     829    #endregion
     830
     831    #region VNS
     832    #region TSP
     833    [TestMethod]
     834    public void CreateVnsTspSampleTest() {
     835      var vns = CreateVnsTspSample();
     836      XmlGenerator.Serialize(vns, "../../VNS_TSP.hl");
     837    }
     838    [TestMethod]
     839    public void RunVnsTspSampleTest() {
     840      var vns = CreateVnsTspSample();
     841      vns.SetSeedRandomly = false;
     842      RunAlgorithm(vns);
     843      Assert.AreEqual(867, GetDoubleResult(vns, "BestQuality"));
     844      Assert.AreEqual(867, GetDoubleResult(vns, "CurrentAverageQuality"));
     845      Assert.AreEqual(867, GetDoubleResult(vns, "CurrentWorstQuality"));
     846      Assert.AreEqual(12975173, GetIntResult(vns, "EvaluatedMoves"));
     847    }
     848
     849    private VariableNeighborhoodSearch CreateVnsTspSample() {
     850      VariableNeighborhoodSearch vns = new VariableNeighborhoodSearch();
     851      #region problem configuration
     852      TravelingSalesmanProblem tspProblem = new TravelingSalesmanProblem();
     853      tspProblem.BestKnownSolution = new Permutation(PermutationTypes.Absolute, new int[] {
     854117, 65, 73, 74, 75, 76, 82, 86, 87, 94, 100, 106, 115, 120, 124, 107, 101, 108, 109, 102, 97, 90, 96, 95, 88, 89, 84, 78, 69, 57, 68, 56, 44, 55, 45, 36, 46, 37, 38, 47, 48, 59, 49, 58, 70, 77, 83, 79, 50, 80, 85, 98, 103, 110, 116, 121, 125, 133, 132, 138, 139, 146, 147, 159, 168, 169, 175, 182, 188, 201, 213, 189, 214, 221, 230, 246, 262, 276, 284, 275, 274, 261, 245, 229, 220, 228, 243, 259, 273, 282, 272, 258, 242, 257, 293, 292, 302, 310, 319, 320, 327, 326, 333, 340, 346, 339, 345, 344, 337, 338, 332, 325, 318, 309, 301, 291, 271, 251, 270, 233, 250, 269, 268, 280, 290, 300, 415, 440, 416, 417, 441, 458, 479, 418, 419, 395, 420, 442, 421, 396, 397, 422, 423, 461, 481, 502, 460, 501, 459, 480, 500, 517, 531, 516, 530, 499, 478, 457, 439, 414, 413, 412, 438, 456, 477, 498, 515, 529, 538, 547, 558, 559, 560, 548, 539, 549, 561, 562, 551, 550, 532, 540, 533, 541, 518, 534, 542, 552, 553, 554, 555, 535, 543, 556, 544, 536, 522, 505, 521, 520, 504, 519, 503, 482, 462, 463, 464, 483, 443, 465, 484, 506, 485, 507, 508, 487, 467, 486, 466, 445, 428, 444, 424, 425, 426, 427, 398, 399, 400, 381, 382, 371, 372, 401, 429, 446, 430, 402, 383, 366, 356, 357, 352, 385, 384, 403, 431, 447, 469, 468, 488, 489, 490, 470, 471, 448, 432, 433, 404, 405, 386, 373, 374, 367, 376, 375, 387, 491, 509, 537, 510, 492, 472, 449, 388, 389, 406, 450, 407, 377, 368, 359, 354, 350, 335, 324, 330, 390, 434, 451, 473, 493, 511, 523, 545, 563, 565, 567, 570, 569, 578, 577, 576, 575, 574, 573, 572, 580, 584, 583, 582, 587, 586, 585, 581, 579, 571, 568, 566, 564, 557, 546, 527, 513, 526, 525, 524, 512, 495, 494, 474, 452, 436, 409, 435, 453, 475, 496, 514, 528, 497, 455, 476, 454, 437, 411, 410, 394, 393, 392, 380, 370, 379, 408, 391, 378, 369, 364, 365, 361, 355, 351, 343, 336, 331, 317, 299, 286, 287, 278, 263, 264, 265, 223, 202, 248, 266, 279, 288, 289, 281, 267, 249, 232, 224, 216, 215, 204, 192, 193, 194, 186, 179, 185, 203, 191, 190, 177, 171, 161, 128, 135, 140, 149, 162, 150, 163, 172, 178, 173, 164, 152, 151, 141, 153, 165, 154, 142, 155, 143, 137, 136, 130, 129, 118, 114, 113, 105, 119, 123, 131, 144, 156, 157, 145, 158, 166, 167, 174, 180, 181, 187, 195, 205, 217, 226, 236, 225, 234, 252, 235, 253, 254, 255, 238, 239, 240, 241, 256, 237, 206, 207, 208, 196, 197, 198, 209, 199, 200, 211, 212, 219, 210, 218, 227, 244, 260, 283, 294, 295, 303, 296, 311, 304, 297, 298, 305, 285, 306, 314, 329, 321, 313, 312, 328, 334, 341, 347, 348, 353, 358, 362, 363, 360, 349, 342, 322, 323, 315, 316, 308, 307, 277, 247, 231, 222, 184, 183, 176, 170, 160, 148, 134, 127, 126, 111, 104, 92, 91, 71, 60, 51, 52, 40, 32, 23, 21, 20, 18, 17, 16, 14, 13, 11, 10, 7, 6, 5, 2, 1, 0, 3, 4, 31, 39, 25, 30, 35, 34, 33, 43, 54, 42, 27, 28, 29, 9, 8, 12, 15, 19, 22, 24, 26, 41, 67, 66, 64, 63, 53, 62, 61, 72, 81, 93, 99, 112, 122,
     855      });
     856      tspProblem.Coordinates = new DoubleMatrix(new double[,] {
     857{48, 71}, {49, 71}, {50, 71}, {44, 70}, {45, 70}, {52, 70}, {53, 70}, {54, 70}, {41, 69}, {42, 69}, {55, 69}, {56, 69}, {40, 68}, {56, 68}, {57, 68}, {39, 67}, {57, 67}, {58, 67}, {59, 67}, {38, 66}, {59, 66}, {60, 66}, {37, 65}, {60, 65}, {36, 64}, {43, 64}, {35, 63}, {37, 63}, {41, 63}, {42, 63}, {43, 63}, {47, 63}, {61, 63}, {40, 62}, {41, 62}, {42, 62}, {43, 62}, {45, 62}, {46, 62}, {47, 62}, {62, 62}, {34, 61}, {38, 61}, {39, 61}, {42, 61}, {43, 61}, {44, 61}, {45, 61}, {46, 61}, {47, 61}, {52, 61}, {62, 61}, {63, 61}, {26, 60}, {38, 60}, {42, 60}, {43, 60}, {44, 60}, {46, 60}, {47, 60}, {63, 60}, {23, 59}, {24, 59}, {27, 59}, {29, 59}, {30, 59}, {31, 59}, {33, 59}, {42, 59}, {46, 59}, {47, 59}, {63, 59}, {21, 58}, {32, 58}, {33, 58}, {34, 58}, {35, 58}, {46, 58}, {47, 58}, {48, 58}, {53, 58}, {21, 57}, {35, 57}, {47, 57}, {48, 57}, {53, 57}, {36, 56}, {37, 56}, {46, 56}, {47, 56}, {48, 56}, {64, 56}, {65, 56}, {20, 55}, {38, 55}, {46, 55}, {47, 55}, {48, 55}, {52, 55}, {21, 54}, {40, 54}, {47, 54}, {48, 54}, {52, 54}, {65, 54}, {30, 53}, {41, 53}, {46, 53}, {47, 53}, {48, 53}, {52, 53}, {65, 53}, {21, 52}, {32, 52}, {33, 52}, {42, 52}, {51, 52}, {21, 51}, {33, 51}, {34, 51}, {43, 51}, {51, 51}, {21, 50}, {35, 50}, {44, 50}, {50, 50}, {66, 50}, {67, 50}, {21, 49}, {34, 49}, {36, 49}, {37, 49}, {46, 49}, {49, 49}, {67, 49}, {22, 48}, {36, 48}, {37, 48}, {46, 48}, {47, 48}, {22, 47}, {30, 47}, {34, 47}, {37, 47}, {38, 47}, {39, 47}, {47, 47}, {48, 47}, {67, 47}, {23, 46}, {28, 46}, {29, 46}, {30, 46}, {31, 46}, {32, 46}, {35, 46}, {37, 46}, {38, 46}, {39, 46}, {49, 46}, {67, 46}, {23, 45}, {28, 45}, {29, 45}, {31, 45}, {32, 45}, {40, 45}, {41, 45}, {49, 45}, {50, 45}, {68, 45}, {24, 44}, {29, 44}, {32, 44}, {41, 44}, {51, 44}, {68, 44}, {25, 43}, {30, 43}, {32, 43}, {42, 43}, {43, 43}, {51, 43}, {68, 43}, {69, 43}, {31, 42}, {32, 42}, {43, 42}, {52, 42}, {55, 42}, {26, 41}, {27, 41}, {31, 41}, {32, 41}, {33, 41}, {44, 41}, {45, 41}, {46, 41}, {47, 41}, {48, 41}, {49, 41}, {53, 41}, {25, 40}, {27, 40}, {32, 40}, {43, 40}, {44, 40}, {45, 40}, {46, 40}, {48, 40}, {49, 40}, {50, 40}, {51, 40}, {53, 40}, {56, 40}, {32, 39}, {33, 39}, {43, 39}, {50, 39}, {51, 39}, {54, 39}, {56, 39}, {69, 39}, {24, 38}, {32, 38}, {41, 38}, {42, 38}, {51, 38}, {52, 38}, {54, 38}, {57, 38}, {69, 38}, {31, 37}, {32, 37}, {40, 37}, {41, 37}, {42, 37}, {43, 37}, {44, 37}, {45, 37}, {46, 37}, {47, 37}, {48, 37}, {51, 37}, {52, 37}, {55, 37}, {57, 37}, {69, 37}, {24, 36}, {31, 36}, {32, 36}, {39, 36}, {40, 36}, {41, 36}, {42, 36}, {43, 36}, {45, 36}, {48, 36}, {49, 36}, {51, 36}, {53, 36}, {55, 36}, {58, 36}, {22, 35}, {23, 35}, {24, 35}, {25, 35}, {30, 35}, {31, 35}, {32, 35}, {39, 35}, {41, 35}, {49, 35}, {51, 35}, {55, 35}, {56, 35}, {58, 35}, {71, 35}, {20, 34}, {27, 34}, {30, 34}, {31, 34}, {51, 34}, {53, 34}, {57, 34}, {60, 34}, {18, 33}, {19, 33}, {29, 33}, {30, 33}, {31, 33}, {45, 33}, {46, 33}, {47, 33}, {52, 33}, {53, 33}, {55, 33}, {57, 33}, {58, 33}, {17, 32}, {30, 32}, {44, 32}, {47, 32}, {54, 32}, {57, 32}, {59, 32}, {61, 32}, {71, 32}, {72, 32}, {43, 31}, {47, 31}, {56, 31}, {58, 31}, {59, 31}, {61, 31}, {72, 31}, {74, 31}, {16, 30}, {43, 30}, {46, 30}, {47, 30}, {59, 30}, {63, 30}, {71, 30}, {75, 30}, {43, 29}, {46, 29}, {47, 29}, {59, 29}, {60, 29}, {75, 29}, {15, 28}, {43, 28}, {46, 28}, {61, 28}, {76, 28}, {15, 27}, {43, 27}, {44, 27}, {45, 27}, {46, 27}, {60, 27}, {62, 27}, {15, 26}, {43, 26}, {44, 26}, {46, 26}, {59, 26}, {60, 26}, {64, 26}, {77, 26}, {15, 25}, {58, 25}, {61, 25}, {77, 25}, {15, 24}, {53, 24}, {55, 24}, {61, 24}, {77, 24}, {62, 23}, {16, 22}, {61, 22}, {62, 22}, {15, 21}, {16, 21}, {52, 21}, {63, 21}, {77, 21}, {16, 20}, {17, 20}, {46, 20}, {47, 20}, {60, 20}, {62, 20}, {63, 20}, {65, 20}, {76, 20}, {15, 19}, {17, 19}, {18, 19}, {44, 19}, {45, 19}, {48, 19}, {53, 19}, {56, 19}, {60, 19}, {62, 19}, {67, 19}, {68, 19}, {76, 19}, {15, 18}, {18, 18}, {19, 18}, {20, 18}, {32, 18}, {33, 18}, {34, 18}, {41, 18}, {42, 18}, {43, 18}, {46, 18}, {48, 18}, {53, 18}, {59, 18}, {60, 18}, {69, 18}, {75, 18}, {16, 17}, {17, 17}, {20, 17}, {21, 17}, {22, 17}, {23, 17}, {24, 17}, {26, 17}, {28, 17}, {29, 17}, {30, 17}, {31, 17}, {32, 17}, {34, 17}, {35, 17}, {36, 17}, {37, 17}, {38, 17}, {39, 17}, {40, 17}, {44, 17}, {46, 17}, {48, 17}, {53, 17}, {56, 17}, {58, 17}, {75, 17}, {17, 16}, {18, 16}, {20, 16}, {24, 16}, {26, 16}, {27, 16}, {29, 16}, {33, 16}, {41, 16}, {42, 16}, {44, 16}, {47, 16}, {52, 16}, {57, 16}, {70, 16}, {73, 16}, {74, 16}, {17, 15}, {18, 15}, {20, 15}, {22, 15}, {24, 15}, {27, 15}, {29, 15}, {31, 15}, {33, 15}, {35, 15}, {36, 15}, {38, 15}, {39, 15}, {42, 15}, {45, 15}, {47, 15}, {52, 15}, {53, 15}, {55, 15}, {56, 15}, {70, 15}, {73, 15}, {17, 14}, {19, 14}, {21, 14}, {24, 14}, {26, 14}, {29, 14}, {31, 14}, {34, 14}, {37, 14}, {40, 14}, {42, 14}, {44, 14}, {46, 14}, {47, 14}, {53, 14}, {54, 14}, {55, 14}, {62, 14}, {70, 14}, {72, 14}, {17, 13}, {19, 13}, {21, 13}, {23, 13}, {25, 13}, {27, 13}, {30, 13}, {32, 13}, {34, 13}, {36, 13}, {38, 13}, {41, 13}, {43, 13}, {44, 13}, {45, 13}, {60, 13}, {70, 13}, {71, 13}, {18, 12}, {21, 12}, {23, 12}, {26, 12}, {28, 12}, {31, 12}, {34, 12}, {37, 12}, {39, 12}, {41, 12}, {42, 12}, {70, 12}, {18, 11}, {19, 11}, {20, 11}, {21, 11}, {24, 11}, {25, 11}, {27, 11}, {29, 11}, {31, 11}, {33, 11}, {35, 11}, {38, 11}, {41, 11}, {59, 11}, {26, 10}, {29, 10}, {32, 10}, {34, 10}, {36, 10}, {39, 10}, {40, 10}, {69, 10}, {21, 9}, {26, 9}, {28, 9}, {30, 9}, {32, 9}, {33, 9}, {35, 9}, {36, 9}, {37, 9}, {38, 9}, {39, 9}, {22, 8}, {27, 8}, {28, 8}, {29, 8}, {30, 8}, {31, 8}, {68, 8}, {23, 7}, {66, 7}, {24, 6}, {65, 6}, {25, 5}, {62, 5}, {63, 5}, {26, 4}, {55, 4}, {56, 4}, {57, 4}, {58, 4}, {59, 4}, {60, 4}, {61, 4}, {28, 3}, {53, 3}, {29, 2}, {50, 2}, {51, 2}, {52, 2}, {31, 1}, {32, 1}, {48, 1}
     858      });
     859      tspProblem.BestKnownQuality = new DoubleValue(867);
     860
     861      tspProblem.Evaluator = new TSPRoundedEuclideanPathEvaluator();
     862      tspProblem.SolutionCreator = new RandomPermutationCreator();
     863      tspProblem.UseDistanceMatrix.Value = true;
     864      tspProblem.Name = "Funny TSP";
     865      tspProblem.Description = "Represents a symmetric Traveling Salesman Problem.";
     866      #endregion
     867      #region algorithm configuration
     868      vns.Name = "Variable Neighborhood Search - TSP";
     869      vns.Description = "A variable neighborhood search algorithm which solves a funny TSP instance";
     870      vns.Problem = tspProblem;
     871
     872      var localImprovement = vns.LocalImprovementParameter.ValidValues
     873        .OfType<LocalSearchImprovementOperator>()
     874        .Single();
     875      // move generator has to be set first
     876      localImprovement.MoveGenerator = localImprovement.MoveGeneratorParameter.ValidValues
     877        .OfType<StochasticInversionMultiMoveGenerator>()
     878        .Single();
     879      localImprovement.MoveEvaluator = localImprovement.MoveEvaluatorParameter.ValidValues
     880        .OfType<TSPInversionMoveRoundedEuclideanPathEvaluator>()
     881        .Single();
     882      localImprovement.MoveMaker = localImprovement.MoveMakerParameter.ValidValues
     883        .OfType<InversionMoveMaker>()
     884        .Single();
     885      localImprovement.SampleSizeParameter.Value = new IntValue(500);
     886      vns.LocalImprovement = localImprovement;
     887
     888      vns.LocalImprovementMaximumIterations = 150;
     889      vns.MaximumIterations = 25;
     890      vns.Seed = 0;
     891      vns.SetSeedRandomly = true;
     892      var shakingOperator = vns.ShakingOperatorParameter.ValidValues
     893        .OfType<PermutationShakingOperator>()
     894        .Single();
     895      shakingOperator.Operators.SetItemCheckedState(shakingOperator.Operators
     896        .OfType<Swap2Manipulator>()
     897        .Single(), false);
     898      shakingOperator.Operators.SetItemCheckedState(shakingOperator.Operators
     899        .OfType<Swap3Manipulator>()
     900        .Single(), false);
     901      vns.ShakingOperator = shakingOperator;
     902      vns.Analyzer.Operators.SetItemCheckedState(vns.Analyzer.Operators
     903        .OfType<TSPAlleleFrequencyAnalyzer>()
     904        .Single(), false);
     905      vns.Analyzer.Operators.SetItemCheckedState(vns.Analyzer.Operators
     906        .OfType<TSPPopulationDiversityAnalyzer>()
     907        .Single(), false);
     908      #endregion
     909      vns.Engine = new ParallelEngine();
     910      return vns;
     911    }
     912
     913    #endregion
     914    #endregion
     915    #region helper
     916    private void ConfigureEvolutionStrategyParameters<R, M, SC, SR, SM>(EvolutionStrategy es, int popSize, int children, int parentsPerChild, int maxGens, bool plusSelection)
     917      where R : ICrossover
     918      where M : IManipulator
     919      where SC : IStrategyParameterCreator
     920      where SR : IStrategyParameterCrossover
     921      where SM : IStrategyParameterManipulator {
     922      es.PopulationSize.Value = popSize;
     923      es.Children.Value = children;
     924      es.ParentsPerChild.Value = parentsPerChild;
     925      es.MaximumGenerations.Value = maxGens;
     926      es.PlusSelection.Value = false;
     927
     928      es.Seed.Value = 0;
     929      es.SetSeedRandomly.Value = true;
     930
     931      es.Recombinator = es.RecombinatorParameter.ValidValues
     932        .OfType<R>()
     933        .Single();
     934
     935      es.Mutator = es.MutatorParameter.ValidValues
     936        .OfType<M>()
     937        .Single();
     938
     939      es.StrategyParameterCreator = es.StrategyParameterCreatorParameter.ValidValues
     940        .OfType<SC>()
     941        .Single();
     942      es.StrategyParameterCrossover = es.StrategyParameterCrossoverParameter.ValidValues
     943        .OfType<SR>()
     944        .Single();
     945      es.StrategyParameterManipulator = es.StrategyParameterManipulatorParameter.ValidValues
     946        .OfType<SM>()
     947        .Single();
     948      es.Engine = new ParallelEngine();
     949    }
    456950
    457951    private void ConfigureGeneticAlgorithmParameters<S, C, M>(GeneticAlgorithm ga, int popSize, int elites, int maxGens, double mutationRate, int tournGroupSize = 0)
     
    479973      var tSelector = ga.Selector as TournamentSelector;
    480974      if (tSelector != null) {
    481         tSelector.GroupSizeParameter.Value.Value = 5;
     975        tSelector.GroupSizeParameter.Value.Value = tournGroupSize;
    482976      }
     977      ga.Engine = new ParallelEngine();
     978    }
     979
     980    private void ConfigureIslandGeneticAlgorithmParameters<S, C, M, Mi, MiS, MiR>(IslandGeneticAlgorithm ga, int popSize, int elites, int maxGens, double mutationRate, int numberOfIslands, int migrationInterval, double migrationRate)
     981      where S : ISelector
     982      where C : ICrossover
     983      where M : IManipulator
     984      where Mi : IMigrator
     985      where MiS : ISelector
     986      where MiR : IReplacer {
     987      ga.Elites.Value = elites;
     988      ga.MaximumGenerations.Value = maxGens;
     989      ga.MutationProbability.Value = mutationRate;
     990      ga.PopulationSize.Value = popSize;
     991      ga.NumberOfIslands.Value = numberOfIslands;
     992      ga.MigrationInterval.Value = migrationInterval;
     993      ga.MigrationRate.Value = migrationRate;
     994      ga.Seed.Value = 0;
     995      ga.SetSeedRandomly.Value = true;
     996      ga.Selector = ga.SelectorParameter.ValidValues
     997        .OfType<S>()
     998        .Single();
     999
     1000      ga.Crossover = ga.CrossoverParameter.ValidValues
     1001        .OfType<C>()
     1002        .Single();
     1003
     1004      ga.Mutator = ga.MutatorParameter.ValidValues
     1005        .OfType<M>()
     1006        .Single();
     1007      ga.Migrator = ga.MigratorParameter.ValidValues
     1008        .OfType<Mi>()
     1009        .Single();
     1010      ga.EmigrantsSelector = ga.EmigrantsSelectorParameter.ValidValues
     1011        .OfType<MiS>()
     1012        .Single();
     1013      ga.ImmigrationReplacer = ga.ImmigrationReplacerParameter.ValidValues
     1014        .OfType<MiR>()
     1015        .Single();
    4831016      ga.Engine = new ParallelEngine();
    4841017    }
     
    4891022      Exception ex = null;
    4901023      a.Stopped += (src, e) => { trigger.Set(); };
    491       a.ExceptionOccurred += (src, e) => { ex = e.Value; };
     1024      a.ExceptionOccurred += (src, e) => { ex = e.Value; trigger.Set(); };
    4921025      a.Prepare();
    4931026      a.Start();
     
    4971030    }
    4981031
    499     private double GetDoubleResult(GeneticAlgorithm ga, string resultName) {
    500       return ((DoubleValue)ga.Results[resultName].Value).Value;
    501     }
    502     private int GetIntResult(GeneticAlgorithm ga, string resultName) {
    503       return ((IntValue)ga.Results[resultName].Value).Value;
    504     }
     1032    private double GetDoubleResult(IAlgorithm a, string resultName) {
     1033      return ((DoubleValue)a.Results[resultName].Value).Value;
     1034    }
     1035    private int GetIntResult(IAlgorithm a, string resultName) {
     1036      return ((IntValue)a.Results[resultName].Value).Value;
     1037    }
     1038    #endregion
    5051039  }
    5061040}
Note: See TracChangeset for help on using the changeset viewer.