Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/13/15 18:47:19 (10 years ago)
Author:
mkommend
Message:

#2174: First working version of refactored programmable problem.

Location:
branches/ProgrammableProblem/HeuristicLab.Problems.Programmable/3.3/Encodings
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/ProgrammableProblem/HeuristicLab.Problems.Programmable/3.3/Encodings/Encoding.cs

    r11737 r11753  
    3838
    3939    protected HashSet<IOperator> encodingOperators = new HashSet<IOperator>(new TypeEqualityComparer<IOperator>());
    40     [Storable]
     40
     41    [Storable(Name = "Operators")]
     42    private IEnumerable<IOperator> StorableOperators {
     43      get { return encodingOperators; }
     44      set { encodingOperators = new HashSet<IOperator>(value, new TypeEqualityComparer<IOperator>()); ; }
     45    }
     46
    4147    public IEnumerable<IOperator> Operators {
    4248      get { return encodingOperators; }
    43       private set { encodingOperators = new HashSet<IOperator>(value, new TypeEqualityComparer<IOperator>()); }
     49      set {
     50        if (!value.OfType<T>().Any())
     51          throw new ArgumentException("The provided operators contain no suitable solution creator");
     52        encodingOperators = new HashSet<IOperator>(value, new TypeEqualityComparer<IOperator>());
     53
     54        T newSolutionCreator = (T)encodingOperators.FirstOrDefault(o => o.GetType() == solutionCreator.GetType());
     55        if (newSolutionCreator == null) newSolutionCreator = encodingOperators.OfType<T>().First();
     56        SolutionCreator = newSolutionCreator;
     57        OnOperatorsChanged();
     58      }
    4459    }
    4560
     
    90105      if (handler != null) handler(this, EventArgs.Empty);
    91106    }
     107
     108    public event EventHandler OperatorsChanged;
     109    protected virtual void OnOperatorsChanged() {
     110      ConfigureOperators(Operators);
     111      var handler = OperatorsChanged;
     112      if (handler != null) handler(this, EventArgs.Empty);
     113    }
    92114  }
    93115}
  • branches/ProgrammableProblem/HeuristicLab.Problems.Programmable/3.3/Encodings/IntegerEncoding.cs

    r11746 r11753  
    174174    }
    175175    private void DiscoverOperators() {
    176       var discoveredTypes = ApplicationManager.Manager.GetTypes(encodingSpecificOperatorTypes, true, false, false);
     176      var pluginDescription = ApplicationManager.Manager.GetDeclaringPlugin(typeof(IIntegerVectorOperator));
     177      var discoveredTypes = ApplicationManager.Manager.GetTypes(encodingSpecificOperatorTypes, pluginDescription, true, false, false);
    177178      var operators = discoveredTypes.Select(t => (IOperator)Activator.CreateInstance(t));
    178179      var newOperators = operators.Except(Operators, new TypeEqualityComparer<IOperator>()).ToList();
  • branches/ProgrammableProblem/HeuristicLab.Problems.Programmable/3.3/Encodings/MultiEncoding.cs

    r11619 r11753  
    8989
    9090    public override void ConfigureOperators(IEnumerable<IOperator> operators) {
    91 
    9291    }
    9392  }
  • branches/ProgrammableProblem/HeuristicLab.Problems.Programmable/3.3/Encodings/PermutationEncoding.cs

    r11746 r11753  
    148148    }
    149149    private void DiscoverOperators() {
    150       var discoveredTypes = ApplicationManager.Manager.GetTypes(encodingSpecificOperatorTypes, true, false, false);
     150      var pluginDescription = ApplicationManager.Manager.GetDeclaringPlugin(typeof(IPermutationOperator));
     151      var discoveredTypes = ApplicationManager.Manager.GetTypes(encodingSpecificOperatorTypes, pluginDescription, true, false, false);
    151152      var operators = discoveredTypes.Select(t => (IOperator)Activator.CreateInstance(t));
    152153      var newOperators = operators.Except(Operators, new TypeEqualityComparer<IOperator>()).ToList();
  • branches/ProgrammableProblem/HeuristicLab.Problems.Programmable/3.3/Encodings/RealEncoding.cs

    r11739 r11753  
    173173    }
    174174    private void DiscoverOperators() {
    175       var discoveredTypes = ApplicationManager.Manager.GetTypes(encodingSpecificOperatorTypes, true, false, false);
     175      var pluginDescription = ApplicationManager.Manager.GetDeclaringPlugin(typeof(IRealVectorOperator));
     176      var discoveredTypes = ApplicationManager.Manager.GetTypes(encodingSpecificOperatorTypes, pluginDescription, true, false, false);
    176177      var operators = discoveredTypes.Select(t => (IOperator)Activator.CreateInstance(t));
    177178      var newOperators = operators.Except(Operators, new TypeEqualityComparer<IOperator>()).ToList();
Note: See TracChangeset for help on using the changeset viewer.