Changeset 14894 for branches/SAPBA
- Timestamp:
- 04/27/17 13:45:01 (8 years ago)
- Location:
- branches/SAPBA/HeuristicLab.Algorithms.SAPBA
- Files:
-
- 1 added
- 3 deleted
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/SAPBA/HeuristicLab.Algorithms.SAPBA
-
Property
svn:global-ignores
set to
.vs
obj
-
Property
svn:ignore
set to
new 2.txt
-
Property
svn:global-ignores
set to
-
branches/SAPBA/HeuristicLab.Algorithms.SAPBA/EgoUtilities.cs
r14893 r14894 93 93 94 94 public static IRegressionSolution BuildModel(CancellationToken cancellationToken, IEnumerable<Tuple<RealVector, double>> samples, IDataAnalysisAlgorithm<IRegressionProblem> regressionAlgorithm, IRandom random, bool removeDuplicates = true, IRegressionSolution oldSolution = null) { 95 var dataset = EgoUtilities.GetDataSet(samples.ToList(), removeDuplicates);95 var dataset = GetDataSet(samples.ToList(), removeDuplicates); 96 96 var problemdata = new RegressionProblemData(dataset, dataset.VariableNames.Where(x => !x.Equals("output")), "output"); 97 97 problemdata.TrainingPartition.Start = 0; -
branches/SAPBA/HeuristicLab.Algorithms.SAPBA/HeuristicLab.Algorithms.SAPBA-3.4.csproj
r14893 r14894 42 42 <SpecificVersion>False</SpecificVersion> 43 43 <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Algorithms.EvolutionStrategy-3.3.dll</HintPath> 44 </Reference> 45 <Reference Include="HeuristicLab.Algorithms.GeneticAlgorithm-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 46 <SpecificVersion>False</SpecificVersion> 47 <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Algorithms.GeneticAlgorithm-3.3.dll</HintPath> 44 48 </Reference> 45 49 <Reference Include="HeuristicLab.Analysis-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> … … 120 124 <ItemGroup> 121 125 <Compile Include="EgoUtilities.cs" /> 126 <Compile Include="Strategies\IndividualStrategy.cs" /> 122 127 <Compile Include="Strategies\GenerationalStrategy.cs" /> 123 128 <Compile Include="SurrogateAssistedPopulationBasedAlgorithm.cs" /> -
branches/SAPBA/HeuristicLab.Algorithms.SAPBA/Plugin.cs
r14893 r14894 20 20 #endregion 21 21 22 using System; 23 using System.Collections.Generic; 24 using System.Text; 22 25 using HeuristicLab.PluginInfrastructure; 23 26 24 27 namespace HeuristicLab.Algorithms.SAPBA { 25 [Plugin("HeuristicLab.Algorithms.SAPBA", "3.4.5.148 33")]26 [PluginFile("HeuristicLab.Algorithms. EGO-3.4.dll", PluginFileType.Assembly)]28 [Plugin("HeuristicLab.Algorithms.SAPBA", "3.4.5.14893")] 29 [PluginFile("HeuristicLab.Algorithms.SAPBA-3.4.dll", PluginFileType.Assembly)] 27 30 [PluginFile("displayModelFrame.html", PluginFileType.Data)] 28 31 [PluginDependency("HeuristicLab.Algorithms.CMAEvolutionStrategy", "3.4")] … … 35 38 [PluginDependency("HeuristicLab.Data", "3.3")] 36 39 [PluginDependency("HeuristicLab.Encodings.RealVectorEncoding", "3.3")] 37 [PluginDependency("HeuristicLab.Operators", 38 [PluginDependency("HeuristicLab.Optimization", 39 [PluginDependency("HeuristicLab.Parameters", 40 [PluginDependency("HeuristicLab.Persistence", 40 [PluginDependency("HeuristicLab.Operators","3.3")] 41 [PluginDependency("HeuristicLab.Optimization","3.3")] 42 [PluginDependency("HeuristicLab.Parameters","3.3")] 43 [PluginDependency("HeuristicLab.Persistence","3.3")] 41 44 [PluginDependency("HeuristicLab.Problems.DataAnalysis", "3.4")] 42 45 [PluginDependency("HeuristicLab.Problems.Instances", "3.3")] -
branches/SAPBA/HeuristicLab.Algorithms.SAPBA/Properties/AssemblyInfo.cs
r14893 r14894 53 53 // by using the '*' as shown below: 54 54 [assembly: AssemblyVersion("3.4.0.0")] 55 [assembly: AssemblyFileVersion("3.4.0.148 33")]55 [assembly: AssemblyFileVersion("3.4.0.14893")] -
branches/SAPBA/HeuristicLab.Algorithms.SAPBA/Strategies/GenerationalStrategy.cs
r14893 r14894 37 37 if (RegressionSolution != null && Generations < NoGenerations.Value) Generations++; 38 38 else { 39 foreach (var indi in individuals) Evaluate (indi.RealVector(), random);39 foreach (var indi in individuals) EvaluateSample(indi.RealVector(), random); 40 40 BuildRegressionSolution(random); 41 41 Generations = 0; -
branches/SAPBA/HeuristicLab.Algorithms.SAPBA/Strategies/StrategyBase.cs
r14893 r14894 38 38 #region Properties 39 39 [Storable] 40 pr ivateSurrogateAssistedPopulationBasedAlgorithm Algorithm;40 protected SurrogateAssistedPopulationBasedAlgorithm Algorithm; 41 41 [Storable] 42 42 private List<Tuple<RealVector, double>> Samples; … … 92 92 93 93 if (!globalResults.ContainsKey(BestQualityResultName)) globalResults.Add(new Result(BestQualityResultName, new DoubleValue(0.0))); 94 ((DoubleValue)globalResults[BestQualityResultName].Value).Value = qualities[bestIdx];95 if (!globalResults.ContainsKey(BestSolutionResultName)) globalResults.Add(new Result(Best QualityResultName, new RealVector()));96 globalResults[BestSolutionResultName].Value = individuals[bestIdx].RealVector();94 ((DoubleValue)globalResults[BestQualityResultName].Value).Value = Samples[bestIdx].Item2; 95 if (!globalResults.ContainsKey(BestSolutionResultName)) globalResults.Add(new Result(BestSolutionResultName, new RealVector())); 96 globalResults[BestSolutionResultName].Value = Samples[bestIdx].Item1; 97 97 98 98 DataTable table; … … 135 135 } 136 136 protected Tuple<RealVector, double> EvaluateSample(RealVector point, IRandom random) { 137 Cancellation.ThrowIfCancellationRequested(); 138 if (Samples.Count >= Algorithm.MaximumEvaluations) { Algorithm.OptimizationAlgorithm.Stop(); return new Tuple<RealVector, double>(point, 0.0); } 137 139 var p = new Tuple<RealVector, double>(point, Algorithm.Problem.Evaluate(GetIndividual(point), random)); 138 140 Samples.Add(p); … … 140 142 } 141 143 protected Tuple<RealVector, double> EstimateSample(RealVector point, IRandom random) { 144 if (Samples.Count == Algorithm.InitialEvaluations && RegressionSolution == null) BuildRegressionSolution(random); 142 145 return Samples.Count < Algorithm.InitialEvaluations ? EvaluateSample(point, random) : new Tuple<RealVector, double>(point, RegressionSolution.Model.GetEstimation(point)); 143 146 } -
branches/SAPBA/HeuristicLab.Algorithms.SAPBA/SurrogateAssistedPopulationBasedAlgorithm.cs
r14893 r14894 44 44 public override bool SupportsPause => true; 45 45 public override Type ProblemType => typeof(SingleObjectiveBasicProblem<IEncoding>); 46 public new SingleObjectiveBasicProblem<IEncoding> Problem { 46 public new SingleObjectiveBasicProblem<IEncoding> Problem 47 { 47 48 get { return (SingleObjectiveBasicProblem<IEncoding>)base.Problem; } 48 49 set { base.Problem = value; } … … 51 52 52 53 #region ParameterNames 53 private const string GenerationSizeParameterName = "GenerationSize";54 54 private const string InitialEvaluationsParameterName = "Initial Evaluations"; 55 55 private const string MaximalDataSetSizeParameterName = "Maximal Dataset Size"; … … 57 57 private const string MaximumRuntimeParameterName = "Maximum Runtime"; 58 58 private const string OptimizationAlgorithmParameterName = "Optimization Algorithm"; 59 private const string OptimizationRestartsParameterName = "Optimization Restarts";60 59 private const string RemoveDuplicatesParamterName = "RemoveDuplicates"; 61 60 private const string RegressionAlgorithmParameterName = "RegressionAlgorithm"; … … 66 65 67 66 #region ParameterProperties 68 public IFixedValueParameter<IntValue> GenerationSizeParemeter => Parameters[GenerationSizeParameterName] as IFixedValueParameter<IntValue>;69 67 public IFixedValueParameter<IntValue> InitialEvaluationsParameter => Parameters[InitialEvaluationsParameterName] as IFixedValueParameter<IntValue>; 70 68 public IFixedValueParameter<IntValue> MaximalDataSetSizeParameter => Parameters[MaximalDataSetSizeParameterName] as IFixedValueParameter<IntValue>; … … 72 70 public IFixedValueParameter<IntValue> MaximumRuntimeParameter => Parameters[MaximumRuntimeParameterName] as IFixedValueParameter<IntValue>; 73 71 public IValueParameter<Algorithm> OptimizationAlgorithmParameter => Parameters[OptimizationAlgorithmParameterName] as IValueParameter<Algorithm>; 74 public IFixedValueParameter<IntValue> OptimizationRestartsParemeter => Parameters[OptimizationRestartsParameterName] as IFixedValueParameter<IntValue>;75 72 public IValueParameter<IDataAnalysisAlgorithm<IRegressionProblem>> RegressionAlgorithmParameter => Parameters[RegressionAlgorithmParameterName] as IValueParameter<IDataAnalysisAlgorithm<IRegressionProblem>>; 76 73 public IFixedValueParameter<BoolValue> RemoveDuplicatesParameter => Parameters[RemoveDuplicatesParamterName] as IFixedValueParameter<BoolValue>; … … 81 78 82 79 #region Properties 83 public int GenerationSize => GenerationSizeParemeter.Value.Value;84 80 public int InitialEvaluations => InitialEvaluationsParameter.Value.Value; 85 81 public int MaximalDatasetSize => MaximalDataSetSizeParameter.Value.Value; … … 87 83 public int MaximumRuntime => MaximumRuntimeParameter.Value.Value; 88 84 public Algorithm OptimizationAlgorithm => OptimizationAlgorithmParameter.Value; 89 public int OptimizationRestarts => OptimizationRestartsParemeter.Value.Value;90 85 public IDataAnalysisAlgorithm<IRegressionProblem> RegressionAlgorithm => RegressionAlgorithmParameter.Value; 91 86 public bool RemoveDuplicates => RemoveDuplicatesParameter.Value.Value; … … 121 116 public override IDeepCloneable Clone(Cloner cloner) { return new SurrogateAssistedPopulationBasedAlgorithm(this, cloner); } 122 117 public SurrogateAssistedPopulationBasedAlgorithm() { 123 var cmaes = new CMAEvolutionStrategy.CMAEvolutionStrategy { 124 MaximumGenerations = 300, 125 PopulationSize = 50 118 surrogateProblem = new SurrogateProblem(); 119 var geneticAlgorithm = new GeneticAlgorithm.GeneticAlgorithm { 120 PopulationSize = { Value = 50 }, 121 Problem = surrogateProblem 126 122 }; 127 123 var model = new GaussianProcessRegression { … … 130 126 model.CovarianceFunctionParameter.Value = new CovarianceRationalQuadraticIso(); 131 127 132 cmaes.Problem = new SurrogateProblem();133 128 Parameters.Add(new FixedValueParameter<IntValue>(MaximumEvaluationsParameterName, "", new IntValue(int.MaxValue))); 134 129 Parameters.Add(new FixedValueParameter<IntValue>(InitialEvaluationsParameterName, "", new IntValue(10))); … … 137 132 Parameters.Add(new FixedValueParameter<BoolValue>(SetSeedRandomlyParameterName, "True if the random seed should be set to a random value, otherwise false.", new BoolValue(true))); 138 133 Parameters.Add(new ValueParameter<IDataAnalysisAlgorithm<IRegressionProblem>>(RegressionAlgorithmParameterName, "The model used to approximate the problem", model)); 139 Parameters.Add(new ValueParameter<Algorithm>(OptimizationAlgorithmParameterName, "The algorithm used to solve the expected improvement subproblem", cmaes)); 140 Parameters.Add(new FixedValueParameter<IntValue>(OptimizationRestartsParameterName, "Number of restarts of the SubAlgortihm to avoid local optima", new IntValue(1))); 141 Parameters.Add(new FixedValueParameter<IntValue>(GenerationSizeParameterName, "Number points that are sampled every iteration (stadard EGO: 1)", new IntValue(1))); 134 Parameters.Add(new ValueParameter<Algorithm>(OptimizationAlgorithmParameterName, "The algorithm used to solve the expected improvement subproblem", geneticAlgorithm)); 142 135 Parameters.Add(new FixedValueParameter<IntValue>(MaximalDataSetSizeParameterName, "The maximum number of sample points used to generate the model. Set 0 or less to use always all samples ", new IntValue(-1))); 143 136 Parameters.Add(new FixedValueParameter<BoolValue>(RemoveDuplicatesParamterName, "Wether duplicate samples should be replaced by a single sample with an averaged quality. This GREATLY decreases the chance of ill conditioned models (unbuildable models) but is not theoretically sound as the model ignores the increasing certainty in this region")); 144 var strategies = new ItemSet<ISurrogateStrategy> { new GenerationalStrategy() };145 Parameters.Add(new ConstrainedValueParameter<ISurrogateStrategy>(StrategyParameterName, "The surrogate strategy that dictates how the optimization alg is assisted", strategies ));137 var strategies = new ItemSet<ISurrogateStrategy> { new GenerationalStrategy(), new IndividualStrategy() }; 138 Parameters.Add(new ConstrainedValueParameter<ISurrogateStrategy>(StrategyParameterName, "The surrogate strategy that dictates how the optimization alg is assisted", strategies, strategies.First())); 146 139 RegisterEventhandlers(); 147 140 }
Note: See TracChangeset
for help on using the changeset viewer.