freev Subroutine

private subroutine freev(n, Nfree, Index, Nenter, Ileave, Indx2, Iwhere, Wrk, Updatd, Cnstnd, Iprint, Iter)

This subroutine counts the entering and leaving variables when iter > 0, and finds the index set of free and active variables at the GCP.

Credits

  • NEOS, November 1994. (Latest revision June 1996.) Optimization Technology Center. Argonne National Laboratory and Northwestern University. Written by Ciyou Zhu in collaboration with R.H. Byrd, P. Lu-Chen and J. Nocedal.

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: n
integer, intent(inout) :: Nfree
integer, intent(inout) :: Index(n)
  • for i=1,...,nfree, index(i) are the indices of free variables
  • for i=nfree+1,...,n, index(i) are the indices of bound variables

  • On entry after the first iteration, index gives the free variables at the previous iteration.

  • On exit it gives the free variables based on the determination in cauchy using the array iwhere.
integer, intent(out) :: Nenter
integer, intent(out) :: Ileave
integer, intent(inout) :: Indx2(n)
  • On entry indx2 is unspecified.
  • On exit with iter>0, indx2 indicates which variables have changed status since the previous iteration.

  • For i= 1,...,nenter, indx2(i) have changed from bound to free.

  • For i= ileave+1,...,n, indx2(i) have changed from free to bound.
integer, intent(in) :: Iwhere(n)
logical, intent(out) :: Wrk
logical, intent(in) :: Updatd
logical, intent(in) :: Cnstnd

indicating whether bounds are present

integer, intent(in) :: Iprint

Controls the frequency and type of output generated

integer, intent(in) :: Iter

Called by

proc~~freev~~CalledByGraph proc~freev lbfgsb_module::freev proc~mainlb lbfgsb_module::mainlb proc~mainlb->proc~freev proc~setulb lbfgsb_module::setulb proc~setulb->proc~mainlb

Source Code

      subroutine freev(n,Nfree,Index,Nenter,Ileave,Indx2,Iwhere,Wrk, &
                       Updatd,Cnstnd,Iprint,Iter)
      implicit none

      integer,intent(in) :: n
      integer,intent(inout) :: Nfree
      integer,intent(out) :: Nenter
      integer,intent(out) :: Ileave
      integer,intent(in) :: Iprint !! Controls the frequency and type of output generated
      integer,intent(in) :: Iter
      integer,intent(inout) :: Index(n) !! * for i=1,...,nfree, index(i) are the indices of free variables
                                        !! * for i=nfree+1,...,n, index(i) are the indices of bound variables
                                        !!
                                        !! * On entry after the first iteration, index gives
                                        !!   the free variables at the previous iteration.
                                        !! * On exit it gives the free variables based on the determination
                                        !!   in cauchy using the array iwhere.
      integer,intent(inout) :: Indx2(n) !! * On entry indx2 is unspecified.
                                        !! * On exit with iter>0, indx2 indicates which variables
                                        !!    have changed status since the previous iteration.
                                        !!
                                        !! * For i= 1,...,nenter, indx2(i) have changed from bound to free.
                                        !! * For i= ileave+1,...,n, indx2(i) have changed from free to bound.
      integer,intent(in) :: Iwhere(n)
      logical,intent(out) :: Wrk
      logical,intent(in) :: Updatd
      logical,intent(in) :: Cnstnd !! indicating whether bounds are present

      integer :: iact , i , k

      Nenter = 0
      Ileave = n + 1
      if ( Iter>0 .and. Cnstnd ) then
         ! count the entering and leaving variables.
         do i = 1 , Nfree
            k = Index(i)

            ! write(output_unit,*) ' k  = index(i) ', k
            ! write(output_unit,*) ' index = ', i

            if ( Iwhere(k)>0 ) then
               Ileave = Ileave - 1
               Indx2(Ileave) = k
               if ( Iprint>=100 ) write (output_unit,*) 'Variable ' , k , &
                   &' leaves the set of free variables'
            endif
         enddo
         do i = 1 + Nfree , n
            k = Index(i)
            if ( Iwhere(k)<=0 ) then
               Nenter = Nenter + 1
               Indx2(Nenter) = k
               if ( Iprint>=100 ) write (output_unit,*) 'Variable ' , k , &
                   &' enters the set of free variables'
            endif
         enddo
         if ( Iprint>=99 ) write (output_unit,*) n + 1 - Ileave , &
                                   &' variables leave; ' , Nenter , &
                                   &' variables enter'
      endif
      Wrk = (Ileave<n+1) .or. (Nenter>0) .or. Updatd

      ! Find the index set of free and active variables at the GCP.

      Nfree = 0
      iact = n + 1
      do i = 1 , n
         if ( Iwhere(i)<=0 ) then
            Nfree = Nfree + 1
            Index(Nfree) = i
         else
            iact = iact - 1
            Index(iact) = i
         endif
      enddo
      if ( Iprint>=99 ) write (output_unit,*) Nfree , &
                                    ' variables are free at GCP ' , &
                                    Iter + 1

      end subroutine freev