Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/15/16 10:20:58 (8 years ago)
Author:
gkronber
Message:

#2434: merged changes r14026:14078 from trunk to branch

Location:
branches/crossvalidation-2434
Files:
4 deleted
14 edited
6 copied

Legend:

Unmodified
Added
Removed
  • branches/crossvalidation-2434

  • branches/crossvalidation-2434/HeuristicLab.Common/3.3/ObjectExtensions.cs

    r14029 r14079  
    3030
    3131namespace HeuristicLab.Common {
     32
     33  [AttributeUsage(System.AttributeTargets.Field)]
     34  // this attribute can be used to mark fields that should be excluded from object graph traversal
     35  public class ExcludeFromObjectGraphTraversalAttribute : Attribute {
     36  }
     37
    3238  public static class ObjectExtensions {
    3339    public static IEnumerable<T> ToEnumerable<T>(this T obj) {
     
    6369    ///   * System.Delegate
    6470    ///   * System.Reflection.Pointer
    65     ///   * System.RuntimeType
    6671    ///   * Primitives (Boolean, Byte, SByte, Int16, UInt16, Int32, UInt32, Int64, UInt64, IntPtr, UIntPtr, Char, Double, Single)
    6772    ///   * string, decimal, DateTime
     
    8085             typeof(Pointer).IsAssignableFrom(type) ||
    8186             type.Namespace == "System.Reflection.Emit" ||
    82              type.Assembly.GetName().Name == "System.Runtime.Serialization" ||
    83              typeof(TypeInfo).IsAssignableFrom(type) ||
    8487             (type.HasElementType && ExcludeType(type.GetElementType()));
    8588    }
     
    117120      } else {
    118121        if (!fieldInfos.ContainsKey(type))
    119           fieldInfos[type] = type.GetAllFields().ToArray();
     122          fieldInfos[type] = type.GetAllFields()
     123            .Where(fi => !fi.GetCustomAttributes<ExcludeFromObjectGraphTraversalAttribute>().Any())
     124            .ToArray();
    120125        foreach (FieldInfo f in fieldInfos[type]) {
    121126          if (excludeStaticMembers && f.IsStatic) continue;
  • branches/crossvalidation-2434/HeuristicLab.Data/3.3

  • branches/crossvalidation-2434/HeuristicLab.Data/3.3/TimeSpanValue.cs

    r14029 r14079  
    6565    }
    6666    protected virtual string GetValue() {
    67       return Value.ToString();
     67      return Value.ToString("c");
    6868    }
    6969    protected virtual bool SetValue(string value) {
     
    7575        return false;
    7676      }
     77    }
     78    public override string ToString() {
     79      return Value.ToString("c");
    7780    }
    7881
  • branches/crossvalidation-2434/HeuristicLab.Optimization

  • branches/crossvalidation-2434/HeuristicLab.Optimization.Views

  • branches/crossvalidation-2434/HeuristicLab.Optimization.Views/3.3/HeuristicLab.Optimization.Views-3.3.csproj

    r14029 r14079  
    166166      <DependentUpon>ExperimentListView.cs</DependentUpon>
    167167    </Compile>
     168    <Compile Include="ResultParameterView.cs">
     169      <SubType>UserControl</SubType>
     170    </Compile>
     171    <Compile Include="ResultParameterView.Designer.cs">
     172      <DependentUpon>ResultParameterView.cs</DependentUpon>
     173    </Compile>
    168174    <Compile Include="MultiEncodingView.cs">
    169175      <SubType>UserControl</SubType>
     
    405411      <Project>{14AB8D24-25BC-400C-A846-4627AA945192}</Project>
    406412      <Name>HeuristicLab.Optimization-3.3</Name>
     413      <Private>False</Private>
     414    </ProjectReference>
     415    <ProjectReference Include="..\..\HeuristicLab.Parameters.Views\3.3\HeuristicLab.Parameters.Views-3.3.csproj">
     416      <Project>{ae5b1ce5-9862-4d6f-a700-d72cd9aea295}</Project>
     417      <Name>HeuristicLab.Parameters.Views-3.3</Name>
     418      <Private>False</Private>
     419    </ProjectReference>
     420    <ProjectReference Include="..\..\HeuristicLab.Parameters\3.3\HeuristicLab.Parameters-3.3.csproj">
     421      <Project>{56f9106a-079f-4c61-92f6-86a84c2d84b7}</Project>
     422      <Name>HeuristicLab.Parameters-3.3</Name>
    407423      <Private>False</Private>
    408424    </ProjectReference>
  • branches/crossvalidation-2434/HeuristicLab.Optimization.Views/3.3/Plugin.cs.frame

    r14029 r14079  
    3939  [PluginDependency("HeuristicLab.MainForm.WindowsForms", "3.3")]
    4040  [PluginDependency("HeuristicLab.Optimization", "3.3")]
     41  [PluginDependency("HeuristicLab.Parameters.Views", "3.3")]
    4142  [PluginDependency("HeuristicLab.Problems.Instances", "3.3")]
    4243  [PluginDependency("HeuristicLab.Problems.Instances.Views", "3.3")]
  • branches/crossvalidation-2434/HeuristicLab.Optimization/3.3/HeuristicLab.Optimization-3.3.csproj

    r14029 r14079  
    156156    <Compile Include="Interfaces\ILocalImprovementAlgorithmOperator.cs" />
    157157    <Compile Include="Interfaces\IMultiObjectiveOperator.cs" />
     158    <Compile Include="Results\IResultParameter.cs" />
    158159    <Compile Include="Interfaces\ISingleObjectiveOperator.cs" />
    159160    <Compile Include="Interfaces\ISingleObjectivePathRelinker.cs" />
     
    169170    <Compile Include="MetaOptimizers\Experiment.cs" />
    170171    <Compile Include="MetaOptimizers\TimeLimitRun.cs" />
     172    <Compile Include="Results\ResultParameter.cs" />
    171173    <Compile Include="RunCollectionModification\RunCollectionRunRemover.cs" />
    172174    <Compile Include="Plugin.cs" />
     
    230232    <Compile Include="RunCollection.cs" />
    231233    <Compile Include="Run.cs" />
    232     <Compile Include="Interfaces\IResult.cs" />
     234    <Compile Include="Results\IResult.cs" />
    233235    <Compile Include="Interfaces\IDiscreteDoubleValueModifier.cs" />
    234236    <Compile Include="Interfaces\IExhaustiveMoveGenerator.cs" />
     
    254256    <Compile Include="Interfaces\ITabuChecker.cs" />
    255257    <Compile Include="Interfaces\ITabuMaker.cs" />
    256     <Compile Include="Result.cs" />
     258    <Compile Include="Results\Result.cs" />
    257259    <Compile Include="Algorithms\UserDefinedAlgorithm.cs" />
    258260    <Compile Include="Algorithms\EngineAlgorithm.cs" />
    259261    <Compile Include="Properties\AssemblyInfo.cs" />
    260     <Compile Include="ResultCollection.cs" />
     262    <Compile Include="Results\ResultCollection.cs" />
    261263    <Compile Include="Problems\UserDefinedProblem.cs" />
    262264  </ItemGroup>
  • branches/crossvalidation-2434/HeuristicLab.Parameters.Views/3.3/HeuristicLab.Parameters.Views-3.3.csproj

    r11623 r14079  
    217217      <Private>False</Private>
    218218    </ProjectReference>
    219     <ProjectReference Include="..\..\HeuristicLab.Optimization.Views\3.3\HeuristicLab.Optimization.Views-3.3.csproj">
    220       <Project>{662B4B15-8F4D-4AE5-B3EB-D91C215F5AF2}</Project>
    221       <Name>HeuristicLab.Optimization.Views-3.3</Name>
    222       <Private>False</Private>
    223     </ProjectReference>
    224     <ProjectReference Include="..\..\HeuristicLab.Optimization\3.3\HeuristicLab.Optimization-3.3.csproj">
    225       <Project>{14AB8D24-25BC-400C-A846-4627AA945192}</Project>
    226       <Name>HeuristicLab.Optimization-3.3</Name>
    227       <Private>False</Private>
    228     </ProjectReference>
    229219    <ProjectReference Include="..\..\HeuristicLab.Parameters\3.3\HeuristicLab.Parameters-3.3.csproj">
    230220      <Project>{56F9106A-079F-4C61-92F6-86A84C2D84B7}</Project>
  • branches/crossvalidation-2434/HeuristicLab.Parameters/3.3/LookupParameter.cs

    r12012 r14079  
    5050    public string TranslatedName {
    5151      get {
    52         string translatedName;
    53         GetValueParameterAndTranslateName(out translatedName);
     52        string translatedName = Name;
     53        GetValueParameterAndTranslateName(ExecutionContext, ref translatedName);
    5454        return translatedName;
    5555      }
     
    6161
    6262    private Lazy<ThreadLocal<IItem>> cachedActualValues;
    63     private IItem CachedActualValue {
     63    protected IItem CachedActualValue {
    6464      get { return cachedActualValues.Value.Value; }
     65      set { cachedActualValues.Value.Value = value; }
    6566    }
    6667
     
    128129    }
    129130
    130     private IValueParameter GetValueParameterAndTranslateName(out string actualName) {
     131    protected static IValueParameter GetValueParameterAndTranslateName(IExecutionContext executionContext, ref string translatedName) {
    131132      IValueParameter valueParam;
    132133      ILookupParameter lookupParam;
    133       IExecutionContext currentExecutionContext = ExecutionContext;
    134 
    135       actualName = Name;
     134      IExecutionContext currentExecutionContext = executionContext;
     135
    136136      while (currentExecutionContext != null) {
    137         valueParam = currentExecutionContext.Parameters[actualName] as IValueParameter;
    138         lookupParam = currentExecutionContext.Parameters[actualName] as ILookupParameter;
     137        IParameter param = null;
     138        while (currentExecutionContext != null && !currentExecutionContext.Parameters.TryGetValue(translatedName, out param))
     139          currentExecutionContext = currentExecutionContext.Parent;
     140        if (currentExecutionContext == null) break;
     141
     142        valueParam = param as IValueParameter;
     143        lookupParam = param as ILookupParameter;
    139144
    140145        if ((valueParam == null) && (lookupParam == null))
    141146          throw new InvalidOperationException(
    142147            string.Format("Parameter look-up chain broken. Parameter \"{0}\" is not an \"{1}\" or an \"{2}\".",
    143                           actualName, typeof(IValueParameter).GetPrettyName(), typeof(ILookupParameter).GetPrettyName())
     148                          translatedName, typeof(IValueParameter).GetPrettyName(), typeof(ILookupParameter).GetPrettyName())
    144149          );
    145150
     
    148153          else if (lookupParam == null) return valueParam;
    149154        }
    150         if (lookupParam != null) actualName = lookupParam.ActualName;
     155        translatedName = lookupParam.ActualName;
    151156
    152157        currentExecutionContext = currentExecutionContext.Parent;
    153         while ((currentExecutionContext != null) && !currentExecutionContext.Parameters.ContainsKey(actualName))
    154           currentExecutionContext = currentExecutionContext.Parent;
    155158      }
    156159      return null;
    157160    }
    158     private IVariable LookupVariable(string name) {
    159       IScope scope = ExecutionContext.Scope;
    160       while ((scope != null) && !scope.Variables.ContainsKey(name))
     161    protected static IVariable LookupVariable(IScope scope, string name) {
     162      IVariable variable = null;
     163      while (scope != null && !scope.Variables.TryGetValue(name, out variable))
    161164        scope = scope.Parent;
    162       return scope != null ? scope.Variables[name] : null;
    163     }
     165      return scope != null ? variable : null;
     166    }
     167
    164168    protected override IItem GetActualValue() {
    165169      if (CachedActualValue != null) return CachedActualValue;
    166       string name;
     170
     171      string translatedName = Name;
     172      var value = GetValue(ExecutionContext, ref translatedName);
     173      if (value != null && !(value is T))
     174        throw new InvalidOperationException(
     175          string.Format("Type mismatch. Variable \"{0}\" does not contain a \"{1}\".",
     176                        translatedName,
     177                        typeof(T).GetPrettyName())
     178        );
     179      CachedActualValue = value;
     180      return value;
     181    }
     182
     183    protected static IItem GetValue(IExecutionContext executionContext, ref string name) {
    167184      // try to get value from context stack
    168       IValueParameter param = GetValueParameterAndTranslateName(out name);
     185      IValueParameter param = GetValueParameterAndTranslateName(executionContext, ref name);
    169186      if (param != null) return param.Value;
    170187
    171188      // try to get variable from scope
    172       IVariable var = LookupVariable(name);
    173       if (var != null) {
    174         if (!(var.Value is T))
    175           throw new InvalidOperationException(
    176             string.Format("Type mismatch. Variable \"{0}\" does not contain a \"{1}\".",
    177                           name,
    178                           typeof(T).GetPrettyName())
    179           );
    180         cachedActualValues.Value.Value = var.Value;
    181         return var.Value;
    182       }
    183       return null;
    184     }
     189      IVariable var = LookupVariable(executionContext.Scope, name);
     190      return var != null ? var.Value : null;
     191    }
     192
    185193    protected override void SetActualValue(IItem value) {
    186194      if (!(value is T))
     
    189197                        typeof(T).GetPrettyName())
    190198        );
    191       cachedActualValues.Value.Value = value;
    192 
     199      CachedActualValue = value;
     200
     201      string translatedName = Name;
     202      SetValue(ExecutionContext, ref translatedName, value);
     203    }
     204
     205    protected static void SetValue(IExecutionContext executionContext, ref string name, IItem value) {
    193206      // try to set value in context stack
    194       string name;
    195       IValueParameter param = GetValueParameterAndTranslateName(out name);
     207      IValueParameter param = GetValueParameterAndTranslateName(executionContext, ref name);
    196208      if (param != null) {
    197209        param.Value = value;
     
    200212
    201213      // try to set value in scope
    202       IVariable var = LookupVariable(name);
     214      IVariable var = LookupVariable(executionContext.Scope, name);
    203215      if (var != null) {
    204216        var.Value = value;
     
    207219
    208220      // create new variable
    209       ExecutionContext.Scope.Variables.Add(new Variable(name, value));
     221      executionContext.Scope.Variables.Add(new Variable(name, value));
    210222    }
    211223
  • branches/crossvalidation-2434/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression

  • branches/crossvalidation-2434/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4

  • branches/crossvalidation-2434/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionConstantOptimizationEvaluator.cs

    r14029 r14079  
    332332          terms.Add(t);
    333333        }
    334         term = AutoDiff.TermBuilder.Sum(terms);
     334        if (terms.Count == 1) term = -terms[0];
     335        else term = AutoDiff.TermBuilder.Sum(terms);
    335336        return true;
    336337      }
Note: See TracChangeset for help on using the changeset viewer.