Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/17/10 05:24:03 (15 years ago)
Author:
swagner
Message:

Operator architecture refactoring (#95)

  • corrected several bugs in order to get SGA working
Location:
trunk/sources/HeuristicLab.Parameters/3.3
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Parameters/3.3/HeuristicLabParametersPlugin.cs.frame

    r2790 r2818  
    2020#endregion
    2121
    22 using System;
    23 using System.Collections.Generic;
    24 using System.Text;
    2522using HeuristicLab.PluginInfrastructure;
    2623
  • trunk/sources/HeuristicLab.Parameters/3.3/LookupParameter.cs

    r2805 r2818  
    2121
    2222using System;
    23 using System.Collections.Generic;
    24 using System.Text;
    25 using System.Xml;
    2623using HeuristicLab.Common;
    2724using HeuristicLab.Core;
     
    7168
    7269    public override string ToString() {
    73       return string.Format("{0}: {1} ({2})", Name, ActualName, DataType.Name);
    74     }
    75 
    76     private IValueParameter<T> GetParameter(out string name) {
    77       IValueParameter<T> valueParam = this as IValueParameter<T>;
    78       ILookupParameter<T> lookupParam = this as ILookupParameter<T>;
     70      return string.Format("{0}: {1} ({2})", Name, ActualName, DataType.GetPrettyName());
     71    }
     72
     73    private IValueParameter GetParameter(out string name) {
     74      IValueParameter valueParam = this as IValueParameter;
     75      ILookupParameter lookupParam = this as ILookupParameter;
    7976      ExecutionContext current = ExecutionContext;
    8077
    8178      name = Name;
    82       while ((valueParam != null) && (lookupParam != null)) {
     79      while ((valueParam != null) || (lookupParam != null)) {
    8380        if ((valueParam != null) && (valueParam.Value != null)) return valueParam;
    8481        if (lookupParam != null) name = lookupParam.ActualName;
     
    8986
    9087        if (current != null) {
    91           valueParam = current.Operator.Parameters[name] as IValueParameter<T>;
    92           lookupParam = current.Operator.Parameters[name] as ILookupParameter<T>;
     88          valueParam = current.Operator.Parameters[name] as IValueParameter;
     89          lookupParam = current.Operator.Parameters[name] as ILookupParameter;
    9390          if ((valueParam == null) && (lookupParam == null))
    9491            throw new InvalidOperationException(
    9592              string.Format("Parameter look-up chain broken. Parameter \"{0}\" is not an \"{1}\" or an \"{2}\".",
    9693                            name,
    97                             typeof(IValueParameter<T>).GetPrettyName(),
    98                             typeof(ILookupParameter<T>).GetPrettyName())
     94                            typeof(IValueParameter).GetPrettyName(),
     95                            typeof(ILookupParameter).GetPrettyName())
    9996            );
    10097        } else {
     
    111108      return scope != null ? scope.Variables[actualName] : null;
    112109    }
    113     private IValueParameter<T> GetProblemParameter(string name) {
    114       IValueParameter<T> param = null;
     110    private IValueParameter GetProblemParameter(string name) {
     111      IValueParameter param = null;
    115112      if (ExecutionContext.Problem.Parameters.ContainsKey(name)) {
    116         param = ExecutionContext.Problem.Parameters[name] as IValueParameter<T>;
     113        param = ExecutionContext.Problem.Parameters[name] as IValueParameter;
    117114        if (param == null)
    118115          throw new InvalidOperationException(
    119116            string.Format("Parameter look-up chain broken. Parameter \"{0}\" is not an \"{1}\".",
    120117                          name,
    121                           typeof(IValueParameter<T>).GetPrettyName())
     118                          typeof(IValueParameter).GetPrettyName())
    122119          );
    123120      }
     
    127124      string name;
    128125      // try to get value from context stack
    129       IValueParameter<T> param = GetParameter(out name);
     126      IValueParameter param = GetParameter(out name);
    130127      if (param != null) return param.Value;
    131128
     
    144141
    145142      // try to get value from problem
    146       IValueParameter<T> problemParam = GetProblemParameter(name);
     143      IValueParameter problemParam = GetProblemParameter(name);
    147144      if (problemParam != null) return problemParam.Value;
    148145
     
    158155      // try to set value in context stack
    159156      string name;
    160       IValueParameter<T> param = GetParameter(out name);
     157      IValueParameter param = GetParameter(out name);
    161158      if (param != null) {
    162159        param.Value = val;
     
    172169
    173170      // try to set value in problem
    174       IValueParameter<T> problemParam = GetProblemParameter(name);
     171      IValueParameter problemParam = GetProblemParameter(name);
    175172      if (problemParam != null) {
    176173        problemParam.Value = val;
     
    193190      ExecutionContext currentContext = context;
    194191      IParameter param;
    195       ILookupParameter<T> lookupParam;
     192      ILookupParameter lookupParam;
    196193
    197194      while (currentContext != null) {
    198195        currentContext.Operator.Parameters.TryGetValue(currentName, out param);
    199196        if (param != null) {
    200           lookupParam = param as ILookupParameter<T>;
     197          lookupParam = param as ILookupParameter;
    201198          if (lookupParam == null)
    202199            throw new InvalidOperationException(
    203200              string.Format("Parameter look-up chain broken. Parameter \"{0}\" is not an \"{1}\".",
    204201                            currentName,
    205                             typeof(ILookupParameter<T>).GetPrettyName())
     202                            typeof(ILookupParameter).GetPrettyName())
    206203            );
    207204          currentName = lookupParam.ActualName;
  • trunk/sources/HeuristicLab.Parameters/3.3/OperatorParameter.cs

    r2790 r2818  
    2020#endregion
    2121
    22 using System;
    23 using System.Collections.Generic;
    24 using System.Text;
    25 using System.Xml;
    2622using HeuristicLab.Core;
    2723using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
  • trunk/sources/HeuristicLab.Parameters/3.3/Parameter.cs

    r2790 r2818  
    2121
    2222using System;
    23 using System.Collections.Generic;
    24 using System.Text;
    25 using System.Xml;
     23using HeuristicLab.Common;
    2624using HeuristicLab.Core;
    2725using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     
    8482
    8583    public override string ToString() {
    86       return string.Format("{0} ({1})", Name, DataType.Name);
     84      return string.Format("{0} ({1})", Name, DataType.GetPrettyName());
    8785    }
    8886
  • trunk/sources/HeuristicLab.Parameters/3.3/ScopeParameter.cs

    r2790 r2818  
    2121
    2222using System;
    23 using System.Collections.Generic;
    24 using System.Text;
    25 using System.Xml;
     23using HeuristicLab.Common;
    2624using HeuristicLab.Core;
    2725using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     
    5048
    5149    public override string ToString() {
    52       return string.Format("{0} ({1})", Name, DataType.Name);
     50      return string.Format("{0} ({1})", Name, DataType.GetPrettyName());
    5351    }
    5452
  • trunk/sources/HeuristicLab.Parameters/3.3/SubScopesLookupParameter.cs

    r2796 r2818  
    2121
    2222using System;
    23 using System.Collections.Generic;
    24 using System.Text;
    25 using System.Xml;
    2623using HeuristicLab.Common;
    2724using HeuristicLab.Core;
    28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2925
    3026namespace HeuristicLab.Parameters {
     
    3935
    4036    protected override IItem GetActualValue() {
    41       string name = LookupParameter<T>.TranslateName(Name, ExecutionContext);
     37      string name = LookupParameter<ItemArray<T>>.TranslateName(Name, ExecutionContext);
    4238      IScope scope = ExecutionContext.Scope;
    4339      ItemArray<T> values = new ItemArray<T>(scope.SubScopes.Count);
     
    6864        );
    6965
    70       string name = LookupParameter<T>.TranslateName(Name, ExecutionContext);
     66      string name = LookupParameter<ItemArray<T>>.TranslateName(Name, ExecutionContext);
    7167      IScope scope = ExecutionContext.Scope;
    7268      IVariable var;
  • trunk/sources/HeuristicLab.Parameters/3.3/ValueLookupParameter.cs

    r2796 r2818  
    2121
    2222using System;
    23 using System.Collections.Generic;
    24 using System.Text;
    25 using System.Xml;
    2623using HeuristicLab.Common;
    2724using HeuristicLab.Core;
     
    8582
    8683    public override string ToString() {
    87       return string.Format("{0}: {1} ({2})", Name, Value != null ? Value.ToString() : ActualName, DataType.Name);
     84      return string.Format("{0}: {1} ({2})", Name, Value != null ? Value.ToString() : ActualName, DataType.GetPrettyName());
    8885    }
    8986
  • trunk/sources/HeuristicLab.Parameters/3.3/ValueParameter.cs

    r2796 r2818  
    2121
    2222using System;
    23 using System.Collections.Generic;
    24 using System.Text;
    25 using System.Xml;
    2623using HeuristicLab.Common;
    2724using HeuristicLab.Core;
     
    8582
    8683    public override string ToString() {
    87       return string.Format("{0}: {1} ({2})", Name, Value != null ? Value.ToString() : "null", DataType.Name);
     84      return string.Format("{0}: {1} ({2})", Name, Value != null ? Value.ToString() : "null", DataType.GetPrettyName());
    8885    }
    8986
Note: See TracChangeset for help on using the changeset viewer.