Revision 1053 branches/threaded2/examples/threaded/multisimple/msimple1.tpl

msimple1.tpl (revision 1053)
1 1
//$Id: msimple1.tpl 742M 2013-06-02 00:06:06Z (local) $
2
GLOBALS_SECTION
3
  int NSLAVES = 7;
4 2

  
5 3
DATA_SECTION
6 4
  !! ad_comm::change_datafile_name("msimple.dat");
7 5
  init_int nobs
8
  int nslaves
9
  !! nslaves = NSLAVES;
10
  matrix Y(1,nslaves,1,nobs)
11
  matrix x(1,nslaves,1,nobs)
6
  init_int nrow
7
  matrix Y(1,nrow,1,nobs)
8
  matrix x(1,nrow,1,nobs)
9
  number A
10
  number B
12 11

  
13 12
 LOCAL_CALCS
14
    double A = 2.0;
15
    double B = 4.0;
13
    A = 2.0;
14
    B = 4.0;
16 15
    random_number_generator rng(101);
17 16
    dvector err(1,nobs);
18
    for (int i = 1; i <= nslaves; i++)
17
    for (int i = 1; i <= nrow; i++)
19 18
    {
20 19
       x(i).fill_randu(rng);
21 20
       x(i) *= 100.0;
......
27 26
PARAMETER_SECTION
28 27
  init_number a   
29 28
  init_number b   
30
  vector ff(1,nslaves)
31
  matrix pred_Y(1,nslaves,1,nobs)
29
  vector ff(1,nrow)
30
  matrix pred_Y(1,nrow,1,nobs)
32 31
  objective_function_value f
33 32

  
34 33
PRELIMINARY_CALCS_SECTION
......
36 35
  b = 2.0;
37 36

  
38 37
PROCEDURE_SECTION
39
  for (int i=1;i<=nslaves;i++)
38
  for (int i=1;i<=nrow;i++)
40 39
  {
41 40
      pred_Y(i) = a * x(i) +  b;
42 41
      ff(i) = norm2(pred_Y(i)-Y(i)); 
43
      ff(i) = nobs/2.*log(ff(i));    // make it a likelihood function so that
44
                                    // covariance matrix is correct
45 42
  }
46 43
  f = sum(ff);
44
  f = (nrow*nobs)/2.*log(f);    // make it a likelihood function so that
45
                                    // covariance matrix is correct
46
REPORT_SECTION
47
  report << "A = " << A << "; B = " << B <<endl;
48
  report << "a = " << a << "; b = " << b <<endl;
47 49

  
50

  

Also available in: Unified diff