Revision 795 branches/replacement/src/nh99/amoeba.cpp

amoeba.cpp (revision 795)
81 81
          if (i != ilo) {
82 82
            for (j=1;j<=ndim;j++)
83 83
              p[i][j]=psum[j]=0.5*(p[i][j]+p[ilo][j]);
84
	      
84

  
85 85
            dvariable vf=0.0;
86 86
            vf=initial_params::reset(dvar_vector(psum));
87 87
            *objective_function_value::pobjfun=0.0;
......
136 136
	return ytry;
137 137
}
138 138
#undef NRANSI
139

  
140

  
141

  
142

  
143
//****************************************************************************80
144
//
145
//  Purpose:
146
//
147
//    NELMIN minimizes a function using the Nelder-Mead algorithm.
148
//
149
//  Discussion:
150
//
151
//    This routine seeks the minimum value of a user-specified function.
152
//
153
//    Simplex function minimisation procedure due to Nelder+Mead(1965),
154
//    as implemented by O'Neill(1971, Appl.Statist. 20, 338-45), with
155
//    subsequent comments by Chambers+Ertel(1974, 23, 250-1), Benyon(1976,
156
//    25, 97) and Hill(1978, 27, 380-2)
157
//
158
//    This routine does not include a termination test using the
159
//    fitting of a quadratic surface.
160
//
161
//  Modified:
162
//
163
//    October 2010 by Derek Seiple
164
//
165
//  Author:
166
//
167
//    FORTRAN77 version by R ONeill
168
//    C++ version by John Burkardt
169
//
170
//  Reference:
171
//
172
//    John Nelder, Roger Mead,
173
//    A simplex method for function minimization,
174
//    Computer Journal,
175
//    Volume 7, 1965, pages 308-313.
176
//
177
//    R ONeill,
178
//    Algorithm AS 47:
179
//    Function Minimization Using a Simplex Procedure,
180
//    Applied Statistics,
181
//    Volume 20, Number 3, 1971, pages 338-345.
182
//
183
//  Parameters:
184
//
185
//    Input, int N, the number of variables.
186
//
187
//    Input/output, double START[N].  On input, a starting point
188
//    for the iteration.  On output, this data may have been overwritten.
189
//
190
//    Output, double XMIN[N], the coordinates of the point which
191
//    is estimated to minimize the function.
192
//
193
//    Output, double YNEWLO, the minimum value of the function.
194
//
195
//    Input, double REQMIN, the terminating limit for the variance
196
//    of function values.
197
//
198
//    Input, int KONVGE, the convergence check is carried out 
199
//    every KONVGE iterations.
200
//
201
//    Input, int KCOUNT, the maximum number of function 
202
//    evaluations.
203
//
204
//    Output, int *ICOUNT, the number of function evaluations 
205
//    used.
206
//
207
//    Output, int *NUMRES, the number of restarts.
208
//
209
//    Output, int *IFAULT, error indicator.
210
//    0, no errors detected.
211
//    1, REQMIN, N, or KONVGE has an illegal value.
212
//    2, iteration terminated because KCOUNT was exceeded without convergence.
213
//
214

  
215
void function_minimizer::neldmead(int n, dvector& _start, dvector& _xmin, 
216
  double *ynewlo, double reqmin, double delta,int *icount, int *numres, int *ifault)
217
{
218
  dvector& start=(dvector&) _start;
219
  dvector& xmin=(dvector&) _xmin;
220
  int slb = start.indexmin();
221
  int xlb = xmin.indexmin();
222
  start.shift(0);
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff