source: trunk/optimizer/src/pgapack/gekco/pgapack/examples/mgh/objfcn77.f @ 815

Last change on this file since 815 was 815, checked in by liveletlive, 16 years ago

Committing the /tmp/gekco/pgapack folder that contains the older PGAPack version and Prof. Klimecks changes to it.

File size: 8.0 KB
Line 
1      subroutine objfcn(n,x,f,nprob)
2      integer n,nprob
3      double precision f
4      double precision x(n)
5c     **********
6c
7c     subroutine objfcn
8c
9c     This subroutine defines the objective functions of eighteen
10c     nonlinear unconstrained minimization problems. The values
11c     of n for functions 1,2,3,4,5,10,11,12,16 and 17 are
12c     3,6,3,2,3,2,4,3,2 and 4, respectively.
13c     For function 7, n may be 2 or greater but is usually 6 or 9.
14c     For functions 6,8,9,13,14,15 and 18 n may be variable,
15c     however it must be even for function 14, a multiple of 4 for
16c     function 15, and not greater than 50 for function 18.
17c
18c     The subroutine statement is
19c
20c       subroutine objfcn(n,x,f,nprob)
21c
22c     where
23c
24c       n is a positive integer input variable.
25c
26c       x is an input array of length n.
27c
28c       f is an output variable which contains the value of
29c         the nprob objective function evaluated at x.
30c
31c       nprob is a positive integer input variable which defines the
32c         number of the problem. nprob must not exceed 18.
33c
34c     Subprograms called
35c
36c       FORTRAN-supplied ... abs,atan,cos,dble,exp,log,sign,sin,sqrt
37c
38c     Argonne National Laboratory. MINPACK Project. march 1980.
39c     Burton S. Garbow, Kenneth E. Hillstrom, Jorge J. More
40c
41c     **********
42      integer i,iev,j
43      double precision ap,arg,c2pdm6,cp0001,cp1,cp2,cp25,cp5,c1p5,
44     *                 c2p25,c2p625,c3p5,c25,c29,c90,c100,c10000,
45     *                 c1pd6,d1,d2,eight,fifty,five,four,one,r,s1,s2,
46     *                 s3,t,t1,t2,t3,ten,th,three,tpi,two,zero
47      double precision fvec(50),y(15)
48      data zero,one,two,three,four,five,eight,ten,fifty
49     *     /0.0d0,1.0d0,2.0d0,3.0d0,4.0d0,5.0d0,8.0d0,1.0d1,5.0d1/
50      data c2pdm6,cp0001,cp1,cp2,cp25,cp5,c1p5,c2p25,c2p625,c3p5,c25,
51     *     c29,c90,c100,c10000,c1pd6
52     *     /2.0d-6,1.0d-4,1.0d-1,2.0d-1,2.5d-1,5.0d-1,1.5d0,2.25d0,
53     *      2.625d0,3.5d0,2.5d1,2.9d1,9.0d1,1.0d2,1.0d4,1.0d6/
54      data ap /1.0d-5/
55      data y(1),y(2),y(3),y(4),y(5),y(6),y(7),y(8),y(9),y(10),y(11),
56     *     y(12),y(13),y(14),y(15)
57     *     /9.0d-4,4.4d-3,1.75d-2,5.4d-2,1.295d-1,2.42d-1,3.521d-1,
58     *      3.989d-1,3.521d-1,2.42d-1,1.295d-1,5.4d-2,1.75d-2,4.4d-3,
59     *      9.0d-4/
60c
61c     Function routine selector.
62c
63      go to (10,20,40,60,70,90,110,150,170,200,210,230,250,280,300,
64     *       320,330,340), nprob
65c
66c     Helical valley function.
67c
68   10 continue
69      tpi = eight*atan(one)
70      th = sign(cp25,x(2))
71      if (x(1) .gt. zero) th = atan(x(2)/x(1))/tpi
72      if (x(1) .lt. zero) th = atan(x(2)/x(1))/tpi + cp5
73      arg = x(1)**2 + x(2)**2
74      r = sqrt(arg)
75      t = x(3) - ten*th
76      f = c100*(t**2 + (r - one)**2) + x(3)**2
77      return
78c
79c     Biggs exp6 function.
80c
81   20 continue
82      f = zero
83      do 30 i = 1, 13
84         d1 = dble(i)/ten
85         d2 = exp(-d1) - five*exp(-ten*d1) + three*exp(-four*d1)
86         s1 = exp(-d1*x(1))
87         s2 = exp(-d1*x(2))
88         s3 = exp(-d1*x(5))
89         t = x(3)*s1 - x(4)*s2 + x(6)*s3 - d2
90         f = f + t**2
91   30    continue
92      return
93c
94c     Gaussian function.
95c
96   40 continue
97      f = zero
98      do 50 i = 1, 15
99         d1 = cp5*dble(i-1)
100         d2 = c3p5 - d1 - x(3)
101         arg = -cp5*x(2)*d2**2
102         r = exp(arg)
103         t = x(1)*r - y(i)
104         f = f + t**2
105   50    continue
106      return
107c
108c     Powell badly scaled function.
109c
110   60 continue
111      t1 = c10000*x(1)*x(2) - one
112      s1 = exp(-x(1))
113      s2 = exp(-x(2))
114      t2 = s1 + s2 - one - cp0001
115      f = t1**2 + t2**2
116      return
117c
118c     Box 3-dimensional function.
119c
120   70 continue
121      f = zero
122      do 80 i = 1, 10
123         d1 = dble(i)
124         d2 = d1/ten
125         s1 = exp(-d2*x(1))
126         s2 = exp(-d2*x(2))
127         s3 = exp(-d2) - exp(-d1)
128         t = s1 - s2 - s3*x(3)
129         f = f + t**2
130   80    continue
131      return
132c
133c     Variably dimensioned function.
134c
135   90 continue
136      t1 = zero
137      t2 = zero
138      do 100 j = 1, n
139         t1 = t1 + dble(j)*(x(j) - one)
140         t2 = t2 + (x(j) - one)**2
141  100    continue
142      f = t2 + t1**2*(one + t1**2)
143      return
144c
145c     Watson function.
146c
147  110 continue
148      f = zero
149      do 140 i = 1, 29
150         d1 = dble(i)/c29
151         s1 = zero
152         d2 = one
153         do 120 j = 2, n
154            s1 = s1 + dble(j-1)*d2*x(j)
155            d2 = d1*d2
156  120       continue
157         s2 = zero
158         d2 = one
159         do 130 j = 1, n
160            s2 = s2 + d2*x(j)
161            d2 = d1*d2
162  130       continue
163         t = s1 - s2**2 - one
164         f = f + t**2
165  140    continue
166      t1 = x(2) - x(1)**2 - one
167      f = f + x(1)**2 + t1**2
168      return
169c
170c     Penalty function I.
171c
172  150 continue
173      t1 = -cp25
174      t2 = zero
175      do 160 j = 1, n
176         t1 = t1 + x(j)**2
177         t2 = t2 + (x(j) - one)**2
178  160    continue
179      f = ap*t2 + t1**2
180      return
181c
182c     Penalty function II.
183c
184  170 continue
185      t1 = -one
186      t2 = zero
187      t3 = zero
188      d1 = exp(cp1)
189      d2 = one
190      do 190 j = 1, n
191         t1 = t1 + dble(n-j+1)*x(j)**2
192         s1 = exp(x(j)/ten)
193         if (j .gt. 1) then
194            s3 = s1 + s2 - d2*(d1 + one)
195            t2 = t2 + s3**2
196            t3 = t3 + (s1 - one/d1)**2
197            end if
198         s2 = s1
199         d2 = d1*d2
200  190    continue
201      f = ap*(t2 + t3) + t1**2 + (x(1) - cp2)**2
202      return
203c
204c     Brown badly scaled function.
205c
206  200 continue
207      t1 = x(1) - c1pd6
208      t2 = x(2) - c2pdm6
209      t3 = x(1)*x(2) - two
210      f = t1**2 + t2**2 + t3**2
211      return
212c
213c     Brown and Dennis function.
214c
215  210 continue
216      f = zero
217      do 220 i = 1, 20
218         d1 = dble(i)/five
219         d2 = sin(d1)
220         t1 = x(1) + d1*x(2) - exp(d1)
221         t2 = x(3) + d2*x(4) - cos(d1)
222         t = t1**2 + t2**2
223         f = f + t**2
224  220    continue
225      return
226c
227c     Gulf research and development function.
228c
229  230 continue
230      f = zero
231      d1 = two/three
232      do 240 i = 1, 99
233         arg = dble(i)/c100
234         r = (-fifty*log(arg))**d1 + c25 - x(2)
235         t1 = abs(r)**x(3)/x(1)
236         t2 = exp(-t1)
237         t = t2 - arg
238         f = f + t**2
239  240    continue
240      return
241c
242c     Trigonometric function.
243c
244  250 continue
245      s1 = zero
246      do 260 j = 1, n
247         s1 = s1 + cos(x(j))
248  260    continue
249      f = zero
250      do 270 j = 1, n
251         t = dble(n+j) - sin(x(j)) - s1 - dble(j)*cos(x(j))
252         f = f + t**2
253  270    continue
254      return
255c
256c     Extended Rosenbrock function.
257c
258  280 continue
259      f = zero
260      do 290 j = 1, n, 2
261         t1 = one - x(j)
262         t2 = ten*(x(j+1) - x(j)**2)
263         f = f + t1**2 + t2**2
264  290    continue
265      return
266c
267c     Extended Powell function.
268c
269  300 continue
270      f = zero
271      do 310 j = 1, n, 4
272         t = x(j) + ten*x(j+1)
273         t1 = x(j+2) - x(j+3)
274         s1 = five*t1
275         t2 = x(j+1) - two*x(j+2)
276         s2 = t2**3
277         t3 = x(j) - x(j+3)
278         s3 = ten*t3**3
279         f = f + t**2 + s1*t1 + s2*t2 + s3*t3
280  310    continue
281      return
282c
283c     Beale function.
284c
285  320 continue
286      s1 = one - x(2)
287      t1 = c1p5 - x(1)*s1
288      s2 = one - x(2)**2
289      t2 = c2p25 - x(1)*s2
290      s3 = one - x(2)**3
291      t3 = c2p625 - x(1)*s3
292      f = t1**2 + t2**2 + t3**2
293      return
294c
295c     Wood function.
296c
297  330 continue
298      s1 = x(2) - x(1)**2
299      s2 = one - x(1)
300      s3 = x(2) - one
301      t1 = x(4) - x(3)**2
302      t2 = one - x(3)
303      t3 = x(4) - one
304      f = c100*s1**2 + s2**2 + c90*t1**2 + t2**2 + ten*(s3 + t3)**2
305     *    + (s3 - t3)**2/ten
306      return
307c
308c     Chebyquad function.
309c
310  340 continue
311      do 350 i = 1, n
312         fvec(i) = zero
313  350    continue
314      do 370 j = 1, n
315         t1 = one
316         t2 = two*x(j) - one
317         t = two*t2
318         do 360 i = 1, n
319            fvec(i) = fvec(i) + t2
320            th = t*t2 - t1
321            t1 = t2
322            t2 = th
323  360       continue
324  370    continue
325      f = zero
326      d1 = one/dble(n)
327      iev = -1
328      do 380 i = 1, n
329         t = d1*fvec(i)
330         if (iev .gt. 0) t = t + one/(dble(i)**2 - one)
331         f = f + t**2
332         iev = -iev
333  380    continue
334      return
335c
336c     Last card of subroutine objfcn.
337c
338      end
Note: See TracBrowser for help on using the repository browser.