Changeset 3687


Ignore:
Timestamp:
05/06/10 23:34:36 (12 years ago)
Author:
swagner
Message:

Worked on refactoring of algorithm analysis and tracing (#999)

  • fixed naming issues in DataTableValuesCollector, ResultsCollector and VariableCreator
Location:
trunk/sources
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Analysis/3.3/DataTableValuesCollector.cs

    r3637 r3687  
    5353
    5454      foreach (IParameter param in CollectedValues) {
     55        ILookupParameter lookupParam = param as ILookupParameter;
     56        string name = lookupParam != null ? lookupParam.TranslatedName : param.Name;
     57
    5558        if (param.ActualValue is DoubleValue) {
    56           AddValue(table, (param.ActualValue as DoubleValue).Value, param.Name, param.Description);
     59          AddValue(table, (param.ActualValue as DoubleValue).Value, name, param.Description);
    5760        } else if (param.ActualValue is IEnumerable<DoubleValue>) {
    5861          int counter = 0;
    5962          foreach (DoubleValue data in (param.ActualValue as IEnumerable<DoubleValue>)) {
    60             AddValue(table, data.Value, param.Name + " " + counter.ToString(), param.Description);
     63            AddValue(table, data.Value, name + " " + counter.ToString(), param.Description);
    6164            counter++;
    6265          }
    6366        } else {
    64           AddValue(table, double.NaN, param.Name, param.Description);
     67          AddValue(table, double.NaN, name, param.Description);
    6568        }
    6669      }
  • trunk/sources/HeuristicLab.Core/3.3/Interfaces/ILookupParameter.cs

    r2852 r3687  
    2525  public interface ILookupParameter : IParameter {
    2626    string ActualName { get; set; }
     27    string TranslatedName { get; }
    2728    event EventHandler ActualNameChanged;
    2829  }
  • trunk/sources/HeuristicLab.Operators/3.3/SubScopesSorter.cs

    r3659 r3687  
    5858    public override IOperation Apply() {
    5959      descending = DescendingParameter.ActualValue.Value;
    60       actualName = LookupParameter<ItemArray<DoubleValue>>.TranslateName(ValueParameter.Name, ExecutionContext);
     60      actualName = ValueParameter.TranslatedName;
    6161      CurrentScope.SubScopes.Sort(SortScopes);
    6262      return base.Apply();
  • trunk/sources/HeuristicLab.Operators/3.3/VariableCreator.cs

    r3503 r3687  
    4747      IVariable var;
    4848      foreach (IParameter param in CollectedValues) {
    49         CurrentScope.Variables.TryGetValue(param.Name, out var);
     49        ILookupParameter lookupParam = param as ILookupParameter;
     50        string name = lookupParam != null ? lookupParam.TranslatedName : param.Name;
     51
     52        CurrentScope.Variables.TryGetValue(name, out var);
    5053        IItem value = param.ActualValue;
    5154        if (var != null)
    5255          var.Value = value == null ? null : (IItem)value.Clone();
    5356        else
    54           CurrentScope.Variables.Add(new Variable(param.Name, param.Description, value == null ? null : (IItem)value.Clone()));
     57          CurrentScope.Variables.Add(new Variable(name, param.Description, value == null ? null : (IItem)value.Clone()));
    5558      }
    5659      return base.Apply();
  • trunk/sources/HeuristicLab.Optimization.Operators/3.3/ResultsCollector.cs

    r3664 r3687  
    5959        IItem value = param.ActualValue;
    6060        if (value != null) {
    61           results.TryGetValue(param.Name, out result);
     61          ILookupParameter lookupParam = param as ILookupParameter;
     62          string name = lookupParam != null ? lookupParam.TranslatedName : param.Name;
     63
     64          results.TryGetValue(name, out result);
    6265          if (result != null)
    6366            result.Value = copy ? (IItem)value.Clone() : value;
    6467          else
    65             results.Add(new Result(param.Name, param.Description, copy ? (IItem)value.Clone() : value));
     68            results.Add(new Result(name, param.Description, copy ? (IItem)value.Clone() : value));
    6669        }
    6770      }
  • trunk/sources/HeuristicLab.Parameters/3.3/LookupParameter.cs

    r3555 r3687  
    4242          OnActualNameChanged();
    4343        }
     44      }
     45    }
     46    public string TranslatedName {
     47      get {
     48        string translatedName;
     49        GetValueParameterAndTranslateName(out translatedName);
     50        return translatedName;
    4451      }
    4552    }
     
    168175      OnToStringChanged();
    169176    }
    170 
    171     public static string TranslateName(string name, IExecutionContext context) {
    172       string currentName = name;
    173       IExecutionContext currentContext = context;
    174       IParameter param;
    175       ILookupParameter lookupParam;
    176 
    177       while (currentContext != null) {
    178         currentContext.Parameters.TryGetValue(currentName, out param);
    179         if (param != null) {
    180           lookupParam = param as ILookupParameter;
    181           if (lookupParam == null)
    182             throw new InvalidOperationException(
    183               string.Format("Parameter look-up chain broken. Parameter \"{0}\" is not an \"{1}\".",
    184                             currentName,
    185                             typeof(ILookupParameter).GetPrettyName())
    186             );
    187           currentName = lookupParam.ActualName;
    188         }
    189         currentContext = currentContext.Parent;
    190       }
    191       return currentName;
    192     }
    193177  }
    194178}
  • trunk/sources/HeuristicLab.Parameters/3.3/ScopeTreeLookupParameter.cs

    r3663 r3687  
    7373
    7474    protected override IItem GetActualValue() {
    75       string name = LookupParameter<ItemArray<T>>.TranslateName(Name, ExecutionContext);
    76 
    7775      IEnumerable<IScope> scopes = new IScope[] { ExecutionContext.Scope };
    7876      for (int i = 0; i < depth; i++)
    7977        scopes = scopes.Select(x => (IEnumerable<IScope>)x.SubScopes).Aggregate((a, b) => a.Concat(b));
    8078
     79      string name = TranslatedName;
    8180      List<T> values = new List<T>();
    8281      IVariable var;
     
    105104        );
    106105
    107       string name = LookupParameter<ItemArray<T>>.TranslateName(Name, ExecutionContext);
    108 
    109106      IEnumerable<IScope> scopes = new IScope[] { ExecutionContext.Scope };
    110107      for (int i = 0; i < depth; i++)
     
    113110      if (scopes.Count() != values.Length) throw new InvalidOperationException("Number of values is not equal to number of scopes.");
    114111
     112      string name = TranslatedName;
    115113      int j = 0;
    116114      IVariable var;
Note: See TracChangeset for help on using the changeset viewer.