Changeset 17513
- Timestamp:
- 04/20/20 14:40:24 (4 years ago)
- Location:
- branches/2521_ProblemRefactoring
- Files:
-
- 1 added
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2521_ProblemRefactoring/HeuristicLab.Algorithms.DataAnalysis.DecisionTrees/3.4/HeuristicLab.Algorithms.DataAnalysis.DecisionTrees-3.4.csproj
r17084 r17513 78 78 <Compile Include="LeafTypes\ComponentReductionLinearLeaf.cs" /> 79 79 <Compile Include="LeafTypes\ConstantLeaf.cs" /> 80 <Compile Include="LeafTypes\GaussianProcessLeaf.cs" />81 80 <Compile Include="LeafTypes\Leaf.cs" /> 82 81 <Compile Include="LeafTypes\LeafBase.cs" /> -
branches/2521_ProblemRefactoring/HeuristicLab.Algorithms.DataAnalysis/3.4/HeuristicLab.Algorithms.DataAnalysis-3.4.csproj
r17226 r17513 137 137 <Compile Include="GaussianProcess\CovarianceFunctions\CovarianceNeuralNetwork.cs" /> 138 138 <Compile Include="GaussianProcess\CovarianceFunctions\CovariancePolynomial.cs" /> 139 <Compile Include="GaussianProcess\GaussianProcessBase.cs" />140 139 <Compile Include="GaussianProcess\CovarianceFunctions\CovarianceConst.cs"> 141 140 <SubType>Code</SubType> … … 180 179 <Compile Include="GaussianProcess\GaussianProcessClassificationSolutionCreator.cs" /> 181 180 <Compile Include="GaussianProcess\GaussianProcessClassificationModelCreator.cs" /> 182 <Compile Include="GaussianProcess\GaussianProcessClassification.cs" />183 181 <Compile Include="GaussianProcess\MeanFunctions\MeanModel.cs" /> 184 182 <Compile Include="GaussianProcess\MeanFunctions\MeanConst.cs" /> … … 201 199 <Compile Include="GaussianProcess\IMeanFunction.cs" /> 202 200 <Compile Include="GaussianProcess\GaussianProcessModel.cs" /> 203 <Compile Include="GaussianProcess\GaussianProcessRegression.cs" />204 201 <Compile Include="GaussianProcess\GaussianProcessRegressionSolution.cs" /> 205 202 <Compile Include="GaussianProcess\ICovarianceFunction.cs" /> … … 275 272 <Compile Include="Nca\ModelCreation\INcaModelCreator.cs" /> 276 273 <Compile Include="Nca\ModelCreation\NcaModelCreator.cs" /> 277 <Compile Include="Nca\NcaAlgorithm.cs" />278 274 <Compile Include="Nca\NcaClassificationSolution.cs" /> 279 275 <Compile Include="Nca\NcaGradientCalculator.cs" /> -
branches/2521_ProblemRefactoring/HeuristicLab.Algorithms.LocalSearch/3.3/LocalSearchImprovementOperator.cs
r17226 r17513 22 22 using System; 23 23 using System.Linq; 24 using HEAL.Attic; 24 25 using HeuristicLab.Analysis; 25 26 using HeuristicLab.Common; … … 30 31 using HeuristicLab.Optimization.Operators; 31 32 using HeuristicLab.Parameters; 32 using HEAL.Attic;33 33 34 34 namespace HeuristicLab.Algorithms.LocalSearch { … … 41 41 #region IGenericLocalImprovementOperator Properties 42 42 public Type ProblemType { get { return typeof(ISingleObjectiveHeuristicOptimizationProblem); } } 43 public I Problem Problem {43 public IEncodedProblem Problem { 44 44 get { return problem; } 45 45 set { -
branches/2521_ProblemRefactoring/HeuristicLab.Algorithms.ParameterlessPopulationPyramid/3.3/ParameterlessPopulationPyramid.cs
r17382 r17513 235 235 pyramid = new List<Population>(); 236 236 seen.Clear(); 237 random.Reset(Seed); 237 random.Reset(Seed); 238 238 tracker = new EvaluationTracker(Problem, MaximumEvaluations); 239 239 -
branches/2521_ProblemRefactoring/HeuristicLab.Algorithms.SimulatedAnnealing/3.3/SimulatedAnnealingImprovementOperator.cs
r17226 r17513 22 22 using System; 23 23 using System.Linq; 24 using HEAL.Attic; 24 25 using HeuristicLab.Analysis; 25 26 using HeuristicLab.Common; … … 29 30 using HeuristicLab.Optimization; 30 31 using HeuristicLab.Parameters; 31 using HEAL.Attic;32 32 using HeuristicLab.PluginInfrastructure; 33 33 … … 41 41 #region IGenericLocalImprovementOperator Properties 42 42 public Type ProblemType { get { return typeof(ISingleObjectiveHeuristicOptimizationProblem); } } 43 public I Problem Problem {43 public IEncodedProblem Problem { 44 44 get { return problem; } 45 45 set { -
branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/Algorithms/Algorithm.cs
r17226 r17513 26 26 using System.Threading; 27 27 using System.Threading.Tasks; 28 using HEAL.Attic; 28 29 using HeuristicLab.Collections; 29 30 using HeuristicLab.Common; 30 31 using HeuristicLab.Core; 31 32 using HeuristicLab.Data; 32 using HEAL.Attic;33 33 34 34 namespace HeuristicLab.Optimization { … … 301 301 foreach ( 302 302 IStatefulItem statefulObject in 303 this.GetObjectGraphObjects(new HashSet<object>() { Runs}).OfType<IStatefulItem>()) {303 this.GetObjectGraphObjects(new HashSet<object>() { Runs }).OfType<IStatefulItem>()) { 304 304 statefulObject.ClearState(); 305 305 } … … 307 307 try { 308 308 runs.Add(new Run(string.Format("{0} Run {1}", Name, runsCounter), this)); 309 } 310 catch (ArgumentException e) { 309 } catch (ArgumentException e) { 311 310 OnExceptionOccurred(new InvalidOperationException("Run creation failed.", e)); 312 311 } 313 } 314 finally { 312 } finally { 315 313 ExecutionState = ExecutionState.Stopped; 316 314 EventHandler handler = Stopped; … … 325 323 326 324 protected virtual void DeregisterProblemEvents() { 327 problem.OperatorsChanged -= new EventHandler(Problem_OperatorsChanged);328 325 problem.Reset -= new EventHandler(Problem_Reset); 329 326 } 330 327 protected virtual void RegisterProblemEvents() { 331 problem.OperatorsChanged += new EventHandler(Problem_OperatorsChanged);332 328 problem.Reset += new EventHandler(Problem_Reset); 333 329 } 334 protected virtual void Problem_OperatorsChanged(object sender, EventArgs e) { }335 330 protected virtual void Problem_Reset(object sender, EventArgs e) { 336 331 Prepare(); -
branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/Algorithms/EngineAlgorithm.cs
r17226 r17513 22 22 using System; 23 23 using System.Linq; 24 using HEAL.Attic; 24 25 using HeuristicLab.Common; 25 26 using HeuristicLab.Core; 26 using HEAL.Attic;27 27 using HeuristicLab.PluginInfrastructure; 28 28 … … 50 50 } 51 51 52 public new IEncodedProblem Problem { 53 get { return (IEncodedProblem)base.Problem; } 54 set { base.Problem = Problem; } 55 } 56 52 57 [Storable] 53 58 private IScope globalScope; … … 181 186 } 182 187 188 189 183 190 #region Events 191 protected override void DeregisterProblemEvents() { 192 Problem.Reset -= new EventHandler(Problem_Reset); 193 } 194 protected override void RegisterProblemEvents() { 195 Problem.Reset += new EventHandler(Problem_Reset); 196 } 197 protected virtual void Problem_OperatorsChanged(object sender, EventArgs e) { } 198 199 184 200 public event EventHandler EngineChanged; 185 201 protected virtual void OnEngineChanged() { -
branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Interfaces/ISingleObjectiveProblemDefinition.cs
r17383 r17513 43 43 void Evaluate(ISingleObjectiveSolutionContext<TEncodedSolution> solutionContext, IRandom random, CancellationToken cancellationToken); 44 44 45 //TODO add cancellationtoken? 45 46 void Analyze(ISingleObjectiveSolutionContext<TEncodedSolution>[] solutionContexts, ResultCollection results, IRandom random); 46 47 48 //TODO remove neighbors from ProblemDefinition? 47 49 IEnumerable<TEncodedSolution> GetNeighbors(TEncodedSolution solution, IRandom random); 48 50 IEnumerable<ISingleObjectiveSolutionContext<TEncodedSolution>> GetNeighbors(ISingleObjectiveSolutionContext<TEncodedSolution> solutionContext, IRandom random); -
branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Problem.cs
r17334 r17513 31 31 namespace HeuristicLab.Optimization { 32 32 [StorableType("D877082E-9E77-4CB1-ABDB-35F63878E116")] 33 public abstract class Problem<TEncoding, TEncodedSolution, TEvaluator> : Problem,33 public abstract class Problem<TEncoding, TEncodedSolution, TEvaluator> : EncodedProblem, 34 34 IHeuristicOptimizationProblem, IProblemDefinition<TEncoding, TEncodedSolution>, IStorableContent 35 35 where TEncoding : class, IEncoding<TEncodedSolution> 36 36 where TEncodedSolution : class, IEncodedSolution 37 37 where TEvaluator : class, IEvaluator { 38 38 39 39 40 40 //TODO remove parameter for encoding? … … 97 97 get { 98 98 if (Encoding == null) return base.ExecutionContextItems; 99 return base.ExecutionContextItems.Concat(new[] { Encoding});99 return base.ExecutionContextItems.Concat(new[] { Encoding }); 100 100 } 101 101 } … … 105 105 Parameters.Add(new ValueParameter<TEncoding>("Encoding", "Describes the configuration of the encoding, what the variables are called, what type they are and their bounds if any.") { Hidden = true }); 106 106 Parameters.Add(new ValueParameter<TEvaluator>("Evaluator", "The operator used to evaluate a solution.") { Hidden = true }); 107 107 108 108 if (Encoding != null) { 109 109 oldEncoding = Encoding; … … 180 180 if (!oldMultiEncoding.Encodings.SequenceEqual(newMultiEncoding.Encodings, new TypeEqualityComparer<IEncoding>())) return; 181 181 182 var nestedEncodings = oldMultiEncoding.Encodings.Zip(newMultiEncoding.Encodings, (o, n) => new { oldEnc = o, newEnc = n});182 var nestedEncodings = oldMultiEncoding.Encodings.Zip(newMultiEncoding.Encodings, (o, n) => new { oldEnc = o, newEnc = n }); 183 183 foreach (var multi in nestedEncodings) 184 184 AdaptEncodingOperators(multi.oldEnc, multi.newEnc); -
branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/HeuristicLab.Optimization-3.3.csproj
r17363 r17513 259 259 <Compile Include="Interfaces\IEvaluator.cs" /> 260 260 <Compile Include="Interfaces\IManipulator.cs" /> 261 <Compile Include=" Interfaces\IProblem.cs" />261 <Compile Include="BasicProblems\Interfaces\IProblem.cs" /> 262 262 <Compile Include="Interfaces\ISingleObjectiveEvaluator.cs" /> 263 263 <Compile Include="Interfaces\ISolutionCreator.cs" /> -
branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/Interfaces/IHeuristicOptimizationProblem.cs
r17226 r17513 21 21 22 22 using System; 23 using HEAL.Attic; 23 24 using HeuristicLab.Core; 24 using HEAL.Attic;25 25 26 26 namespace HeuristicLab.Optimization { … … 29 29 /// Interface to represent a heuristic optimization problem. 30 30 /// </summary> 31 public interface IHeuristicOptimizationProblem : I Problem {31 public interface IHeuristicOptimizationProblem : IEncodedProblem { 32 32 IParameter SolutionCreatorParameter { get; } 33 33 ISolutionCreator SolutionCreator { get; } -
branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/Interfaces/ILocalImprovementAlgorithmOperator.cs
r17226 r17513 27 27 public interface ILocalImprovementAlgorithmOperator : ILocalImprovementOperator { 28 28 Type ProblemType { get; } 29 I Problem Problem { get; set; }29 IEncodedProblem Problem { get; set; } 30 30 } 31 31 } -
branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/Problems/HeuristicOptimizationProblem.cs
r17226 r17513 21 21 22 22 using System; 23 using HEAL.Attic; 23 24 using HeuristicLab.Common; 24 25 using HeuristicLab.Core; 25 26 using HeuristicLab.Parameters; 26 using HEAL.Attic;27 27 28 28 namespace HeuristicLab.Optimization { 29 29 [Item("Heuristic Optimization Problem", "Represents the base class for a heuristic optimization problem.")] 30 30 [StorableType("DE0478BA-3797-4AC3-9A89-3734D2643823")] 31 public abstract class HeuristicOptimizationProblem<T, U> : Problem, IHeuristicOptimizationProblem32 where T : class, IEvaluator33 where U : class, ISolutionCreator {31 public abstract class HeuristicOptimizationProblem<T, U> : EncodedProblem, IHeuristicOptimizationProblem 32 where T : class, IEvaluator 33 where U : class, ISolutionCreator { 34 34 private const string EvaluatorParameterName = "Evaluator"; 35 35 private const string SolutionCreateParameterName = "SolutionCreator"; -
branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/Problems/Problem.cs
r17334 r17513 31 31 32 32 namespace HeuristicLab.Optimization { 33 [StorableType("C213CE21-A970-4886-BC4C-9790B9897738")] 34 public abstract class Problem : ParameterizedNamedItem, IProblem { 35 public string Filename { get; set; } 36 37 public static new Image StaticItemImage { 38 get { return HeuristicLab.Common.Resources.VSImageLibrary.Type; } 39 } 40 41 42 43 [StorableConstructor] 44 protected Problem(StorableConstructorFlag _) : base(_) { } 45 protected Problem(Problem original, Cloner cloner) : base(original, cloner) { } 46 public Problem() : base() { } 47 48 protected override IEnumerable<KeyValuePair<string, IItem>> GetCollectedValues(IValueParameter param) { 49 var children = base.GetCollectedValues(param); 50 foreach (var child in children) { 51 if (child.Value is IOperator) 52 yield return new KeyValuePair<string, IItem>(child.Key, new StringValue(((IOperator)child.Value).Name)); 53 else yield return child; 54 } 55 } 56 57 public event EventHandler Reset; 58 protected virtual void OnReset() { 59 EventHandler handler = Reset; 60 if (handler != null) 61 handler(this, EventArgs.Empty); 62 } 63 } 64 65 66 33 67 [Item("Problem", "Represents the base class for a problem.")] 34 68 [StorableType("6DC97432-9BD1-4304-802A-1FC48A0E0468")] 35 public abstract class Problem : ParameterizedNamedItem, IProblem { 36 public string Filename { get; set; } 69 public abstract class EncodedProblem : Problem, IEncodedProblem { 37 70 38 71 private const string OperatorsParameterName = "Operators"; … … 41 74 } 42 75 43 public static new Image StaticItemImage {44 get { return HeuristicLab.Common.Resources.VSImageLibrary.Type; }45 }46 47 76 [StorableConstructor] 48 protected Problem(StorableConstructorFlag _) : base(_) { }49 protected Problem(Problem original, Cloner cloner)77 protected EncodedProblem(StorableConstructorFlag _) : base(_) { } 78 protected EncodedProblem(EncodedProblem original, Cloner cloner) 50 79 : base(original, cloner) { 51 80 RegisterEventHandlers(); 52 81 } 53 82 54 protected Problem()83 protected EncodedProblem() 55 84 : base() { 56 85 Parameters.Add(new FixedValueParameter<ItemCollection<IItem>>(OperatorsParameterName, "The operators and items that the problem provides to the algorithms.", new ItemCollection<IItem>()) { GetsCollected = false }); … … 116 145 } 117 146 } 118 IEnumerable<IItem> I Problem.Operators { get { return GetOperators(); } }147 IEnumerable<IItem> IEncodedProblem.Operators { get { return GetOperators(); } } 119 148 120 149 protected virtual IEnumerable<IItem> GetOperators() { … … 127 156 #endregion 128 157 129 protected override IEnumerable<KeyValuePair<string, IItem>> GetCollectedValues(IValueParameter param) { 130 var children = base.GetCollectedValues(param); 131 foreach (var child in children) { 132 if (child.Value is IOperator) 133 yield return new KeyValuePair<string, IItem>(child.Key, new StringValue(((IOperator)child.Value).Name)); 134 else yield return child; 135 } 136 } 158 137 159 138 160 #region events … … 146 168 handler(this, EventArgs.Empty); 147 169 } 148 149 public event EventHandler Reset;150 protected virtual void OnReset() {151 EventHandler handler = Reset;152 if (handler != null)153 handler(this, EventArgs.Empty);154 }155 170 #endregion 156 171 } -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.QuadraticAssignment.Algorithms/3.3/RobustTabooSearch.cs
r17226 r17513 385 385 AnalyzerParameter.Value.Operators.Clear(); 386 386 if (Problem != null) { 387 foreach (IAnalyzer analyzer in ((I Problem)Problem).Operators.OfType<IAnalyzer>()) {387 foreach (IAnalyzer analyzer in ((IEncodedProblem)Problem).Operators.OfType<IAnalyzer>()) { 388 388 AnalyzerParameter.Value.Operators.Add(analyzer, analyzer.EnabledByDefault); 389 389 if (!(analyzer is BestQAPSolutionAnalyzer)) -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.VehicleRouting/3.4/VehicleRoutingProblem.cs
r17226 r17513 24 24 using System.Drawing; 25 25 using System.Linq; 26 using HEAL.Attic; 26 27 using HeuristicLab.Analysis; 27 28 using HeuristicLab.Common; … … 31 32 using HeuristicLab.Optimization.Operators; 32 33 using HeuristicLab.Parameters; 33 using HEAL.Attic;34 34 using HeuristicLab.PluginInfrastructure; 35 35 using HeuristicLab.Problems.Instances; … … 44 44 [Creatable(CreatableAttribute.Categories.CombinatorialProblems, Priority = 110)] 45 45 [StorableType("95137523-AE3B-4638-958C-E86829D54CE3")] 46 public sealed class VehicleRoutingProblem : Problem, ISingleObjectiveHeuristicOptimizationProblem, IStorableContent, IProblemInstanceConsumer<IVRPData> {46 public sealed class VehicleRoutingProblem : EncodedProblem, ISingleObjectiveHeuristicOptimizationProblem, IStorableContent, IProblemInstanceConsumer<IVRPData> { 47 47 public string Filename { get; set; } 48 48
Note: See TracChangeset
for help on using the changeset viewer.