Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2988_ModelsOfModels2/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/BatchOperations.cs @ 17495

Last change on this file since 17495 was 17134, checked in by msemenki, 5 years ago

#2988:

  1. The file system was changed, folders was added and part of files was transferred in these folders.
  2. HelpFunctions class was divided on 2 parts: HelpFuctions for common purposes static functions and SelfConfiguration that include functions for self-configuration mechanism realization (is used in EMMSucsessMap).
  3. Parts of self-configuration mechanism was transferred from EMMSucsessMap.cs to SelfConfiguration.cs. Now EMMSucsessMap used SelfConfiguration like one of data member. Other parts of project was adopted for this changing.
  4. FileComunication class was added. It include the majority of functions for printing to files or reading from files. Here were realized possibility to write and read to hl files.
  5. ModelTreeNode.cs has additional possibility - to write sub-model in string (then it is possible to write it in file).
  6. InfixExpressionFormatter.cs can work with TreeModelNode.
  7. Possibility for different map types to be readable from files was extended and cheeked.
  8. Such parameters like - ClusterNumbers, ClusterNumbersShow, NegbourNumber, NegbourType (that is used only in several maps) was transferred from EMMAlgorithm to Map Parameters. Now EMMBaseMap class inherited from ParameterizedNamedItem (not from Item). And EMMIslandMap and EMMNetworkMap contains their parameters (constructors was modified). CreationMap calls functions were simplified.
  9. Functions for different distance metric calculation was added. Now, it is possible to calculate different types of distances between models (with different random values of constants).
  10. DistanceParametr was added. Now maps can be created according different types of distance calculations.
  11. The class EMMClustering has new name KMeansClusterizationAlgorithm. On KMeansClusterizationAlgorithm bug with bloating of centroids list was fixed. Algorithm was adopted for working with different type of distance metric and get maximum number of iterations.
  12. Possibilities for constants optimization in sub-models an whole tree was added. EMMAlgorithm get new function for evaluation of individuals (and some additional technical stuff for that). Function for trees with model in usual tree transformation and back was added.
  13. EMMAlgorithm was divided on 2 parts:
  • EMMAlgorithm, that contain evolutionary algorithm working with sub-models, and use ready to use maps;
  • ModelSetPreparation, that contain distance calculation, model set simplification and map creation.
File size: 3.1 KB
Line 
1using System;
2
3namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
4  public static class BatchOperations {
5    public const int BATCHSIZE = 64;
6
7    public static void Load(double[] a, double[] b) {
8      Array.Copy(b, a, BATCHSIZE);
9    }
10
11    public static void Add(double[] a, double[] b) {
12      for (int i = 0; i < BATCHSIZE; ++i) {
13        a[i] += b[i];
14      }
15    }
16
17    public static void Sub(double[] a, double[] b) {
18      for (int i = 0; i < BATCHSIZE; ++i) {
19        a[i] -= b[i];
20      }
21    }
22
23    public static void Div(double[] a, double[] b) {
24      for (int i = 0; i < BATCHSIZE; ++i) {
25        a[i] /= b[i];
26      }
27    }
28
29    public static void Mul(double[] a, double[] b) {
30      for (int i = 0; i < BATCHSIZE; ++i) {
31        a[i] *= b[i];
32      }
33    }
34
35    public static void Neg(double[] a, double[] b) {
36      for (int i = 0; i < BATCHSIZE; ++i) {
37        a[i] = -b[i];
38      }
39    }
40
41    public static void Inv(double[] a, double[] b) {
42      for (int i = 0; i < BATCHSIZE; ++i) {
43        a[i] = 1 / b[i];
44      }
45    }
46
47    public static void Log(double[] a, double[] b) {
48      for (int i = 0; i < BATCHSIZE; ++i)
49        a[i] = Math.Log(b[i]);
50    }
51
52    public static void Exp(double[] a, double[] b) {
53      for (int i = 0; i < BATCHSIZE; ++i)
54        a[i] = Math.Exp(b[i]);
55    }
56
57    public static void Sin(double[] a, double[] b) {
58      for (int i = 0; i < BATCHSIZE; ++i)
59        a[i] = Math.Sin(b[i]);
60    }
61
62    public static void Cos(double[] a, double[] b) {
63      for (int i = 0; i < BATCHSIZE; ++i)
64        a[i] = Math.Cos(b[i]);
65    }
66
67    public static void Tan(double[] a, double[] b) {
68      for (int i = 0; i < BATCHSIZE; ++i)
69        a[i] = Math.Tan(b[i]);
70    }
71    public static void Tanh(double[] a, double[] b) {
72      for (int i = 0; i < BATCHSIZE; ++i)
73        a[i] = Math.Tanh(b[i]);
74    }
75
76    public static void Pow(double[] a, double[] b) {
77      for (int i = 0; i < BATCHSIZE; ++i)
78        a[i] = Math.Pow(a[i], Math.Round(b[i]));
79    }
80
81    public static void Root(double[] a, double[] b) {
82      for (int i = 0; i < BATCHSIZE; ++i)
83        a[i] = Math.Pow(a[i], 1 / Math.Round(b[i]));
84    }
85
86    public static void Square(double[] a, double[] b) {
87      for (int i = 0; i < BATCHSIZE; ++i)
88        a[i] = Math.Pow(b[i], 2d);
89    }
90
91    public static void Sqrt(double[] a, double[] b) {
92      for (int i = 0; i < BATCHSIZE; ++i)
93        a[i] = Math.Sqrt(b[i]);
94    }
95
96    public static void Cube(double[] a, double[] b) {
97      for (int i = 0; i < BATCHSIZE; ++i)
98        a[i] = Math.Pow(b[i], 3d);
99    }
100
101    public static void CubeRoot(double[] a, double[] b) {
102      for (int i = 0; i < BATCHSIZE; ++i)
103        a[i] = b[i] < 0 ? -Math.Pow(-b[i], 1d / 3d) : Math.Pow(b[i], 1d / 3d);
104    }
105
106    public static void Absolute(double[] a, double[] b) {
107      for (int i = 0; i < BATCHSIZE; ++i)
108        a[i] = Math.Abs(b[i]);
109    }
110
111    public static void AnalyticQuotient(double[] a, double[] b) {
112      for (int i = 0; i < BATCHSIZE; ++i)
113        a[i] = a[i] / Math.Sqrt(1d + b[i] * b[i]);
114    }
115  }
116}
Note: See TracBrowser for help on using the repository browser.