Revision 1153

branches/threaded2/examples/threaded/newertpl/newertpl.htp (revision 1153)
1
#if !defined(_newertpl_)
2
#  define _newertpl_
3

  
4
class model_data : public ad_comm{
5
  int m;
6
  int m2;
7
  ~model_data();
8
  model_data(int argc,char * argv[]);
9
  friend class model_parameters;
10
};
11

  
12
class model_parameters : public model_data ,
13
  public function_minimizer
14
{
15
public:
16
  ~model_parameters();
17
  void preliminary_calculations(void);
18
  void set_runtime(void);
19
  virtual void * mycast(void) {return (void*)this;}
20
  static int mc_phase(void)
21
  {
22
    return initial_params::mc_phase;
23
  }
24
  static int mceval_phase(void)
25
  {
26
    return initial_params::mceval_phase;
27
  }
28
  static int sd_phase(void)
29
  {
30
    return initial_params::sd_phase;
31
  }
32
  static int current_phase(void)
33
  {
34
    return initial_params::current_phase;
35
  }
36
  static int last_phase(void)
37
  {
38
    return (initial_params::current_phase
39
      >=initial_params::max_number_phases);
40
  }
41
  static prevariable current_feval(void)
42
  {
43
    return *objective_function_value::pobjfun;
44
  }
45
private:
46
  ivector integer_control_flags;
47
  dvector double_control_flags;
48
  param_init_vector x;
49
  param_number prior_function_value;
50
  param_number likelihood_function_value;
51
  objective_function_value f;
52
public:
53
  virtual void userfunction(void);
54
  virtual void report(void);
55
  virtual void final_calcs(void);
56
  model_parameters(int sz,int argc, char * argv[]);
57
  virtual void initializationfunction(void){}
58

  
59
};
60
#endif
branches/threaded2/examples/threaded/newertpl/newertpl.cpp (revision 1153)
1
  #include <admodel.h>
2
  #include "adthread.h"
3
 int M=10;
4
  void admb_thread_1(void * ptr)
5
  {
6
    pthread_mutex_lock(&ad_comm::pthread_manager->start_mutex);
7
    pthread_mutex_unlock(&ad_comm::pthread_manager->start_mutex);
8
    new_thread_data * tptr = (new_thread_data *) ptr;
9
    
10
    int m=tptr->m;
11
    int sno=tptr->thread_no;
12
    {
13
      gradient_structure::set_MAX_NVAR_OFFSET(10000);
14
      gradient_structure::set_GRADSTACK_BUFFER_SIZE(20000000);
15
      gradient_structure::set_CMPDIF_BUFFER_SIZE(20000000);
16
      gradient_structure::set_MAX_NVAR_OFFSET(10000);
17
      //gradient_structure::set_ARRAY_MEMBLOCK_SIZE(20000);
18
      gradient_structure gs(1000000);
19
      ad_comm::pthread_manager->set_slave_number(tptr->thread_no);
20
      do
21
      {
22
        ad_comm::pthread_manager->read_lock_buffer(0);
23
        int lflag=ad_comm::pthread_manager->get_int(0);
24
        if (lflag==0.0) break;
25
        dvar_vector v= ad_comm::pthread_manager->get_dvar_vector(0);
26
        ad_comm::pthread_manager->read_unlock_buffer(0);
27
        //cout << "NNN " << norm2(value(v)) << endl;
28
        int mmin=v.indexmin();
29
        int mmax=v.indexmax();
30
        dvar_matrix M(1,m,1,m);
31
        int ii=0;
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff