Free cookie consent management tool by TermsFeed Policy Generator

Changeset 8853


Ignore:
Timestamp:
10/29/12 14:30:35 (12 years ago)
Author:
sforsten
Message:

#1865: An additional property has been added, which contains all possible variable names. The old property "VariableNames" contains the variable names which can be used with a certain symbol (which are checked in the view).
The "AfterDeserialization" method makes sure that the new property is set.

Location:
trunk/sources
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/Symbols/VariableConditionView.cs

    r8103 r8853  
    124124        RegisterVariableNamesViewContentEvents();
    125125      } else {
    126         var existingEntries = variableNamesView.Content.ToList();
    127 
    128126        // temporarily deregister to prevent circular calling of events
    129127        DeregisterVariableNamesViewContentEvents();
    130         // add additional entries
    131         foreach (var variableName in Content.VariableNames.Except(existingEntries.Select(x => x.Value)))
    132           variableNamesView.Content.Add(new StringValue(variableName), true);
    133         foreach (var oldEntry in existingEntries.Where(x => !Content.VariableNames.Contains(x.Value)))
    134           variableNamesView.Content.Remove(oldEntry);
     128        variableNamesView.Content.Clear();
     129        foreach (var variableName in Content.AllVariableNames) {
     130          variableNamesView.Content.Add(new StringValue(variableName), Content.VariableNames.Contains(variableName));
     131        }
    135132        RegisterVariableNamesViewContentEvents();
    136133
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/Symbols/VariableView.cs

    r8476 r8853  
    181181        RegisterVariableNamesViewContentEvents();
    182182      } else {
    183         var existingEntries = variableNamesView.Content.ToList();
    184 
    185183        // temporarily deregister to prevent circular calling of events
    186184        DeregisterVariableNamesViewContentEvents();
    187         // add additional entries
    188         foreach (var variableName in Content.VariableNames.Except(existingEntries.Select(x => x.Value)))
    189           variableNamesView.Content.Add(new StringValue(variableName), true);
    190         foreach (var oldEntry in existingEntries.Where(x => !Content.VariableNames.Contains(x.Value)))
    191           variableNamesView.Content.Remove(oldEntry);
     185        variableNamesView.Content.Clear();
     186        foreach (var variableName in Content.AllVariableNames) {
     187          variableNamesView.Content.Add(new StringValue(variableName), Content.VariableNames.Contains(variableName));
     188        }
    192189        RegisterVariableNamesViewContentEvents();
    193190
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisProblem.cs

    r8666 r8853  
    211211      SymbolicExpressionTreeGrammar.MaximumFunctionDefinitions = MaximumFunctionDefinitions.Value;
    212212      foreach (var varSymbol in SymbolicExpressionTreeGrammar.Symbols.OfType<HeuristicLab.Problems.DataAnalysis.Symbolic.Variable>()) {
    213         if (!varSymbol.Fixed) varSymbol.VariableNames = ProblemData.AllowedInputVariables;
     213        if (!varSymbol.Fixed) varSymbol.AllVariableNames = ProblemData.AllowedInputVariables;
    214214      }
    215215      foreach (var varSymbol in SymbolicExpressionTreeGrammar.Symbols.OfType<HeuristicLab.Problems.DataAnalysis.Symbolic.VariableCondition>()) {
    216         if (!varSymbol.Fixed) varSymbol.VariableNames = ProblemData.AllowedInputVariables;
     216        if (!varSymbol.Fixed) varSymbol.AllVariableNames = ProblemData.AllowedInputVariables;
    217217      }
    218218    }
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Variable.cs

    r8798 r8853  
    101101    }
    102102
     103    private List<string> allVariableNames;
     104    [Storable]
     105    public IEnumerable<string> AllVariableNames {
     106      get { return allVariableNames; }
     107      set {
     108        if (value == null) throw new ArgumentNullException();
     109        allVariableNames.Clear();
     110        allVariableNames.AddRange(value);
     111        VariableNames = value;
     112      }
     113    }
     114
    103115    public override bool Enabled {
    104116      get {
     
    123135    #endregion
    124136
     137    [StorableHook(HookType.AfterDeserialization)]
     138    private void AfterDeserialization() {
     139      if (allVariableNames == null || (allVariableNames.Count == 0 && variableNames.Count > 0)) {
     140        allVariableNames = variableNames;
     141      }
     142    }
     143
    125144    [StorableConstructor]
    126145    protected Variable(bool deserializing)
    127146      : base(deserializing) {
    128147      variableNames = new List<string>();
     148      allVariableNames = new List<string>();
    129149    }
    130150    protected Variable(Variable original, Cloner cloner)
     
    133153      weightSigma = original.weightSigma;
    134154      variableNames = new List<string>(original.variableNames);
     155      allVariableNames = new List<string>(original.allVariableNames);
    135156      weightManipulatorMu = original.weightManipulatorMu;
    136157      weightManipulatorSigma = original.weightManipulatorSigma;
     
    146167      multiplicativeWeightManipulatorSigma = 0.03;
    147168      variableNames = new List<string>();
     169      allVariableNames = new List<string>();
    148170    }
    149171
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/VariableCondition.cs

    r8099 r8853  
    9191    }
    9292
     93    private List<string> allVariableNames;
     94    [Storable]
     95    public IEnumerable<string> AllVariableNames {
     96      get { return allVariableNames; }
     97      set {
     98        if (value == null) throw new ArgumentNullException();
     99        allVariableNames.Clear();
     100        allVariableNames.AddRange(value);
     101        VariableNames = value;
     102      }
     103    }
     104
    93105    [Storable]
    94106    private double slopeInitializerMu;
     
    151163
    152164    #region persistence and cloning
     165    [StorableHook(HookType.AfterDeserialization)]
     166    private void AfterDeserialization() {
     167      if (allVariableNames == null || (allVariableNames.Count == 0 && variableNames.Count > 0)) {
     168        allVariableNames = variableNames;
     169      }
     170    }
     171
    153172    [StorableConstructor]
    154173    private VariableCondition(bool deserializing) : base(deserializing) { }
     
    161180
    162181      variableNames = new List<string>(original.variableNames);
     182      allVariableNames = new List<string>(original.allVariableNames);
    163183
    164184      slopeInitializerMu = original.slopeInitializerMu;
     
    181201
    182202      variableNames = new List<string>();
     203      allVariableNames = new List<string>();
    183204
    184205      slopeInitializerMu = 0.0;
Note: See TracChangeset for help on using the changeset viewer.