Last change
on this file was
17986,
checked in by gkronber, 3 years ago
|
#3106 Fixed a bug: training data were not resampled in restarts for local search. Made a few minor changes to match the description in the paper (introduced two parameters for local search and changed likelihood of variables to be included.)
|
File size:
947 bytes
|
Line | |
---|
1 | using HeuristicLab.Core;
|
---|
2 |
|
---|
3 | namespace HeuristicLab.Algorithms.DataAnalysis.ContinuedFractionRegression {
|
---|
4 | public class ContinuedFraction {
|
---|
5 | internal bool[] vars;
|
---|
6 | internal Term[] h;
|
---|
7 |
|
---|
8 | public ContinuedFraction() { }
|
---|
9 | public ContinuedFraction(int nVars, int depth, IRandom rand) {
|
---|
10 | this.vars = new bool[nVars];
|
---|
11 | for (int i = 0; i < nVars; i++) vars[i] = rand.NextDouble() < 0.3; // page 12 of the preprint. Each input variable then has a probability p = 1/3 to be present in the whitelist
|
---|
12 |
|
---|
13 | this.h = new Term[depth * 2 + 1];
|
---|
14 | for (int i = 0; i < h.Length; i++) {
|
---|
15 | h[i] = new Term();
|
---|
16 | var hi = h[i];
|
---|
17 | hi.vars = (bool[])vars.Clone();
|
---|
18 | hi.coef = new double[nVars];
|
---|
19 | for (int vi = 0; vi < nVars; vi++) {
|
---|
20 | if (hi.vars[vi])
|
---|
21 | hi.coef[vi] = rand.NextDouble() * 6 - 3;
|
---|
22 | }
|
---|
23 | hi.beta = rand.NextDouble() * 6 - 3;
|
---|
24 | }
|
---|
25 | }
|
---|
26 | }
|
---|
27 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.