1 /* DIRserial-transp.f -- translated by f2c (version 20050501).
3 f2c output hand-cleaned by SGJ (August 2007).
6 #include "direct-internal.h"
8 /* +-----------------------------------------------------------------------+ */
9 /* | Program : Direct.f (subfile DIRserial.f) | */
10 /* | Last modified : 04-12-2001 | */
11 /* | Written by : Joerg Gablonsky | */
12 /* | SUBROUTINEs, which differ depENDing on the serial or parallel version.| */
13 /* +-----------------------------------------------------------------------+ */
14 /* +-----------------------------------------------------------------------+ */
15 /* | SUBROUTINE for sampling. | */
16 /* +-----------------------------------------------------------------------+ */
17 /* Subroutine */ void direct_dirsamplef_(doublereal *c__, integer *arrayi, doublereal
18 *delta, integer *sample, integer *new__, integer *length,
19 FILE *logfile, doublereal *f, integer *free, integer *maxi,
20 integer *point, fp fcn, doublereal *x, doublereal *l, doublereal *
21 fmin, integer *minpos, doublereal *u, integer *n, integer *maxfunc,
22 integer *maxdeep, integer *oops, doublereal *fmax, integer *
23 ifeasiblef, integer *iinfesiblef, void *fcn_data)
25 /* System generated locals */
26 integer length_dim1, length_offset, c_dim1, c_offset, i__1, i__2;
30 integer i__, j, helppoint, pos, kret;
32 /* +-----------------------------------------------------------------------+ */
33 /* | JG 07/16/01 fcn must be declared external. | */
34 /* +-----------------------------------------------------------------------+ */
35 /* +-----------------------------------------------------------------------+ */
36 /* | JG 07/16/01 Removed fcn. | */
37 /* +-----------------------------------------------------------------------+ */
38 /* +-----------------------------------------------------------------------+ */
39 /* | JG 01/22/01 Added variable to keep track of the maximum value found. | */
40 /* | Added variable to keep track IF feasible point was found. | */
41 /* +-----------------------------------------------------------------------+ */
42 /* +-----------------------------------------------------------------------+ */
43 /* | Variables to pass user defined data to the function to be optimized. | */
44 /* +-----------------------------------------------------------------------+ */
45 /* +-----------------------------------------------------------------------+ */
46 /* | Set the pointer to the first function to be evaluated, | */
47 /* | store this position also in helppoint. | */
48 /* +-----------------------------------------------------------------------+ */
49 /* Parameter adjustments */
57 length_offset = 1 + length_dim1;
58 length -= length_offset;
60 c_offset = 1 + c_dim1;
66 /* +-----------------------------------------------------------------------+ */
67 /* | Iterate over all points, where the function should be | */
69 /* +-----------------------------------------------------------------------+ */
71 for (j = 1; j <= i__1; ++j) {
72 /* +-----------------------------------------------------------------------+ */
73 /* | Copy the position into the helparrayy x. | */
74 /* +-----------------------------------------------------------------------+ */
76 for (i__ = 1; i__ <= i__2; ++i__) {
77 x[i__] = c__[i__ + pos * c_dim1];
80 /* +-----------------------------------------------------------------------+ */
81 /* | Call the function. | */
82 /* +-----------------------------------------------------------------------+ */
83 direct_dirinfcn_(fcn, &x[1], &l[1], &u[1], n, &f[(pos << 1) + 1],
85 /* +-----------------------------------------------------------------------+ */
86 /* | Remember IF an infeasible point has been found. | */
87 /* +-----------------------------------------------------------------------+ */
88 *iinfesiblef = MAX(*iinfesiblef,kret);
90 /* +-----------------------------------------------------------------------+ */
91 /* | IF the function evaluation was O.K., set the flag in | */
92 /* | f(2,pos). Also mark that a feasible point has been found. | */
93 /* +-----------------------------------------------------------------------+ */
94 f[(pos << 1) + 2] = 0.;
96 /* +-----------------------------------------------------------------------+ */
97 /* | JG 01/22/01 Added variable to keep track of the maximum value found. | */
98 /* +-----------------------------------------------------------------------+ */
100 d__1 = f[(pos << 1) + 1];
101 *fmax = MAX(d__1,*fmax);
104 /* +-----------------------------------------------------------------------+ */
105 /* | IF the function could not be evaluated at the given point, | */
106 /* | set flag to mark this (f(2,pos) and store the maximum | */
107 /* | box-sidelength in f(1,pos). | */
108 /* +-----------------------------------------------------------------------+ */
109 f[(pos << 1) + 2] = 2.;
110 f[(pos << 1) + 1] = *fmax;
112 /* +-----------------------------------------------------------------------+ */
113 /* | IF the function could not be evaluated due to a failure in | */
114 /* | the setup, mark this. | */
115 /* +-----------------------------------------------------------------------+ */
117 f[(pos << 1) + 2] = -1.;
119 /* +-----------------------------------------------------------------------+ */
120 /* | Set the position to the next point, at which the function | */
121 /* | should e evaluated. | */
122 /* +-----------------------------------------------------------------------+ */
127 /* +-----------------------------------------------------------------------+ */
128 /* | Iterate over all evaluated points and see, IF the minimal | */
129 /* | value of the function has changed. IF this has happEND, | */
130 /* | store the minimal value and its position in the array. | */
131 /* | Attention: Only valied values are checked!! | */
132 /* +-----------------------------------------------------------------------+ */
133 i__1 = *maxi + *maxi;
134 for (j = 1; j <= i__1; ++j) {
135 if (f[(pos << 1) + 1] < *fmin && f[(pos << 1) + 2] == 0.) {
136 *fmin = f[(pos << 1) + 1];