Revision 1053

branches/threaded2/examples/threaded/multisimple/msimple.rep (revision 1053)
1
A = 2; B = 4
2
a = 2.00011; b = 3.98708
branches/threaded2/examples/threaded/multisimple/msimple1.par (revision 1053)
1
# Number of parameters = 2  Objective function value = 5.15547e+06  Maximum gradient component = 1.44899e-05
2
# a:
3
2.00011388315
4
# b:
5
3.98708478027
branches/threaded2/examples/threaded/multisimple/msimple1.cor (revision 1053)
1
 The logarithm of the determinant of the hessian = 27.2082
2
 index   name    value      std.dev       1       2   
3
     1   a  2.0001e+00 2.0692e-04   1.0000
4
     2   b  3.9871e+00 1.1944e-02  -0.8661  1.0000
branches/threaded2/examples/threaded/multisimple/msimple.eva (revision 1053)
1
    7008.337891    93491569.74
branches/threaded2/examples/threaded/multisimple/msimple.cpp (revision 1053)
1
  #include <pthread.h>
2
  #include <fvar.hpp>
3
  #include <adthread.h>
4
  //#include "pt_trace.h"
5
  pthread_mutex_t trace_mutex= PTHREAD_MUTEX_INITIALIZER;
6
  ofstream clogf;
7
  int NSLAVES = 7;
8
  void * mp_ptr = NULL;
9
  //adpthread_manager * ad_comm::pthread_manager= NULL;
10
  void* simple_thread(void * ptr);
11
  //int __thread thread_data::id=-1;
12
#include <admodel.h>
13
#include <contrib.h>
14

  
15
  extern "C"  {
16
    void ad_boundf(int i);
17
  }
18
#include <msimple.htp>
19

  
20
model_data::model_data(int argc,char * argv[]) : ad_comm(argc,argv)
21
{
22
  nobs.allocate("nobs");
23
 nslaves = NSLAVES;
24
  Y.allocate(1,nslaves,1,nobs);
25
  x.allocate(1,nslaves,1,nobs);
26
    //TTRACE(nobs,nslaves)
27
    A = 2.0;
28
    B = 4.0;
29
    random_number_generator rng(101);
30
    dvector err(1,nobs);
31
    for (int i = 1; i <= nslaves; i++)
32
    {
33
       x(i).fill_randu(rng);
34
       x(i) *= 100.0;
35
       Y(i) = A*x(i) + B;
36
       err.fill_randn(rng);
37
       Y(i) += 5.0*err;
38
    }
39
    /*
40
    if (1)
41
    {
42
       TTRACE(nobs,NSLAVES)
43
       TTRACE(A,B)
44
       TRACE(x)
45
       TRACE(Y)
46
       ad_exit(1);
47
    }
48
    */
49
}
50

  
51
model_parameters::model_parameters(int sz,int argc,char * argv[]) : 
52
 model_data(argc,argv) , function_minimizer(sz)
53
{
54
  initializationfunction();
55
  a.allocate("a");
56
  b.allocate("b");
57
  ff.allocate(1,nslaves,"ff");
58
  #ifndef NO_AD_INITIALIZE
59
    ff.initialize();
60
  #endif
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff