public final double doOperation() throws OperatorFailedException {
  int randomSite=(int)(Math.random() * siteCount);
  int currentCategory=(int)categoryParameter.getParameterValue(randomSite);
  siteModel.subtractSitesInCategoryCount(currentCategory);
  int[] temp=new int[categoryCount - 1];
  int count=0;
  for (int i=0; i < categoryCount; i++) {
    if (i != currentCategory) {
      temp[count]=i;
      count++;
    }
  }
  int newCategory=temp[(int)(Math.random() * temp.length)];
  categoryParameter.setParameterValue(randomSite,newCategory);
  siteModel.addSitesInCategoryCount(newCategory);
  return 0.0;
}

public final double doOperation ( ) throws OperatorFailedException { int randomSite = ( int ) ( Math . random ( ) * siteCount ) ; int currentCategory = ( int ) categoryParameter . getParameterValue ( randomSite ) ; siteModel . subtractSitesInCategoryCount ( currentCategory ) ; int [ ] temp = new int [ categoryCount - 1 ] ; int count = 0 ; for ( int i = 0 ; i < categoryCount ; i ++ ) { if ( i != currentCategory ) { temp [ count ] = i ; count ++ ; } } int newCategory = temp [ ( int ) ( Math . random ( ) * temp . length ) ] ; categoryParameter . setParameterValue ( randomSite , newCategory ) ; siteModel . addSitesInCategoryCount ( newCategory ) ; return 0.0 ; }
alter the category of one site
