GNU Octave 10.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 
Loading...
Searching...
No Matches
dcnstr.f
Go to the documentation of this file.
1C Work performed under the auspices of the U.S. Department of Energy
2C by Lawrence Livermore National Laboratory under contract number
3C W-7405-Eng-48.
4C
5 SUBROUTINE dcnstr (NEQ, Y, YNEW, ICNSTR, TAU, RLX, IRET, IVAR)
6C
7C***BEGIN PROLOGUE DCNSTR
8C***DATE WRITTEN 950808 (YYMMDD)
9C***REVISION DATE 950814 (YYMMDD)
10C
11C
12C-----------------------------------------------------------------------
13C***DESCRIPTION
14C
15C This subroutine checks for constraint violations in the proposed
16C new approximate solution YNEW.
17C If a constraint violation occurs, then a new step length, TAU,
18C is calculated, and this value is to be given to the linesearch routine
19C to calculate a new approximate solution YNEW.
20C
21C On entry:
22C
23C NEQ -- size of the nonlinear system, and the length of arrays
24C Y, YNEW and ICNSTR.
25C
26C Y -- real array containing the current approximate y.
27C
28C YNEW -- real array containing the new approximate y.
29C
30C ICNSTR -- INTEGER array of length NEQ containing flags indicating
31C which entries in YNEW are to be constrained.
32C if ICNSTR(I) = 2, then YNEW(I) must be .GT. 0,
33C if ICNSTR(I) = 1, then YNEW(I) must be .GE. 0,
34C if ICNSTR(I) = -1, then YNEW(I) must be .LE. 0, while
35C if ICNSTR(I) = -2, then YNEW(I) must be .LT. 0, while
36C if ICNSTR(I) = 0, then YNEW(I) is not constrained.
37C
38C RLX -- real scalar restricting update, if ICNSTR(I) = 2 or -2,
39C to ABS( (YNEW-Y)/Y ) < FAC2*RLX in component I.
40C
41C TAU -- the current size of the step length for the linesearch.
42C
43C On return
44C
45C TAU -- the adjusted size of the step length if a constraint
46C violation occurred (otherwise, it is unchanged). it is
47C the step length to give to the linesearch routine.
48C
49C IRET -- output flag.
50C IRET=0 means that YNEW satisfied all constraints.
51C IRET=1 means that YNEW failed to satisfy all the
52C constraints, and a new linesearch step
53C must be computed.
54C
55C IVAR -- index of variable causing constraint to be violated.
56C
57C-----------------------------------------------------------------------
58 IMPLICIT DOUBLE PRECISION(a-h,o-z)
59 dimension y(neq), ynew(neq), icnstr(neq)
60 SAVE fac, fac2, zero
61 DATA fac /0.6d0/, fac2 /0.9d0/, zero/0.0d0/
62C-----------------------------------------------------------------------
63C Check constraints for proposed new step YNEW. If a constraint has
64C been violated, then calculate a new step length, TAU, to be
65C used in the linesearch routine.
66C-----------------------------------------------------------------------
67 iret = 0
68 rdymx = zero
69 ivar = 0
70 DO 100 i = 1,neq
71C
72 IF (icnstr(i) .EQ. 2) THEN
73 rdy = abs( (ynew(i)-y(i))/y(i) )
74 IF (rdy .GT. rdymx) THEN
75 rdymx = rdy
76 ivar = i
77 ENDIF
78 IF (ynew(i) .LE. zero) THEN
79 tau = fac*tau
80 ivar = i
81 iret = 1
82 RETURN
83 ENDIF
84C
85 ELSEIF (icnstr(i) .EQ. 1) THEN
86 IF (ynew(i) .LT. zero) THEN
87 tau = fac*tau
88 ivar = i
89 iret = 1
90 RETURN
91 ENDIF
92C
93 ELSEIF (icnstr(i) .EQ. -1) THEN
94 IF (ynew(i) .GT. zero) THEN
95 tau = fac*tau
96 ivar = i
97 iret = 1
98 RETURN
99 ENDIF
100C
101 ELSEIF (icnstr(i) .EQ. -2) THEN
102 rdy = abs( (ynew(i)-y(i))/y(i) )
103 IF (rdy .GT. rdymx) THEN
104 rdymx = rdy
105 ivar = i
106 ENDIF
107 IF (ynew(i) .GE. zero) THEN
108 tau = fac*tau
109 ivar = i
110 iret = 1
111 RETURN
112 ENDIF
113C
114 ENDIF
115 100 CONTINUE
116
117 IF(rdymx .GE. rlx) THEN
118 tau = fac2*tau*rlx/rdymx
119 iret = 1
120 ENDIF
121C
122 RETURN
123C----------------------- END OF SUBROUTINE DCNSTR ----------------------
124 END
subroutine dcnstr(neq, y, ynew, icnstr, tau, rlx, iret, ivar)
Definition dcnstr.f:6