Revision 2018

trunk/tests/changepoint/changepoint.tpl (revision 2018)
1
DATA_SECTION
2
  init_int nobs
3
  init_vector y(1,nobs)
4
  vector predm(1,nobs)
5
PARAMETER_SECTION
6
  init_number m1
7
  init_number m2
8
  init_number cp
9
  objective_function_value f
10
PROCEDURE_SECTION
11

  
12
  double s=1;
13
  switch (current_phase())
14
  {
15
  case 1:
16
    s=1.0;
17
    break;
18
  case 2:
19
    s=10.0;
20
    break;
21
  case 3:
22
    s=100.0;
23
    break;
24
  default:
25
    s=1000.0;
26
    break;
27
  }
28

  
29
  for (int i=1;i<=nobs;i++)
30
  {
31
    dvariable p=f1(i,cp,s);
32
    dvariable m=p*m1+(1.0-p)*m2;
33
    predm(i)=value(m);
34
    f+=square(y(i)-m);
35
  }
36
  
37
REPORT_SECTION
38

  
39
  report << predm << endl;
40

  
41
GLOBALS_SECTION
42

  
43
  #include <admodel.h>
44

  
45
  dvariable f1(int i,const prevariable& cp,double s)
46
  {
47
    dvariable z=s*(cp-double(i));
48
    if (value(z)<20.)
49
    {
50
      return 1.0/(1+exp(z));
51
    }
52
    else
53
    {
54
      return exp(-z)/(1.0+exp(-z));
55
    }
56
  }
57

  
trunk/tests/changepoint/changepoint.dat (revision 2018)
1
100
2
 0 0 1 0 0 0 0 0 0 0
3
 0 0 0 0 0 0 0 0 0 0
4
 0 0 0 1 0 0 1 0 1 0
5
 1 0 1 0 1 1 0 1 1 1
6
 1 0 1 1 1 1 1 1 1 1
7
 1 1 1 1 1 1 1 1 1 1
8
 1 1 0 1 1 1 1 1 1 1
9
 1 1 1 1 1 1 1 1 1 1
10
 1 1 1 1 1 1 1 1 1 1
11
 1 1 1 1 1 1 1 1 1 1
12
 1 1 1 1 1 1 1 1 1 1
13
 1 1 1 1 1 1 1 1 1 1
14
 1 1 1 1 1 1 1 1 1 1
trunk/tests/changepoint/GNUmakefile (revision 2018)
1
ifeq ($(OS),Windows_NT)
2
EXT=.sh
3
endif
4

  
5
all:
6
	$(MAKE) changepoint.tpl
7
	../../admb$(EXT) changepoint.tpl
8
	$(MAKE) run
9

  
10
run: changepoint.dat
11
	./changepoint
12

  
13
changepoint.tpl:
14
	svn cat svn://scm.r-forge.r-project.org/svnroot/nwfscassmt/pkg/nwfscAgeingError/inst/executables/AGEMAT.TPL > changepoint.tpl
15

  
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff