Free cookie consent management tool by TermsFeed Policy Generator

Changeset 17513


Ignore:
Timestamp:
04/20/20 14:40:24 (4 years ago)
Author:
mkommend
Message:

#2521: Splitted problems into several problem and encoded problems.

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  
    7878    <Compile Include="LeafTypes\ComponentReductionLinearLeaf.cs" />
    7979    <Compile Include="LeafTypes\ConstantLeaf.cs" />
    80     <Compile Include="LeafTypes\GaussianProcessLeaf.cs" />
    8180    <Compile Include="LeafTypes\Leaf.cs" />
    8281    <Compile Include="LeafTypes\LeafBase.cs" />
  • branches/2521_ProblemRefactoring/HeuristicLab.Algorithms.DataAnalysis/3.4/HeuristicLab.Algorithms.DataAnalysis-3.4.csproj

    r17226 r17513  
    137137    <Compile Include="GaussianProcess\CovarianceFunctions\CovarianceNeuralNetwork.cs" />
    138138    <Compile Include="GaussianProcess\CovarianceFunctions\CovariancePolynomial.cs" />
    139     <Compile Include="GaussianProcess\GaussianProcessBase.cs" />
    140139    <Compile Include="GaussianProcess\CovarianceFunctions\CovarianceConst.cs">
    141140      <SubType>Code</SubType>
     
    180179    <Compile Include="GaussianProcess\GaussianProcessClassificationSolutionCreator.cs" />
    181180    <Compile Include="GaussianProcess\GaussianProcessClassificationModelCreator.cs" />
    182     <Compile Include="GaussianProcess\GaussianProcessClassification.cs" />
    183181    <Compile Include="GaussianProcess\MeanFunctions\MeanModel.cs" />
    184182    <Compile Include="GaussianProcess\MeanFunctions\MeanConst.cs" />
     
    201199    <Compile Include="GaussianProcess\IMeanFunction.cs" />
    202200    <Compile Include="GaussianProcess\GaussianProcessModel.cs" />
    203     <Compile Include="GaussianProcess\GaussianProcessRegression.cs" />
    204201    <Compile Include="GaussianProcess\GaussianProcessRegressionSolution.cs" />
    205202    <Compile Include="GaussianProcess\ICovarianceFunction.cs" />
     
    275272    <Compile Include="Nca\ModelCreation\INcaModelCreator.cs" />
    276273    <Compile Include="Nca\ModelCreation\NcaModelCreator.cs" />
    277     <Compile Include="Nca\NcaAlgorithm.cs" />
    278274    <Compile Include="Nca\NcaClassificationSolution.cs" />
    279275    <Compile Include="Nca\NcaGradientCalculator.cs" />
  • branches/2521_ProblemRefactoring/HeuristicLab.Algorithms.LocalSearch/3.3/LocalSearchImprovementOperator.cs

    r17226 r17513  
    2222using System;
    2323using System.Linq;
     24using HEAL.Attic;
    2425using HeuristicLab.Analysis;
    2526using HeuristicLab.Common;
     
    3031using HeuristicLab.Optimization.Operators;
    3132using HeuristicLab.Parameters;
    32 using HEAL.Attic;
    3333
    3434namespace HeuristicLab.Algorithms.LocalSearch {
     
    4141    #region IGenericLocalImprovementOperator Properties
    4242    public Type ProblemType { get { return typeof(ISingleObjectiveHeuristicOptimizationProblem); } }
    43     public IProblem Problem {
     43    public IEncodedProblem Problem {
    4444      get { return problem; }
    4545      set {
  • branches/2521_ProblemRefactoring/HeuristicLab.Algorithms.ParameterlessPopulationPyramid/3.3/ParameterlessPopulationPyramid.cs

    r17382 r17513  
    235235      pyramid = new List<Population>();
    236236      seen.Clear();
    237       random.Reset(Seed);
     237      random.Reset(Seed);                                                         
    238238      tracker = new EvaluationTracker(Problem, MaximumEvaluations);
    239239
  • branches/2521_ProblemRefactoring/HeuristicLab.Algorithms.SimulatedAnnealing/3.3/SimulatedAnnealingImprovementOperator.cs

    r17226 r17513  
    2222using System;
    2323using System.Linq;
     24using HEAL.Attic;
    2425using HeuristicLab.Analysis;
    2526using HeuristicLab.Common;
     
    2930using HeuristicLab.Optimization;
    3031using HeuristicLab.Parameters;
    31 using HEAL.Attic;
    3232using HeuristicLab.PluginInfrastructure;
    3333
     
    4141    #region IGenericLocalImprovementOperator Properties
    4242    public Type ProblemType { get { return typeof(ISingleObjectiveHeuristicOptimizationProblem); } }
    43     public IProblem Problem {
     43    public IEncodedProblem Problem {
    4444      get { return problem; }
    4545      set {
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/Algorithms/Algorithm.cs

    r17226 r17513  
    2626using System.Threading;
    2727using System.Threading.Tasks;
     28using HEAL.Attic;
    2829using HeuristicLab.Collections;
    2930using HeuristicLab.Common;
    3031using HeuristicLab.Core;
    3132using HeuristicLab.Data;
    32 using HEAL.Attic;
    3333
    3434namespace HeuristicLab.Optimization {
     
    301301        foreach (
    302302          IStatefulItem statefulObject in
    303           this.GetObjectGraphObjects(new HashSet<object>() {Runs}).OfType<IStatefulItem>()) {
     303          this.GetObjectGraphObjects(new HashSet<object>() { Runs }).OfType<IStatefulItem>()) {
    304304          statefulObject.ClearState();
    305305        }
     
    307307        try {
    308308          runs.Add(new Run(string.Format("{0} Run {1}", Name, runsCounter), this));
    309         }
    310         catch (ArgumentException e) {
     309        } catch (ArgumentException e) {
    311310          OnExceptionOccurred(new InvalidOperationException("Run creation failed.", e));
    312311        }
    313       }   
    314       finally {
     312      } finally {
    315313        ExecutionState = ExecutionState.Stopped;
    316314        EventHandler handler = Stopped;
     
    325323
    326324    protected virtual void DeregisterProblemEvents() {
    327       problem.OperatorsChanged -= new EventHandler(Problem_OperatorsChanged);
    328325      problem.Reset -= new EventHandler(Problem_Reset);
    329326    }
    330327    protected virtual void RegisterProblemEvents() {
    331       problem.OperatorsChanged += new EventHandler(Problem_OperatorsChanged);
    332328      problem.Reset += new EventHandler(Problem_Reset);
    333329    }
    334     protected virtual void Problem_OperatorsChanged(object sender, EventArgs e) { }
    335330    protected virtual void Problem_Reset(object sender, EventArgs e) {
    336331      Prepare();
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/Algorithms/EngineAlgorithm.cs

    r17226 r17513  
    2222using System;
    2323using System.Linq;
     24using HEAL.Attic;
    2425using HeuristicLab.Common;
    2526using HeuristicLab.Core;
    26 using HEAL.Attic;
    2727using HeuristicLab.PluginInfrastructure;
    2828
     
    5050    }
    5151
     52    public new IEncodedProblem Problem {
     53      get { return (IEncodedProblem)base.Problem; }
     54      set { base.Problem = Problem; }
     55    }
     56
    5257    [Storable]
    5358    private IScope globalScope;
     
    181186    }
    182187
     188
     189
    183190    #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
    184200    public event EventHandler EngineChanged;
    185201    protected virtual void OnEngineChanged() {
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Interfaces/ISingleObjectiveProblemDefinition.cs

    r17383 r17513  
    4343    void Evaluate(ISingleObjectiveSolutionContext<TEncodedSolution> solutionContext, IRandom random, CancellationToken cancellationToken);
    4444
     45    //TODO add cancellationtoken?
    4546    void Analyze(ISingleObjectiveSolutionContext<TEncodedSolution>[] solutionContexts, ResultCollection results, IRandom random);
    4647
     48    //TODO remove neighbors from ProblemDefinition?
    4749    IEnumerable<TEncodedSolution> GetNeighbors(TEncodedSolution solution, IRandom random);
    4850    IEnumerable<ISingleObjectiveSolutionContext<TEncodedSolution>> GetNeighbors(ISingleObjectiveSolutionContext<TEncodedSolution> solutionContext, IRandom random);
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Problem.cs

    r17334 r17513  
    3131namespace HeuristicLab.Optimization {
    3232  [StorableType("D877082E-9E77-4CB1-ABDB-35F63878E116")]
    33   public abstract class Problem<TEncoding, TEncodedSolution, TEvaluator> : Problem,
     33  public abstract class Problem<TEncoding, TEncodedSolution, TEvaluator> : EncodedProblem,
    3434    IHeuristicOptimizationProblem, IProblemDefinition<TEncoding, TEncodedSolution>, IStorableContent
    3535    where TEncoding : class, IEncoding<TEncodedSolution>
    3636    where TEncodedSolution : class, IEncodedSolution
    3737    where TEvaluator : class, IEvaluator {
    38    
     38
    3939
    4040    //TODO remove parameter for encoding?
     
    9797      get {
    9898        if (Encoding == null) return base.ExecutionContextItems;
    99         return base.ExecutionContextItems.Concat(new[] {Encoding});
     99        return base.ExecutionContextItems.Concat(new[] { Encoding });
    100100      }
    101101    }
     
    105105      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 });
    106106      Parameters.Add(new ValueParameter<TEvaluator>("Evaluator", "The operator used to evaluate a solution.") { Hidden = true });
    107      
     107
    108108      if (Encoding != null) {
    109109        oldEncoding = Encoding;
     
    180180        if (!oldMultiEncoding.Encodings.SequenceEqual(newMultiEncoding.Encodings, new TypeEqualityComparer<IEncoding>())) return;
    181181
    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 });
    183183        foreach (var multi in nestedEncodings)
    184184          AdaptEncodingOperators(multi.oldEnc, multi.newEnc);
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/HeuristicLab.Optimization-3.3.csproj

    r17363 r17513  
    259259    <Compile Include="Interfaces\IEvaluator.cs" />
    260260    <Compile Include="Interfaces\IManipulator.cs" />
    261     <Compile Include="Interfaces\IProblem.cs" />
     261    <Compile Include="BasicProblems\Interfaces\IProblem.cs" />
    262262    <Compile Include="Interfaces\ISingleObjectiveEvaluator.cs" />
    263263    <Compile Include="Interfaces\ISolutionCreator.cs" />
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/Interfaces/IHeuristicOptimizationProblem.cs

    r17226 r17513  
    2121
    2222using System;
     23using HEAL.Attic;
    2324using HeuristicLab.Core;
    24 using HEAL.Attic;
    2525
    2626namespace HeuristicLab.Optimization {
     
    2929  /// Interface to represent a heuristic optimization problem.
    3030  /// </summary>
    31   public interface IHeuristicOptimizationProblem : IProblem {
     31  public interface IHeuristicOptimizationProblem : IEncodedProblem {
    3232    IParameter SolutionCreatorParameter { get; }
    3333    ISolutionCreator SolutionCreator { get; }
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/Interfaces/ILocalImprovementAlgorithmOperator.cs

    r17226 r17513  
    2727  public interface ILocalImprovementAlgorithmOperator : ILocalImprovementOperator {
    2828    Type ProblemType { get; }
    29     IProblem Problem { get; set; }
     29    IEncodedProblem Problem { get; set; }
    3030  }
    3131}
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/Problems/HeuristicOptimizationProblem.cs

    r17226 r17513  
    2121
    2222using System;
     23using HEAL.Attic;
    2324using HeuristicLab.Common;
    2425using HeuristicLab.Core;
    2526using HeuristicLab.Parameters;
    26 using HEAL.Attic;
    2727
    2828namespace HeuristicLab.Optimization {
    2929  [Item("Heuristic Optimization Problem", "Represents the base class for a heuristic optimization problem.")]
    3030  [StorableType("DE0478BA-3797-4AC3-9A89-3734D2643823")]
    31   public abstract class HeuristicOptimizationProblem<T, U> : Problem, IHeuristicOptimizationProblem
    32     where T : class,IEvaluator
    33     where U : class,ISolutionCreator {
     31  public abstract class HeuristicOptimizationProblem<T, U> : EncodedProblem, IHeuristicOptimizationProblem
     32    where T : class, IEvaluator
     33    where U : class, ISolutionCreator {
    3434    private const string EvaluatorParameterName = "Evaluator";
    3535    private const string SolutionCreateParameterName = "SolutionCreator";
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/Problems/Problem.cs

    r17334 r17513  
    3131
    3232namespace 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
    3367  [Item("Problem", "Represents the base class for a problem.")]
    3468  [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 {
    3770
    3871    private const string OperatorsParameterName = "Operators";
     
    4174    }
    4275
    43     public static new Image StaticItemImage {
    44       get { return HeuristicLab.Common.Resources.VSImageLibrary.Type; }
    45     }
    46 
    4776    [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)
    5079      : base(original, cloner) {
    5180      RegisterEventHandlers();
    5281    }
    5382
    54     protected Problem()
     83    protected EncodedProblem()
    5584      : base() {
    5685      Parameters.Add(new FixedValueParameter<ItemCollection<IItem>>(OperatorsParameterName, "The operators and items that the problem provides to the algorithms.", new ItemCollection<IItem>()) { GetsCollected = false });
     
    116145      }
    117146    }
    118     IEnumerable<IItem> IProblem.Operators { get { return GetOperators(); } }
     147    IEnumerable<IItem> IEncodedProblem.Operators { get { return GetOperators(); } }
    119148
    120149    protected virtual IEnumerable<IItem> GetOperators() {
     
    127156    #endregion
    128157
    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
    137159
    138160    #region events
     
    146168        handler(this, EventArgs.Empty);
    147169    }
    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     }
    155170    #endregion
    156171  }
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.QuadraticAssignment.Algorithms/3.3/RobustTabooSearch.cs

    r17226 r17513  
    385385      AnalyzerParameter.Value.Operators.Clear();
    386386      if (Problem != null) {
    387         foreach (IAnalyzer analyzer in ((IProblem)Problem).Operators.OfType<IAnalyzer>()) {
     387        foreach (IAnalyzer analyzer in ((IEncodedProblem)Problem).Operators.OfType<IAnalyzer>()) {
    388388          AnalyzerParameter.Value.Operators.Add(analyzer, analyzer.EnabledByDefault);
    389389          if (!(analyzer is BestQAPSolutionAnalyzer))
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.VehicleRouting/3.4/VehicleRoutingProblem.cs

    r17226 r17513  
    2424using System.Drawing;
    2525using System.Linq;
     26using HEAL.Attic;
    2627using HeuristicLab.Analysis;
    2728using HeuristicLab.Common;
     
    3132using HeuristicLab.Optimization.Operators;
    3233using HeuristicLab.Parameters;
    33 using HEAL.Attic;
    3434using HeuristicLab.PluginInfrastructure;
    3535using HeuristicLab.Problems.Instances;
     
    4444  [Creatable(CreatableAttribute.Categories.CombinatorialProblems, Priority = 110)]
    4545  [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> {
    4747    public string Filename { get; set; }
    4848
Note: See TracChangeset for help on using the changeset viewer.