Revision 754

branches/threaded2/src/nh99/mod_hess.cpp (revision 754)
69 69

  
70 70
void function_minimizer::hess_routine_noparallel(void)
71 71
{
72
  int nvar=initial_params::nvarcalc(); // get the number of active parameters
73
  //if (adjm_ptr) set_labels_for_hess(nvar);
72
  int nvar=initial_params::nvarcalc();
74 73
  independent_variables x(1,nvar);
75
  initial_params::xinit(x);        // get the initial values into the x vector
74
  initial_params::xinit(x);
76 75
  double delta=1.e-5;
77 76
  dvector g1(1,nvar);
78 77
  dvector g2(1,nvar);
79
  dvector gbest(1,nvar);
80 78
  dvector hess(1,nvar);
81 79
  dvector hess1(1,nvar);
82 80
  dvector hess2(1,nvar);
83 81
  double eps=.1;
84 82
  gradient_structure::set_YES_DERIVATIVES();
83

  
84
  dvector gbest(1,nvar);
85 85
  gbest.fill_seqadd(1.e+50,0.);
86 86
 
87 87
  std::ostringstream oss;
88 88
  std::thread::id this_thread_id = std::this_thread::get_id();
89 89
  oss << *ad_comm::adprogram_name << this_thread_id << ".hes";
90 90
  uostream ofs((char*)oss.str().c_str());
91

  
92 91
  ofs << nvar;
93 92
  {
94 93
    {
......
98 97
      vf+=*objective_function_value::pobjfun;
99 98
      double f = value(vf);
100 99
      gradcalc(nvar,g1);
101
//cerr << this_thread_id << " f: " << f << " g1: " << g1 << endl;
102 100
    }
103 101
    for (int i=1;i<=nvar;i++)
104 102
    {
......
119 117
      vf+=*objective_function_value::pobjfun;
120 118
      f=value(vf);
121 119
      gradcalc(nvar,g1);
122
//cerr << this_thread_id << " f: " << f << " g1: " << g1 << endl;
123 120

  
124 121
      double sdelta2=x(i)-delta;
125 122
      sdelta2-=x(i);
......
132 129
      gradcalc(nvar,g2);
133 130
      x(i)=xsave;
134 131
      hess1=(g1-g2)/(sdelta1-sdelta2);
135
//cerr << this_thread_id << " f: " << f << " g2: " << g2 << endl;
136 132

  
137 133
      sdelta1=x(i)+eps*delta;
138 134
      sdelta1-=x(i);
......
162 158
      hess = (eps2 * hess1 - hess2) / (eps2 - 1.0);
163 159

  
164 160
      ofs << hess;
165

  
166
//cerr << "g1b: " << g1 << endl;
167
//cerr << "g2b: " << g2 << endl;
168

  
169
//cerr << hess << endl;
170 161
    }
171 162
  }
172 163
  ofs << gradient_structure::Hybrid_bounded_flag;
173 164
  dvector tscale(1,nvar);   // need to get scale from somewhere
174 165
  initial_params::stddev_scale(tscale,x);
175 166
  ofs << tscale;
167

  
168
  ofs.close();
176 169
}
177 170

  
178 171
void function_minimizer::hess_routine_and_constraint(int iprof, const dvector& g, dvector& fg)

Also available in: Unified diff