Free cookie consent management tool by TermsFeed Policy Generator

Changeset 17073


Ignore:
Timestamp:
07/04/19 16:10:58 (5 years ago)
Author:
mkommend
Message:

#2958: Merged 16378, 16379, 16542 into stable.

Location:
stable
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.ExtLibs

  • stable/HeuristicLab.ExtLibs/HeuristicLab.NativeInterpreter/0.1/HeuristicLab.NativeInterpreter-0.1/HeuristicLab.NativeInterpreter-0.1.csproj

    r16266 r17073  
    3939  </PropertyGroup>
    4040  <ItemGroup>
    41     <Reference Include="HeuristicLab.PluginInfrastructure-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    42       <SpecificVersion>False</SpecificVersion>
    43       <HintPath>..\..\..\..\bin\HeuristicLab.PluginInfrastructure-3.3.dll</HintPath>
    44       <Private>False</Private>
    45     </Reference>
    4641    <Reference Include="System" />
    4742    <Reference Include="System.Core" />
     
    6964    </Content>
    7065  </ItemGroup>
     66  <ItemGroup>
     67    <ProjectReference Include="..\..\..\..\HeuristicLab.PluginInfrastructure\3.3\HeuristicLab.PluginInfrastructure-3.3.csproj">
     68      <Project>{94186a6a-5176-4402-ae83-886557b53cca}</Project>
     69      <Name>HeuristicLab.PluginInfrastructure-3.3</Name>
     70      <Private>False</Private>
     71    </ProjectReference>
     72  </ItemGroup>
    7173  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
    7274</Project>
  • stable/HeuristicLab.Problems.DataAnalysis.Symbolic

  • stable/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeBatchInterpreter.cs

    r17072 r17073  
    3636      Parameters.Add(new FixedValueParameter<IntValue>(EvaluatedSolutionsParameterName, "A counter for the total number of solutions the interpreter has evaluated", new IntValue(0)));
    3737    }
    38 
    3938
    4039    [StorableConstructor]
     
    175174    }
    176175
     176    private readonly object syncRoot = new object();
     177
    177178    [ThreadStatic]
    178179    private Dictionary<string, double[]> cachedData;
    179180
     181    [ThreadStatic]
     182    private IDataset dataset;
     183
    180184    private void InitCache(IDataset dataset) {
     185      this.dataset = dataset;
    181186      cachedData = new Dictionary<string, double[]>();
    182187      foreach (var v in dataset.DoubleVariables) {
     
    187192    public void InitializeState() {
    188193      cachedData = null;
     194      dataset = null;
    189195      EvaluatedSolutions = 0;
    190196    }
    191197
    192198    private double[] GetValues(ISymbolicExpressionTree tree, IDataset dataset, int[] rows) {
     199      if (cachedData == null || this.dataset != dataset) {
     200        InitCache(dataset);
     201      }
     202
    193203      var code = Compile(tree, dataset, OpCodes.MapSymbolToOpCode);
    194204      var remainingRows = rows.Length % BATCHSIZE;
    195205      var roundedTotal = rows.Length - remainingRows;
    196206
    197       // TODO: evaluated solutions are not counted
    198 
    199207      var result = new double[rows.Length];
    200208
     
    209217      }
    210218
     219      // when evaluation took place without any error, we can increment the counter
     220      lock (syncRoot) {
     221        EvaluatedSolutions++;
     222      }
     223
    211224      return result;
    212225    }
    213226
    214227    public IEnumerable<double> GetSymbolicExpressionTreeValues(ISymbolicExpressionTree tree, IDataset dataset, int[] rows) {
    215       if (cachedData == null) {
    216         InitCache(dataset);
    217       }
    218228      return GetValues(tree, dataset, rows);
    219229    }
  • stable/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeNativeInterpreter.cs

    r17071 r17073  
    5959    protected SymbolicDataAnalysisExpressionTreeNativeInterpreter(bool deserializing) : base(deserializing) { }
    6060
    61 
    6261    protected SymbolicDataAnalysisExpressionTreeNativeInterpreter(SymbolicDataAnalysisExpressionTreeNativeInterpreter original, Cloner cloner) : base(original, cloner) {
    6362    }
     
    9998    private static Dictionary<string, GCHandle> cachedData;
    10099
     100    [ThreadStatic]
     101    private IDataset dataset;
     102
    101103    public IEnumerable<double> GetSymbolicExpressionTreeValues(ISymbolicExpressionTree tree, IDataset dataset, IEnumerable<int> rows) {
    102104      if (!rows.Any()) return Enumerable.Empty<double>();
    103105
    104       lock (syncRoot) {
    105         EvaluatedSolutions++; // increment the evaluated solutions counter
    106       }
    107 
    108       if (cachedData == null) {
     106      if (cachedData == null || this.dataset != dataset) {
    109107        InitCache(dataset);
    110108      }
     
    116114
    117115      NativeWrapper.GetValuesVectorized(code, code.Length, rowsArray, rowsArray.Length, result);
     116
     117      // when evaluation took place without any error, we can increment the counter
     118      lock (syncRoot) {
     119        EvaluatedSolutions++;
     120      }
     121
    118122      return result;
    119123    }
    120124
    121125    private void InitCache(IDataset dataset) {
     126      this.dataset = dataset;
     127
     128      // free handles to old data
     129      if (cachedData != null) {
     130        foreach (var gch in cachedData.Values) {
     131          gch.Free();
     132        }
     133        cachedData = null;
     134      }
     135
     136      // cache new data
    122137      cachedData = new Dictionary<string, GCHandle>();
    123138      foreach (var v in dataset.DoubleVariables) {
     
    135150        cachedData = null;
    136151      }
     152      dataset = null;
    137153      EvaluatedSolutions = 0;
    138154    }
Note: See TracChangeset for help on using the changeset viewer.