1 |
************************************************************************ |
2 |
* |
3 |
* File mi05funs fortran. |
4 |
* |
5 |
* funobj funcon matmod |
6 |
* t2obj t3obj t4obj t4con t5obj t6con t7obj |
7 |
* |
8 |
*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
9 |
|
10 |
subroutine funobj( mode, n, x, f, g, nstate, nprob, z, nwcore ) |
11 |
|
12 |
implicit double precision (a-h,o-z) |
13 |
double precision x(n), g(n), z(nwcore) |
14 |
|
15 |
* ------------------------------------------------------------------ |
16 |
* This is the default version of funobj for MINOS. |
17 |
* It is for one of the test problems |
18 |
* t2banana, t3qp, t4manne, t5weapon or t6wood, |
19 |
* which will specify |
20 |
* Problem number 1112, 1113, 1114, 1115 or 1116 |
21 |
* respectively in order to identify themselves. |
22 |
* ------------------------------------------------------------------ |
23 |
|
24 |
common /m1file/ iread,iprint,isumm |
25 |
|
26 |
if (nprob .eq. 1112) then |
27 |
call t2obj ( mode, n, x, f, g, nstate, nprob, z, nwcore ) |
28 |
else if (nprob .eq. 1113) then |
29 |
call t3obj ( mode, n, x, f, g, nstate, nprob, z, nwcore ) |
30 |
else if (nprob .eq. 1114) then |
31 |
call t4obj ( mode, n, x, f, g, nstate, nprob, z, nwcore ) |
32 |
else if (nprob .eq. 1115) then |
33 |
call t5obj ( mode, n, x, f, g, nstate, nprob, z, nwcore ) |
34 |
else if (nprob .eq. 1116) then |
35 |
* t6wood doesn't have a nonlinear objective |
36 |
else if (nprob .eq. 1117) then |
37 |
call t7obj ( mode, n, x, f, g, nstate, nprob, z, nwcore ) |
38 |
else |
39 |
if (iprint .gt. 0) write(iprint, 9000) |
40 |
if (isumm .gt. 0) write(isumm , 9000) |
41 |
mode = -1 |
42 |
end if |
43 |
|
44 |
9000 format(/ ' XXX Subroutine funobj has not been loaded.') |
45 |
|
46 |
* end of funobj |
47 |
end |
48 |
|
49 |
*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
50 |
|
51 |
subroutine funcon( mode, m, n, njac, x, f, g, |
52 |
$ nstate, nprob, z, nwcore ) |
53 |
|
54 |
implicit double precision (a-h,o-z) |
55 |
double precision x(n), f(m), g(njac), z(nwcore) |
56 |
|
57 |
* ------------------------------------------------------------------ |
58 |
* This is the default version of funcon for MINOS. |
59 |
* It is for one of the test problems |
60 |
* t4manne or t6wood, |
61 |
* which will specify |
62 |
* Problem number 1114 or 1116 |
63 |
* respectively in order to identify themselves. |
64 |
* ------------------------------------------------------------------ |
65 |
|
66 |
common /m1file/ iread,iprint,isumm |
67 |
|
68 |
if (nprob .eq. 1114) then |
69 |
call t4con ( mode, m, n, njac, x, f, g, |
70 |
$ nstate, nprob, z, nwcore ) |
71 |
else if (nprob .eq. 1116) then |
72 |
call t6con ( mode, m, n, njac, x, f, g, |
73 |
$ nstate, nprob, z, nwcore ) |
74 |
else |
75 |
if (iprint .gt. 0) write(iprint, 9000) |
76 |
if (isumm .gt. 0) write(isumm , 9000) |
77 |
mode = -1 |
78 |
end if |
79 |
|
80 |
9000 format(/ ' XXX Subroutine funcon has not been loaded.') |
81 |
|
82 |
* end of funcon |
83 |
end |
84 |
|
85 |
*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
86 |
|
87 |
subroutine matmod( ncycle, nprob, finish, |
88 |
$ m, n, nb, ne, nka, ns, nscl, nname, |
89 |
$ a, ha, ka, bl, bu, |
90 |
$ ascale, hs, name1, name2, |
91 |
$ x, pi, rc, z, nwcore ) |
92 |
|
93 |
implicit double precision (a-h,o-z) |
94 |
integer*4 ha(ne), hs(nb) |
95 |
integer ka(nka), name1(nname), name2(nname) |
96 |
double precision a(ne), ascale(nscl), bl(nb), bu(nb) |
97 |
double precision x(nb), pi(m), rc(nb), z(nwcore) |
98 |
logical finish |
99 |
|
100 |
* ------------------------------------------------------------------ |
101 |
* This is the default version of matmod for MINOS. |
102 |
* It belongs to the nonlinear test problem t4manne, |
103 |
* which will specify |
104 |
* Problem number 1114 |
105 |
* in order to identify itself. |
106 |
* |
107 |
* If Cycle limit > 1, matmod is called before the first cycle |
108 |
* (ncycle = 0) and at the end of each cycle except the last. |
109 |
* |
110 |
* 25 Nov 1991: nname and rc added as parameters. |
111 |
* nname = nb for regular MINOS, 1 for minoss. |
112 |
* 26 Jun 1992: If ncycle ge 1, rc contains reduced costs for the |
113 |
* columns and rows, using the appropriate objective |
114 |
* and pi. (If infeasible, it is the Phase 1 obj. |
115 |
* If feasible and maximizing, the sign is changed.) |
116 |
* ------------------------------------------------------------------ |
117 |
|
118 |
common /m1file/ iread,iprint,isumm |
119 |
common /m5lobj/ sinf,wtobj,minimz,ninf,iobj,jobj,kobj |
120 |
common /cyclcm/ cnvtol,jnew,materr,maxcy,nephnt,nphant,nprint |
121 |
|
122 |
if (nprob .eq. 1114) then |
123 |
bu(n) = 0.1 |
124 |
if (iprint .gt. 0) write(iprint, 1000) bu(n) |
125 |
if (isumm .gt. 0) write(isumm , 1000) bu(n) |
126 |
else |
127 |
if (iprint .gt. 0) write(iprint, 9000) |
128 |
if (isumm .gt. 0) write(isumm , 9000) |
129 |
finish = .true. |
130 |
end if |
131 |
|
132 |
1000 format(/ ' matmod changes last upper bound to', f5.2) |
133 |
9000 format(/ ' XXX Subroutine matmod has not been loaded.') |
134 |
|
135 |
* end of matmod |
136 |
end |
137 |
|
138 |
*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
139 |
|
140 |
subroutine t2obj ( mode, n, x, f, g, nstate, nprob, z, nwcore ) |
141 |
|
142 |
implicit double precision (a-h,o-z) |
143 |
double precision x(n), g(n), z(nwcore) |
144 |
|
145 |
* ------------------------------------------------------------------ |
146 |
* This is funobj for problem t2banana |
147 |
* (Rosenbrock's banana function). |
148 |
* f(x) = 100(x2 - x1**2)**2 + (1 - x1)**2. |
149 |
* ------------------------------------------------------------------ |
150 |
|
151 |
x1 = x(1) |
152 |
x2 = x(2) |
153 |
t1 = x2 - x1**2 |
154 |
t2 = 1.0d+0 - x1 |
155 |
f = 100.0d+0 * t1**2 + t2**2 |
156 |
g(1) = - 400.0d+0 * t1*x1 - 2.0d+0 * t2 |
157 |
g(2) = 200.0d+0 * t1 |
158 |
|
159 |
* end of t2obj (funobj for t2banana) |
160 |
end |
161 |
|
162 |
*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
163 |
|
164 |
subroutine t3obj ( mode, n, x, f, g, nstate, nprob, z, nwcore ) |
165 |
|
166 |
implicit double precision (a-h,o-z) |
167 |
double precision x(n), g(n), z(nwcore) |
168 |
|
169 |
* ------------------------------------------------------------------ |
170 |
* This is funobj for problem t3qp. |
171 |
* f(x) = 1/2 x'Qx, g(x) = Qx. |
172 |
* ------------------------------------------------------------------ |
173 |
|
174 |
parameter ( zero = 0.0d+0, half = 0.5d+0, |
175 |
$ two = 2.0d+0, four = 4.0d+0, |
176 |
$ maxn = 10 ) |
177 |
double precision Q(maxn,maxn) |
178 |
save Q |
179 |
|
180 |
if (nstate .eq. 1) then |
181 |
|
182 |
* Define Q on the first entry. |
183 |
* Here we assume n = 3. |
184 |
|
185 |
Q(1,1) = four |
186 |
Q(1,2) = two |
187 |
Q(1,3) = two |
188 |
Q(2,2) = four |
189 |
Q(2,3) = zero |
190 |
Q(3,3) = two |
191 |
|
192 |
* Make Q symmetric. |
193 |
|
194 |
do 20 j = 1, n-1 |
195 |
do 10 i = 2, n |
196 |
Q(i,j) = Q(j,i) |
197 |
10 continue |
198 |
20 continue |
199 |
end if |
200 |
|
201 |
* Compute f and g on all entries. |
202 |
* We first compute g = Qx, then f = 1/2 x'g. |
203 |
* In Fortran it is best to run down the columns of Q. |
204 |
|
205 |
do 200 i = 1, n |
206 |
g(i) = zero |
207 |
200 continue |
208 |
|
209 |
do 300 j = 1, n |
210 |
xj = x(j) |
211 |
do 250 i = 1, n |
212 |
g(i) = g(i) + Q(i,j) * xj |
213 |
250 continue |
214 |
300 continue |
215 |
|
216 |
f = half * ddot ( n, x, 1, g, 1 ) |
217 |
|
218 |
* end of t3obj (funobj for t3qp) |
219 |
end |
220 |
|
221 |
*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
222 |
|
223 |
subroutine t4obj ( mode, n, x, f, g, nstate, nprob, z, nwcore ) |
224 |
|
225 |
implicit double precision (a-h,o-z) |
226 |
double precision x(n), g(n), z(nwcore) |
227 |
|
228 |
* ------------------------------------------------------------------ |
229 |
* This is funobj for problem t4manne. |
230 |
* |
231 |
* The data bt(*) is computed by t4con on its first entry. |
232 |
* |
233 |
* For test purposes, we look at Derivative level |
234 |
* and sometimes pretend that we don't know the first |
235 |
* three elements of the gradient. |
236 |
* ------------------------------------------------------------------ |
237 |
|
238 |
common /m1file/ iread,iprint,isumm |
239 |
common /m8diff/ difint(2),gdummy,lderiv,lvldif,knowng(2) |
240 |
common /manne / b,at(100),bt(100) |
241 |
|
242 |
intrinsic log |
243 |
logical gknown |
244 |
parameter ( zero = 0.0d+0 ) |
245 |
|
246 |
gknown = lderiv .eq. 1 .or. lderiv .eq. 3 |
247 |
nt = n/2 |
248 |
f = zero |
249 |
|
250 |
do 50 j = 1, nt |
251 |
xcon = x(nt+j) |
252 |
f = f + bt(j) * log(xcon) |
253 |
if (mode .eq. 2) then |
254 |
g(j) = zero |
255 |
if (gknown .or. j .gt. 3) g(nt+j) = bt(j) / xcon |
256 |
end if |
257 |
50 continue |
258 |
|
259 |
* end of t4obj (funobj for t4manne) |
260 |
end |
261 |
|
262 |
*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
263 |
|
264 |
subroutine t4con ( mode, m, n, njac, x, f, g, |
265 |
$ nstate, nprob, z, nwcore ) |
266 |
|
267 |
implicit double precision (a-h,o-z) |
268 |
double precision x(n), f(m), g(njac), z(nwcore) |
269 |
|
270 |
* ------------------------------------------------------------------ |
271 |
* This is funcon for problem t4manne. |
272 |
* |
273 |
* For test purposes, we look at Derivative level |
274 |
* and sometimes pretend that we don't know the first |
275 |
* three elements of the gradient. |
276 |
* ------------------------------------------------------------------ |
277 |
|
278 |
common /m1file/ iread,iprint,isumm |
279 |
common /m8diff/ difint(2),gdummy,lderiv,lvldif,knowng(2) |
280 |
common /manne / b,at(100),bt(100) |
281 |
|
282 |
logical gknown |
283 |
parameter ( one = 1.0d+0 ) |
284 |
|
285 |
gknown = lderiv .ge. 2 |
286 |
nt = n |
287 |
|
288 |
* --------------------------------------- |
289 |
* First entry. Define b, at(*) and bt(*) |
290 |
* for this and all subsequent entries. |
291 |
* --------------------------------------- |
292 |
if (nstate .eq. 1) then |
293 |
grow = 0.03 |
294 |
beta = 0.95 |
295 |
xk0 = 3.0 |
296 |
xc0 = 0.95 |
297 |
xi0 = 0.05 |
298 |
b = 0.25 |
299 |
if (iprint .gt. 0) write(iprint, 1000) nt, b |
300 |
|
301 |
a = (xc0 + xi0) / xk0**b |
302 |
gfac = (one + grow)**(one - b) |
303 |
at(1) = a*gfac |
304 |
bt(1) = beta |
305 |
|
306 |
do 10 j = 2, nt |
307 |
at(j) = at(j-1)*gfac |
308 |
bt(j) = bt(j-1)*beta |
309 |
10 continue |
310 |
|
311 |
bt(nt) = bt(nt) / (one - beta) |
312 |
end if |
313 |
|
314 |
* ------------- |
315 |
* Normal entry. |
316 |
* ------------- |
317 |
do 150 j = 1, nt |
318 |
xkap = x(j) |
319 |
f(j) = at(j) * xkap**b |
320 |
if (mode .eq. 2) then |
321 |
if (gknown .or. j .gt. 3) g(j) = b*f(j) / xkap |
322 |
end if |
323 |
150 continue |
324 |
|
325 |
* ------------ |
326 |
* Final entry. |
327 |
* ------------ |
328 |
if (nstate .ge. 2) then |
329 |
if (iprint .gt. 0) write(iprint, 2000) (f(j), j = 1, nt) |
330 |
end if |
331 |
return |
332 |
|
333 |
1000 format(// ' This is problem t4manne. nt =', i4, ' b =', f8.3) |
334 |
2000 format(// ' Final nonlinear function values' / (5f12.5)) |
335 |
|
336 |
* end of t4con (funcon for t4manne) |
337 |
end |
338 |
|
339 |
*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
340 |
|
341 |
subroutine t5obj ( mode, n, x, f, g, nstate, nprob, z, nwcore ) |
342 |
|
343 |
implicit double precision (a-h,o-z) |
344 |
double precision x(n), g(n), z(nwcore) |
345 |
|
346 |
* ------------------------------------------------------------------ |
347 |
* t5obj is funobj for the Weapon Assignment problem t5weapon. |
348 |
* It assumes the Specs file contains input data after the End card. |
349 |
* ------------------------------------------------------------------ |
350 |
|
351 |
common /m1file/ iread,iprint,isumm |
352 |
common /m2file/ iback,idump,iload,imps,inewb,insrt, |
353 |
$ ioldb,ipnch,iprob,iscr,isoln,ispecs,ireprt |
354 |
|
355 |
intrinsic log |
356 |
parameter ( nweapn = 5, ntargt = 20, zero = 0.0d+0 ) |
357 |
double precision q(nweapn,ntargt), ql(nweapn,ntargt), u(ntargt) |
358 |
save q , ql , u |
359 |
|
360 |
if (nstate .eq. 1) then |
361 |
* ---------------------------------------------------- |
362 |
* First entry. Read some data defining the objective. |
363 |
* ---------------------------------------------------- |
364 |
do 20 i = 1, nweapn |
365 |
read (ispecs, '(18f4.2)') (q(i,j), j = 1, ntargt) |
366 |
do 10 j = 1, ntargt |
367 |
ql(i,j) = log( q(i,j) ) |
368 |
10 continue |
369 |
20 continue |
370 |
|
371 |
read (ispecs, '(18f4.0)') u |
372 |
end if |
373 |
|
374 |
* ------------- |
375 |
* Normal entry. |
376 |
* ------------- |
377 |
k = 0 |
378 |
f = zero |
379 |
|
380 |
do 990 j = 1, ntargt |
381 |
t = u(j) |
382 |
do 960 i = 1, nweapn |
383 |
xk = x(k+i) |
384 |
if (xk .gt. zero) t = t * q(i,j)**xk |
385 |
960 continue |
386 |
|
387 |
if (mode .eq. 2) then |
388 |
do 970 i = 1, nweapn |
389 |
g(k+i) = t * ql(i,j) |
390 |
970 continue |
391 |
end if |
392 |
|
393 |
k = k + nweapn |
394 |
f = f + (t - u(j)) |
395 |
990 continue |
396 |
|
397 |
* end of t5obj (funobj for t5weapon) |
398 |
end |
399 |
|
400 |
*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
401 |
|
402 |
subroutine t6con ( mode, m, n, njac, x, f, g, |
403 |
$ nstate, nprob, z, nwcore ) |
404 |
|
405 |
implicit double precision (a-h,o-z) |
406 |
double precision x(n), f(m), g(m,n), z(nwcore) |
407 |
|
408 |
* ------------------------------------------------------------------ |
409 |
* t6con is funcon for test problem t6wood, |
410 |
* a chemical engineering design problem. |
411 |
* Originally called woplant (wood plant?). |
412 |
* m = 5, n = 10. |
413 |
* |
414 |
* For test purposes, we test Derivative level |
415 |
* to decide whether or not to compute gradients. |
416 |
* |
417 |
* Dec 1981: Original MINOS version obtained via Bruce Murtagh. |
418 |
* Oct 1991: Converted to f77 for test problem t6wood. |
419 |
* ------------------------------------------------------------------ |
420 |
|
421 |
common /m1file/ iread,iprint,isumm |
422 |
common /m8diff/ difint(2),gdummy,lderiv,lvldif,knowng(2) |
423 |
|
424 |
parameter (one = 1.0d+0, two = 2.0d+0, |
425 |
$ three = 3.0d+0, four = 4.0d+0, |
426 |
$ half = 0.5d+0, tenk = 10000.0d+0, vrho = 3000.0d+0) |
427 |
|
428 |
if (nstate .eq. 1) then |
429 |
if (iprint .gt. 0) write(iprint, 5) lderiv |
430 |
if (isumm .gt. 0) write(isumm , 5) lderiv |
431 |
5 format(/ ' This is problem t6wood. Derivative level =', i3 /) |
432 |
end if |
433 |
|
434 |
* Transform to original variables. |
435 |
|
436 |
fg = tenk*(one + x(1)) |
437 |
fp = tenk*(one + x(2)) |
438 |
fd = tenk*(one + x(3)) |
439 |
fra = tenk*(one + x(4)) |
440 |
frp = tenk*(one + x(5)) |
441 |
fre = tenk*(one + x(6)) |
442 |
frb = tenk*(one + x(7)) |
443 |
frc = tenk*(one + x(8)) |
444 |
fr = tenk*(one + x(9)) |
445 |
temp = 630.0d+0 + 50.0d+0*x(10) |
446 |
|
447 |
* Rate constants. |
448 |
|
449 |
ak1 = 5.9755d+09 * dexp(-1.2d+4/temp) |
450 |
ak2 = 2.5962d+12 * dexp(-1.5d+4/temp) |
451 |
ak3 = 9.6283d+15 * dexp(-2.0d+4/temp) |
452 |
|
453 |
* Rate terms. |
454 |
|
455 |
fr2 = fr**2 |
456 |
r1 = ak1*fra*frb*vrho/fr2 |
457 |
r2 = ak2*frb*frc*vrho/fr2 |
458 |
r3 = ak3*frc*frp*vrho/fr2 |
459 |
|
460 |
* Nonlinear functions. |
461 |
|
462 |
recip = one/(fr - fg - fp) |
463 |
f(1) = two*r2 - fd*recip*fre |
464 |
f(2) = r2 - half*r3 - fd*recip*(frp - fp) - fp |
465 |
f(3) = - r1 - fd*recip*fra |
466 |
f(4) = - r1 - r2 - fd*recip*frb |
467 |
f(5) = 1.5d+0*r3 - fg |
468 |
|
469 |
* Scale them. |
470 |
|
471 |
do 10 i = 1, m |
472 |
f(i) = f(i) / tenk |
473 |
10 continue |
474 |
|
475 |
* Compute the Jacobian (if MINOS wants it). |
476 |
|
477 |
if (mode .eq. 0 .or. lderiv .lt. 2) return |
478 |
|
479 |
b1t = 1.2d+4/temp**2 |
480 |
b2t = 1.5d+4/temp**2 |
481 |
b3t = 2.0d+4/temp**2 |
482 |
rr = recip**2 |
483 |
|
484 |
g(1,1) = - fd*fre*rr |
485 |
g(1,2) = g(1,1) |
486 |
g(1,3) = - fre*recip |
487 |
g(1,6) = - fd *recip |
488 |
g(1,7) = two*r2/frb |
489 |
g(1,8) = two*r2/frc |
490 |
g(1,9) = - four*r2/fr - g(1,1) |
491 |
g(1,10)= two*r2*b2t |
492 |
|
493 |
g(2,1) = - fd*(frp - fp)*rr |
494 |
g(2,2) = fd*(fr - frp - fg)*rr - one |
495 |
g(2,3) = - (frp - fp)*recip |
496 |
g(2,5) = - half*r3/frp - fd*recip |
497 |
g(2,7) = r2/frb |
498 |
g(2,8) = (r2 - half*r3)/frc |
499 |
g(2,9) = - two*(r2 - half*r3)/fr - g(2,1) |
500 |
g(2,10)= r2*b2t - half*r3*b3t |
501 |
|
502 |
g(3,1) = - fd*fra*rr |
503 |
g(3,2) = g(3,1) |
504 |
g(3,3) = - fra*recip |
505 |
g(3,4) = - r1/fra - fd*recip |
506 |
g(3,7) = - r1/frb |
507 |
g(3,9) = two*r1/fr - g(3,1) |
508 |
g(3,10)= - r1*b1t |
509 |
|
510 |
g(4,1) = - fd*frb*rr |
511 |
g(4,2) = g(4,1) |
512 |
g(4,3) = - frb*recip |
513 |
g(4,4) = - r1/fra |
514 |
g(4,7) = - (r1 + r2)/frb - fd*recip |
515 |
g(4,8) = - r2/frc |
516 |
g(4,9) = two*(r1+r2)/fr - g(4,1) |
517 |
g(4,10)= - r1*b1t - r2*b2t |
518 |
|
519 |
g(5,1) = - 1.0d+0 |
520 |
g(5,5) = 1.5d+0*r3/frp |
521 |
g(5,8) = 1.5d+0*r3/frc |
522 |
g(5,9) = - three *r3/fr |
523 |
g(5,10)= 1.5d+0*r3*b3t |
524 |
|
525 |
* Rescale the temperature derivatives. |
526 |
|
527 |
do 20 i = 1, m |
528 |
g(i,10) = g(i,10) * 5.0d-3 |
529 |
20 continue |
530 |
|
531 |
* end of t6con (funcon for Chemical Design Problem woplant) |
532 |
end |
533 |
|
534 |
*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
535 |
|
536 |
subroutine t7obj ( mode, n, x, f, g, nstate, nprob, z, nwcore ) |
537 |
|
538 |
implicit double precision (a-h,o-z) |
539 |
double precision x(n), g(n), z(nwcore) |
540 |
|
541 |
* ------------------------------------------------------------------ |
542 |
* t7obj is funobj for Alan Manne's energy model ETAMACRO. |
543 |
* ------------------------------------------------------------------ |
544 |
|
545 |
common /m1file/ iread,iprint,isumm |
546 |
|
547 |
intrinsic log |
548 |
parameter ( maxt = 16, zero = 0.0d+0, one = 1.0d+0 ) |
549 |
|
550 |
double precision a1, b1, alpha, beta, rho, rate, esub, refp |
551 |
save a1, b1, alpha, beta, rho, rate, esub, refp |
552 |
|
553 |
double precision deltat(maxt), zks(maxt), zls(maxt), zes(maxt), |
554 |
$ zns (maxt), zys(maxt), zlb(maxt) |
555 |
save deltat , zks , zls , zes , |
556 |
$ zns , zys , zlb |
557 |
|
558 |
data zlb / 1.160d+0, 1.446d+0, 1.717d+0, 2.039d+0, |
559 |
$ 2.364d+0, 2.740d+0, 3.101d+0, 3.508d+0, |
560 |
$ 3.873d+0, 4.276d+0, 4.721d+0, 5.213d+0, |
561 |
$ 5.755d+0, 6.354d+0, 7.016d+0, 7.746d+0/ |
562 |
|
563 |
data rate / 10.000d+0 /, esub / 0.2000d+0 /, |
564 |
$ beta / 0.4000d+0 /, alpha / 0.3333d+0 /, |
565 |
$ refp / 0.8000d+0 / |
566 |
|
567 |
if (nstate .eq. 1) then |
568 |
* ---------------------------------------------------- |
569 |
* First entry. Define some data. |
570 |
* ---------------------------------------------------- |
571 |
spda = 0.96d+0 |
572 |
s5 = spda**5 |
573 |
rho = (esub - one) / esub |
574 |
delta = one / (one + rate/100) |
575 |
|
576 |
* Compute coefficients a1, b1 with given data at 1970. |
577 |
|
578 |
zel = 1.650d+0 |
579 |
zne = 0.509d+0 |
580 |
pn = 0.080d+0 |
581 |
gnp = 1.360d+0 |
582 |
zkp = 2.5d+0 * gnp |
583 |
y = gnp + zne * pn / (one - beta) |
584 |
b1 = pn * y**(rho - one) / (one - beta) |
585 |
$ * zel**(-rho*beta) |
586 |
$ * zne**(one - rho*(one - beta)) |
587 |
a1 = b1 * zel**( rho*beta) * zne**(rho*(one - beta)) |
588 |
a1 = (y**rho - a1) / zkp**(alpha*rho) |
589 |
if (iprint .gt. 0) then |
590 |
write(iprint, '(/ 1p, a , e16.8, 4x, a , e16.8)') |
591 |
$ ' a =', a1 , ' b =', b1 |
592 |
end if |
593 |
|
594 |
* Compute deltat(j). |
595 |
|
596 |
d5 = delta**5 |
597 |
deltat(1) = 1000 |
598 |
do 130 j = 2, maxt |
599 |
deltat(j) = deltat(j-1) * d5 |
600 |
130 continue |
601 |
deltat(maxt) = deltat(maxt) / (one - d5) |
602 |
|
603 |
* Compute surviving quantities. |
604 |
|
605 |
do 140 j = 1, maxt |
606 |
s5j = s5**j |
607 |
zys(j) = y * s5j |
608 |
zks(j) = zkp * s5j |
609 |
zls(j) = (zlb(j) - s5j)**(one - alpha) |
610 |
zes(j) = zel * s5j |
611 |
zns(j) = zne * s5j |
612 |
140 continue |
613 |
end if |
614 |
|
615 |
* ------------------------------------------- |
616 |
* Normal entry. |
617 |
* Some output is produced on the final entry. |
618 |
* ------------------------------------------- |
619 |
if (nstate .eq. 2) then |
620 |
if (iprint .gt. 0) then |
621 |
write(iprint, '(/ a / a)') |
622 |
$ ' Time series of Gross Output, Annual Consumption and', |
623 |
$ ' Cumulative Consumption discounted at 5% and 10% are' |
624 |
end if |
625 |
end if |
626 |
|
627 |
f = zero |
628 |
cdc5 = zero |
629 |
cdc10 = zero |
630 |
|
631 |
do 190 j = 1, maxt |
632 |
j1 = j |
633 |
j2 = j1 + maxt |
634 |
j3 = j2 + maxt |
635 |
j4 = j3 + maxt |
636 |
j5 = j4 + maxt |
637 |
dxk = x(j1) - zks(j) |
638 |
dxe = x(j2) - zes(j) |
639 |
dxn = x(j3) - zns(j) |
640 |
r = (dxk**alpha * zls(j))**rho |
641 |
e = ((dxe/dxn)**beta * dxn)**rho |
642 |
d = (a1*r + b1*e)**(one/rho) |
643 |
y = zys(j) + d |
644 |
c = y - x(j4) - x(j5) |
645 |
f = f + deltat(j) * log(c) |
646 |
|
647 |
if (nstate .eq. 2) then |
648 |
it = 5*(j - 1) |
649 |
cdc5 = cdc5 + 5*(one / 1.05d+0)**it * c |
650 |
cdc10 = cdc10 + 5*(one / 1.10d+0)**it * c |
651 |
iyr = 1975 + it |
652 |
if (iprint .gt. 0) then |
653 |
write(iprint, '(i5, 4f9.3)') iyr, y, c, cdc5, cdc10 |
654 |
end if |
655 |
end if |
656 |
|
657 |
* Compute the gradient. |
658 |
|
659 |
dc = deltat(j) / c |
660 |
d = dc * d**(one - rho) |
661 |
g(j1) = d * a1 * r * alpha / dxk |
662 |
g(j2) = d * b1 * e * beta / dxe |
663 |
g(j3) = d * b1 * e * (one - beta) / dxn |
664 |
g(j4) = - dc |
665 |
g(j5) = g(j4) |
666 |
190 continue |
667 |
|
668 |
* end of t7obj (funobj for ETAMACRO) |
669 |
end |