⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dirserial.f

📁 优化问题中的直接搜索法
💻 F
字号:
C+-----------------------------------------------------------------------+C| Program       : Direct.f (subfile DIRserial.f)                        |C| Last modified : 04-12-2001                                            |C| Written by    : Joerg Gablonsky                                       |C| SUBROUTINEs, which differ depENDing on the serial or parallel version.|C+-----------------------------------------------------------------------+C+-----------------------------------------------------------------------+C| SUBROUTINE for sampling.                                              |C+-----------------------------------------------------------------------+      SUBROUTINE DIRSamplef(c,ArrayI,delta,sample,new,length,     +           dwrit,logfile,f,free,maxI,point,fcn,x,l,fmin,     +           minpos,u,n,maxfunc,maxdeep,oops,fmax,     +            IFeasiblef,IInfesiblef,     +           iidata, iisize, ddata, idsize, cdata, icsize)       IMPLICIT NONEC+-----------------------------------------------------------------------+C| JG 07/16/01 fcn must be declared external.                            |C+-----------------------------------------------------------------------+      EXTERNAL fcn      INTEGER n,maxfunc,maxdeep,oops      INTEGER maxI,ArrayI(n),sample,new      INTEGER length(maxfunc,n),free,point(maxfunc),iC+-----------------------------------------------------------------------+C| JG 07/16/01 Removed fcn.                                              |C+-----------------------------------------------------------------------+      DOUBLE PRECISION c(maxfunc,n),delta,x(n)      DOUBLE PRECISION l(n),u(n),f(maxfunc,2)      DOUBLE PRECISION fmin      INTEGER pos,j,dwrit,logfile,minpos      INTEGER helppoint,kretC+-----------------------------------------------------------------------+C| JG 01/22/01 Added variable to keep track of the maximum value found.  |C|             Added variable to keep track IF feasible point was found. |C+-----------------------------------------------------------------------+      DOUBLE PRECISION fmax      INTEGER  IFeasiblef,IInfesiblefC+-----------------------------------------------------------------------+C| Variables to pass user defined data to the function to be optimized.  |C+-----------------------------------------------------------------------+      INTEGER iisize, idsize, icsize      INTEGER iidata(iisize)      DOUBLE PRECISION ddata(idsize)      CHARACTER*40 cdata(icsize)      C+-----------------------------------------------------------------------+C| Set the pointer to the first function to be evaluated,                |C| store this position also in helppoint.                                |C+-----------------------------------------------------------------------+      pos = new      helppoint = posC+-----------------------------------------------------------------------+C| Iterate over all points, where the function should be                 |C| evaluated.                                                            |C+-----------------------------------------------------------------------+      DO 40,j=1,maxI + maxIC+-----------------------------------------------------------------------+C| Copy the position into the helparrayy x.                              |C+-----------------------------------------------------------------------+         DO 60,i=1,n           x(i) = c(pos,i)60       CONTINUEC+-----------------------------------------------------------------------+C| Call the function.                                                    |C+-----------------------------------------------------------------------+         CALL DIRinfcn(fcn,x,l,u,n,f(pos,1),kret,     +                 iidata, iisize, ddata, idsize, cdata, icsize)C+-----------------------------------------------------------------------+C| Remember IF an infeasible point has been found.                       |C+-----------------------------------------------------------------------+         IInfesiblef = max(IInfesiblef,kret)         IF (kret .eq. 0) thenC+-----------------------------------------------------------------------+C| IF the function evaluation was O.K., set the flag in                  |C| f(pos,2). Also mark that a feasible point has been found.             |C+-----------------------------------------------------------------------+           f(pos,2) = 0.D0            IFeasiblef = 0C+-----------------------------------------------------------------------+C| JG 01/22/01 Added variable to keep track of the maximum value found.  |C+-----------------------------------------------------------------------+           fmax = max(f(pos,1),fmax)         END if         IF (kret .ge. 1) thenC+-----------------------------------------------------------------------+C|  IF the function could not be evaluated at the given point,            |C| set flag to mark this (f(pos,2) and store the maximum                 |C| box-sidelength in f(pos,1).                                           |C+-----------------------------------------------------------------------+           f(pos,2) = 2.D0           f(pos,1) = fmax         END ifC+-----------------------------------------------------------------------+C|  IF the function could not be evaluated due to a failure in            |C| the setup, mark this.                                                 |C+-----------------------------------------------------------------------+         IF (kret .eq. -1) then           f(pos,2) = -1.D0         END ifC+-----------------------------------------------------------------------+C| Set the position to the next point, at which the function             |C| should e evaluated.                                                   |C+-----------------------------------------------------------------------+         pos = point(pos)40    CONTINUE      pos = helppointC+-----------------------------------------------------------------------+C| Iterate over all evaluated points and see, IF the minimal             |C| value of the function has changed.  IF this has happEND,               |C| store the minimal value and its position in the array.                |C| Attention: Only valied values are checked!!                           |C+-----------------------------------------------------------------------+      DO 50,j=1,maxI + maxI        IF ((f(pos,1) .LT. fmin) .and. (f(pos,2) .eq. 0)) THEN          fmin = f(pos,1)           minpos = pos        END IF        pos = point(pos)50    CONTINUE      ENDC+-----------------------------------------------------------------------+C| Problem-specific Initialisation                                       |C+-----------------------------------------------------------------------+      SUBROUTINE DIRInitSpecific(x,n,     +   iidata, iisize, ddata, idsize, cdata, icsize)      IMPLICIT NONE      INTEGER n      DOUBLE PRECISION x(n)C+-----------------------------------------------------------------------+C| Variables to pass user defined data to the function to be optimized.  |C+-----------------------------------------------------------------------+      INTEGER iisize, idsize, icsize      INTEGER iidata(iisize)      DOUBLE PRECISION ddata(idsize)      CHARACTER*40 cdata(icsize)C+-----------------------------------------------------------------------+C| Problem - specific variables !                                        |C+-----------------------------------------------------------------------+C+-----------------------------------------------------------------------+C| END of problem - specific variables !                                 |C+-----------------------------------------------------------------------+C+-----------------------------------------------------------------------+C| Start of problem-specific initialisation                              |C+-----------------------------------------------------------------------+C+-----------------------------------------------------------------------+C| END of problem-specific initialisation                                |C+-----------------------------------------------------------------------+      END

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -