
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% private_90_ROUTINE
%
%
%
%
%
% Ported to Matlab by Jason Lott, University of Alabama at Birmingham
% CONTACT:hoffa@uab.edu
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


function a = private_90_ROUTINE(b)					%again, really just a script

global X
global XMAX
global XMIN
global DELTX
global DELMIN
global ERR
global FOBJ
global VEC
global DLX
global XS
global FSTORE
global DX
global SALVO
global XOSC
global FOSC
global ARG
global STCUT
global ACK
global FACUP
global RZERO
global XPLUS
global FSAVE
global FBEST
global XSAVE
global ABSDX
global FPREV
global DENOM
global DEL
global DXZ
global DXU
global DFZ
global DFU
global ABSVEC
global SUMV
global CINDER
global COXCOM
global COSIN
global STEPS
global J
global JFLAT
global JFLMIN
global JOCK
global JUMP
global JVARY
global JX
global K
global KERFEL
global KL
global KW
global MASK
global MATRX
global MINSOC
global MAXOSC
global MAXSTP
global NACK
global NACTIV
global NAH
global NCIRC
global NEQUAL
global NF
global NFLAT
global NFMAX
global NFSAV
global NGATE
global NGIANT
global NONZER
global NOREP
global NOSC
global NOUT
global NRETRY
global NSSW
global NSTEPS
global NT
global NTRACE
global NV
global NEXTRA
global NZIP
global tag_380
global tag_390
global wtag
global tag
global continueflag
global T
global Y
global YSIG
global grandtag
global KFLAG
global DX
global XS
global DLX
global fortag
global KFLAGENCOUNTER



XPLUS = X(JX);

X(JX) = XSAVE-DX(JX);



if (X(JX)>=XMIN(JX))&(X(JX)<=XMAX(JX))
   
   private_FUNK(1);
   NF = NF + 1;
   JVARY = JX;
   
   
   if FOBJ<FBEST
      
      DX(JX) = -DX(JX);
      NCIRC = 0;
      NSTEPS = 0;
      DEL = DX(JX);
     
      wtag  = 1;
      
      while wtag == 1
         
         FPREV = FBEST;
         FBEST = FOBJ;
         VEC(JX) = VEC(JX) + DEL/ABSDX;
         DLX(JX) = DLX(JX) + DEL;
         NSTEPS = NSTEPS + 1;
         
         if NSTEPS>=MAXSTP
            
            JOCK = 1
            private_210_ROUTINE;
            wtag = 0;												%Kicks me out of this damn while loop, to continue in big FOR loop
            continueflag = 0;
                             
         else
            
            DEL = ACK*DEL;
            XPLUS = XSAVE;
            XSAVE = X(JX);
            X(JX) = XSAVE + DEL;
                           
            if (X(JX)<XMIN(JX))|(X(JX)>XMAX(JX))
               
               X(JX) = XSAVE;
               private_210_ROUTINE;
               wtag = 0;											%Kicks me out of this damn while loop, to continue in big FOR loop
               continueflag = 0;
                              
            else
               
               private_FUNK(1);
               NF = NF +1;
                                 
               if FOBJ<FBEST
                  
                  wtag = 1;										%Continue in while loop
                  
               else
                  
                  wtag = 0;										%Kicks me out of this damn while loop, to continue with next statements
                  continueflag =1;
                                    
               end
               
            end
            
         end
         
      end
      
      if continueflag == 1
         
         DXZ = XSAVE-XPLUS;
         DXU = X(JX)-XSAVE;
         DFZ = FBEST-FPREV;
         DFU = FOBJ-FBEST;
         DENOM = DFZ*DXU-DFU*DXZ;
         
         if DENOM == RZERO
            
            X(JX) = XSAVE;
            private_210_ROUTINE(1);
            
         else
            
            DEL = (DFZ*DXU^2+DFU*DXZ^2)/(DENOM+DENOM);
            X(JX)=XSAVE+DEL;
                              
            if X(JX) == XSAVE
              
               private_210_ROUTINE(1);
               
            else
               
               private_FUNK(1);
               NF = NF +1;
                                 
               if FOBJ>=FBEST
                  
                  X(JX) = XSAVE;
                  private_210_ROUTINE(1);
                                    
               else
                  
                  FBEST = FOBJ;
                  DLX(JX) = DLX(JX) + DEL;
                  VEC(JX) = VEC(JX) + DEL/ABSDX;
                  JOCK = 1;
                  private_210_ROUTINE(1);
                  
               end
               
            end
            
         end
         
      end
      
   else
      
      if FOBJ == FBEST
         
         NEQUAL = NEQUAL + 1;
         
      end
      private_110_ROUTINE(1);
      
   end
   
else
   
   NOUT = NOUT + 1;
   private_110_ROUTINE(1);
         
end

    
       



































































































