anchor.diff:        pos(2, dim) = ysum / real(dim - 2)
         
   end subroutine
  +
  +!! finds centroid position for salesman
  +subroutine centroid_sales(weights, min, dim)
  +      implicit none
  +      real*8, intent(inout)  :: weights(:,:)
  +      integer, intent(in)    :: min, dim
  +      integer                :: i, j
  +
  +
  +      do i = 1,dim - 1
  +          if (i.NE.min) then
  +              do j = 1, dim - 1
  +                  weights(dim, j) = weights(dim, j) + weights(i, j)
  +              end do
  +          end if
  +      end do
  +
  +      do i = 1, dim - 1
  +          weights(dim, j) = weights(dim, j) / (dim - 1)
  +      end do
  +
  +end subroutine
  +
   
   !! minimum currently set to 0.5, should be found via Downhill Simplex!
   subroutine findval(pos, value, dim)
  
positive.code:       end do
  
        !! initialize each new position
        do i = 1, dim
            theta = i * 2 * 3.14159 / dim
            pos(1,i) = cos(theta)
            pos(2,i) = sqrt(1 - (pos(1,i) * pos(1,i)))
        end do
  
  end subroutine
  
negative.code:       pos(1,min) = (1 - gamma) * pos(1,dim) + gamma * pos(1, min)
        pos(2,min) = (1 - gamma) * pos(2,dim) + gamma * pos(2, min)
  
  end subroutine
  
  !! for Nelder Mead expansions for salesman
  pure subroutine expand_sales(weights, min, dim, gamma)
        implicit none
        real*8, dimension(:,:), intent(inout) :: weights
        integer, intent(in)                   :: min, dim
        real*8, intent(in)                    :: gamma
        integer                               :: i
  
        do i = 1, dim - 1
            weights(min,i) = (1 - gamma)*weights(dim,i) + gamma*weights(min, i)
        end do
  
  end subroutine
  
  