protected void optimize1() throws Exception {
    //% main routine for modification 1 procedure main
    //  while (numChanged > 0 || examineAll)
    //    numChanged = 0; 
    int nNumChanged = 0;
    boolean bExamineAll = true;
    //  while (numChanged > 0 || examineAll)
    //    numChanged = 0; 
    while (nNumChanged > 0 || bExamineAll) {
      nNumChanged = 0;
      //    if (examineAll)
      //      loop I over all the training examples
      //        numChanged += examineExample(I) 
      //    else
      //      loop I over I.0
      //        numChanged += examineExample(I) 
      //        % It is easy to check if optimality on I.0 is attained... 
      //        if (b.up > b.low - 2*tol) at any I
      //          exit the loop after setting numChanged = 0 
      //        endif 
      if (bExamineAll) {
	for (int i = 0; i < m_nInstances; i++) {
	  nNumChanged += examineExample(i);
	}
      } else {
	for (int i = m_I0.getNext(-1); i != -1; i = m_I0.getNext(i)) {
	  
	  nNumChanged += examineExample(i);
	  if (m_bLow - m_bUp < 2 * m_fTolerance) {
	    nNumChanged = 0;
	    break;
	  }
	}
      } //    if (examineAll == 1)
      //      examineAll = 0; 
      //    elseif (numChanged == 0)
      //      examineAll = 1;
      //    endif 
      //  endwhile 
      //endprocedure
      if (bExamineAll) {
	bExamineAll = false;
      } else if (nNumChanged == 0) {
	bExamineAll = true;
      }
    }
  }