亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? partition.java

?? clustering data for the different techniques of data mining
?? JAVA
?? 第 1 頁 / 共 5 頁
字號:
/*
  Partition.java
  
  Definition of the class Partition
  
  (P)2002  Dana Cristofor

*/

/*

GAClust - Clustering categorical databases using genetic algorithms
Copyright (C) 2002  Dana Cristofor


This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at
your option) any later version.

This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
USA

GAClust was written by Dana Cristofor (dana@cs.umb.edu).

*/

import java.util.*;
import java.text.*;

/**
 * Partition
 *
 * @version 	1.0
 * @author	Dana Cristofor
 */
public class Partition
{
  protected int classFitnessType;
  protected int[] v;  // array of integers
  protected int size; // no. of elements

  protected int maxNoClasses; // maximum no. of classes (distinct elements)
  protected Hashtable classCard; // classes cardinalities, key (integer):
			         // class id, value (integer) class
			         // cardinality
  protected Hashtable classCode; // classes encodings, key is a
				 // String representing the
				 // original value, mapped to an
				 // Integer representing the
				 // encoding
  protected Hashtable classFitness; // we remember the fitness for each
				    // class of the partition; key
				    // (Integer): class number, value
				    // (Double): fitness of the class
  protected boolean cfIsValid;

  protected double fitness; // fitness of the partition

  // class fitness types
  static public final int CF_SYM_DIFF  = 1; // symmetrical difference
  static public final int CF_PROD      = 2; // |Cj|imp(Cj)
  static public final int CF_DIV       = 3; // imp(Cj) / |Cj|
  static public final int CF_POW       = 4; // 2^imp(Cj) / |Cj| 

  Partition(int size)
  {
    this(size, 0, CF_SYM_DIFF);
  }

  Partition(int size, int maxNoClasses)
  {
    this(size, maxNoClasses, CF_SYM_DIFF);
  }

  Partition(int size, int maxNoClasses, int classFitnessType)
  {
    this.size = size;
    v = new int[size];
    for (int i = 0; i < size; i++)
      v[i] = 0;  // initial values 0, no class is set yet
    this.maxNoClasses = maxNoClasses;
    classCard = new Hashtable();
    classCode = new Hashtable();
    classFitness = new Hashtable();
    fitness = 0.0;
    this.classFitnessType = classFitnessType;
    cfIsValid = false;
  }

  /** sets <code>rowid</code> to belong to class <code>c</code>,
   * updates the class cardinality of the new and old class to whom
   * rowid belongs */
  public void set(int rowid, int c)
  {
    // if new class equal the old class return
    if (v[rowid] == c)
      return;
    
    // otherwise update classCard info!

    // if v[rowid] already had a class number
    Integer oldClassNo = new Integer(v[rowid]);
    if (v[rowid] != 0)
      if (classCard.containsKey(oldClassNo))
	{
	  // if v[rowid] is unique
	  int card = ((Integer)classCard.get(oldClassNo)).intValue();
	  if (card == 1)
	    // remove this class from the map
	    classCard.remove(oldClassNo);
	  else
	    // decrement cardinality of previous class v[rowid]
	    classCard.put(oldClassNo, new Integer(card - 1)); 
	}
    
    // set new value
    v[rowid] = c;
    
    // increment the cardinality of new class val
    Integer newClassNo = new Integer(c);

    int newClassCard = 1;
    if (classCard.containsKey(newClassNo))
      newClassCard = ((Integer)classCard.get(newClassNo)).intValue() + 1;
   
    classCard.put(newClassNo , new Integer(newClassCard));
    
    cfIsValid = false;
  }

  /** @return the class of <code>rowid</code> */
  public int get(int rowid)
  {
    if (Global.DEBUG == 1)
      if (rowid >= size)
	{
	  System.err.println("ERROR! Partition.get(): rowid too large");
	  System.exit(1);
	}

    return v[rowid];
  }

  /** @return true if the class <code>classOrig</code> has already a
   *  numeric code */
  public boolean hasClassCode(String classOrig)
  {
    return classCode.containsKey(classOrig);
  }

  /** @return an Integer encoding associated with the class
   * <code>classOrig</code>*/
  public Integer getClassCode(String classOrig)
  {
    return (Integer)(classCode.get(classOrig));
  }

  /** sets an Integer encoding <code>code</code> for the class
   * <code>classOrig</code>*/
  public void setClassCode(String classOrig, Integer code)
  {
    classCode.put(classOrig, code);
  }

  /** @return the maximum number of classes */
  public int getMaxNoClasses()
  {
    return maxNoClasses;
  }

  /** @return the actual number of classes */
  public int getNoClasses()
  {
    return classCard.size();
  }

  /** prints information about the classes of this Partition */
  public void printClassInfo()
  {
    for (Enumeration e = classCode.keys() ; e.hasMoreElements() ; ) 
      {
	String classOrig = (String)(e.nextElement());
	Integer encoding  = (Integer)classCode.get(classOrig);
	System.out.println(classOrig + " enc: " +  encoding 
			   + " card: " + classCard.get(encoding));
      }
  }

  /** returns a String containing a list of classes of this Partition
   * and their cardinalities */
  public String getClassesAndCardinalities()
  {
    StringBuffer output = new StringBuffer();
    for (Enumeration classes = classCard.keys(); 
	 classes.hasMoreElements(); )
      {
	Integer currClass = (Integer)classes.nextElement();
	output.append(currClass + " (" 
		      + classCard.get(currClass) + ") ");
      }
    return output.toString();
  }

  /** prints cardinalities of the classes of this Partition */
  public void printClassCardinalities()
  {
    for (Enumeration classes = classCard.keys(); 
	 classes.hasMoreElements(); )
      {
	Integer currClass = (Integer)classes.nextElement();
	System.out.print(currClass + " (" 
			 + classCard.get(currClass) + ") ");
      }
    System.out.println();
  }

  /** appends cardinalities of the classes of this Partition to the
   * <code>output</code> */
  public void printClassCardinalities(StringBuffer output)
  {
    for (Enumeration classes = classCard.keys(); 
	 classes.hasMoreElements(); )
      {
	Integer currClass = (Integer)classes.nextElement();
	output.append(currClass + " (" 
		      + classCard.get(currClass) + ") ");
      }
    output.append("\n");
  }

  /** prints the class fitness values */
  public void printClassFitness()
  {
    if (cfIsValid == false)
      {
	System.err.println("ERROR! Partition.getClassFitness(): cfIsValid = false");
	System.exit(1);
      }

    NumberFormat nf = NumberFormat.getInstance();
    nf.setMaximumFractionDigits(3);

    for (Enumeration classes = classFitness.keys(); 
	 classes.hasMoreElements(); )
      {
	Integer currClass = (Integer)classes.nextElement();
	System.out.print(currClass + " (" 
			 + nf.format(classFitness.get(currClass)) + ") ");
      }
    System.out.println();
  }


  /** @return the size of this Partition */
  public int getSize()
  {
    return size;
  }

  /** resets the size of this partition to a smaller value
   * <code>size</code>*/
  public void setSize(int size)
  {
    if (size <= this.size)
      this.size = size;
  }

  /** randomly initializes this Partition 
   *  @param rand random number generator
  */
  public void init(Random rand)
  {
    for (int j = 0; j < size; j++)
      // fill with a random number between 1 and getMaxNoClasses()
      set(j, rand.nextInt(getMaxNoClasses()) + 1); 
    
    // if we do not have exactly getMaxNoClasses() adjust the chromosome
    if (getNoClasses() != getMaxNoClasses())
      adjust(rand);
  }


  /** adjusts this Partition to have exactly
   * <code>getMaxNoClasses()</code> classes 
   * @param rand a random number generator object
  */
  public void adjust(Random rand)
  {
    //System.out.println("adjusting...");
    int noClasses = getNoClasses();
    int maxNoClasses = getMaxNoClasses();
    Hashtable[] am = new Hashtable[maxNoClasses];
    for (int i = 0; i < maxNoClasses; i++)
      am[i] = new Hashtable();

    getAM(am);
  
    // the empty classes will be between indices noClasses and
    // getMaxNoClasses()-1
    // populate the empty classes
    for (int k = noClasses; k < getMaxNoClasses(); k++)
      {
	// pick a random class between 0 and noClasses - 1
	int pos = rand.nextInt(noClasses);
      
	// if the selected class has less than 2 elements
	// choose again
	while (am[pos].size() < 2)
	  pos = rand.nextInt(noClasses);
      
	// pick one element in the selected class
	// between 0 and size-1
	int selClass = rand.nextInt(am[pos].size());
	
	// retrieve the class to move
	Integer classToMove = null;
	try
	  {
	    for (Enumeration keys = am[pos].keys(); selClass >= 0; selClass--)
	      classToMove = (Integer)keys.nextElement();
	  }
	catch(NoSuchElementException e)
	  {
	    System.err.println("InternalError: Partition.adjust()");
	    System.exit(1);
	  }

	// move the element
	am[k].put(classToMove, classToMove);
	am[pos].remove(classToMove);
      }
    
    // setAM(am, getMaxNoClasses());
    setAM(am);
  }

  /** fills an array of Hashtable objects, <code>am</code>, with the
   * array representation of the partition; in this array each class
   * corresponds to an index in the array; the contents of the array
   * at that index is a Hashtable with the rowids where the class
   * appears in the partition */
  public void getAM(Hashtable[] am)
  {
    // maps classes to the order in the array of maps
    Hashtable classToIndexMap = new Hashtable();

    int index = 0;
    for (int i = 0; i < size; i++)
      {
	// v[i] is the class, key in the map
	// classToIndexMap.get(v[i]) is the index in am where
	Integer currClassNo = new Integer(v[i]);
	
	// this class will be stored at classToIndexMap index in am
	// class v[i] was not mapped yet
	if (classToIndexMap.containsKey(currClassNo) == false)
	  classToIndexMap.put(currClassNo, 
			      new Integer(index++));

	// key and value are the same
	Integer currRowid = new Integer(i);
	am[((Integer)classToIndexMap.get(currClassNo)).intValue()].put(currRowid, currRowid);
      }
  }

  /** sets this Partition according to the groupings in the array of
   * Hashtables <code>am</code> that contains <code>am.length</code>
   * Hashtables */
  public void setAM(Hashtable[] am)
  {
    //    System.out.println("B setAM " + getNoClasses() + " " + am.length);
    int noClasses = am.length;

    // empty the classCard map
    classCard.clear();

    // reset partition to 0
    for (int i = 0; i < size; i++)
      v[i] = 0;

    // we can have at most noClasses classes
    for (int i = 0; i < noClasses; i++)
      for (Enumeration e = am[i].keys(); e.hasMoreElements(); )
	{
	  int currRowid = ((Integer)e.nextElement()).intValue();
	  set(currRowid, i+1);

	  /*
	  v[currRowid] = i+1; // classes will be encoded starting from 1
	  Integer currClass = new Integer(i+1);
	  int currCard = 0;
	  if (classCard.containsKey(currClass) == true)
	    currCard = ((Integer)classCard.get(currClass)).intValue();
	  
	  // increment class cardinality
	  classCard.put(currClass, new Integer(currCard + 1)); 
	  */
	}
    
    cfIsValid = false;

    //    System.out.println("A setAM " + getNoClasses() + " " + am.length);
  }

  /** prints this Partition as an array of integers */
  protected void print()
  {
    for (int i = 0; i < size; i++)
      System.out.print(v[i] + " ");
    

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
午夜精品视频一区| 欧美精品自拍偷拍| 91国产精品成人| 精品国产一区二区三区久久久蜜月| 国产精品视频你懂的| 亚洲一区二区视频在线观看| 激情综合网av| 欧美精品久久天天躁| 国产精品久久久久精k8| 免费成人在线网站| 欧美亚洲综合另类| 亚洲欧洲国产专区| 国产成人精品影视| 欧美成人精精品一区二区频| 亚洲午夜激情网页| 成人av网址在线| 欧美精品一区二区三区视频| 亚洲va欧美va天堂v国产综合| 成人激情文学综合网| 久久综合色8888| 麻豆专区一区二区三区四区五区| 91国产福利在线| 最新日韩av在线| 福利一区二区在线| 国产日韩精品一区二区三区 | 欧美一区二区免费视频| 亚洲精品成人a在线观看| 不卡视频在线看| 中文字幕av免费专区久久| 久草中文综合在线| 欧美r级电影在线观看| 免费人成网站在线观看欧美高清| 欧美日韩极品在线观看一区| 一区二区三区自拍| 91成人网在线| 亚洲一二三区不卡| 欧美精品久久一区二区三区 | 久久久影视传媒| 国产精品羞羞答答xxdd| 久久久三级国产网站| 国产精品一品视频| 欧美经典一区二区三区| 从欧美一区二区三区| 日本一区二区三区dvd视频在线| 国产成人免费av在线| 国产精品丝袜黑色高跟| 99精品欧美一区二区三区小说 | 国精产品一区一区三区mba桃花 | 成人v精品蜜桃久久一区| 国产日韩成人精品| 97久久精品人人做人人爽50路| 亚洲欧洲精品一区二区三区不卡| av亚洲精华国产精华精华| 亚洲人成人一区二区在线观看| 日本电影欧美片| 婷婷综合另类小说色区| 日韩精品一区二区三区中文不卡| 国产一区二区调教| 亚洲人成伊人成综合网小说| 欧美亚洲一区三区| 九九视频精品免费| 国产精品大尺度| 欧美日本乱大交xxxxx| 国产在线精品国自产拍免费| 国产精品视频一二三| 欧美日韩三级视频| 狠狠色狠狠色综合日日91app| 国产精品乱码久久久久久| 欧美日韩一区高清| 国产馆精品极品| 一区二区欧美国产| 久久九九影视网| 欧美午夜不卡在线观看免费| 久久国产精品区| 国产午夜精品久久久久久免费视 | 99热这里都是精品| 日韩vs国产vs欧美| 国产精品久久久久9999吃药| 欧美日韩久久一区| eeuss鲁片一区二区三区在线观看 eeuss鲁片一区二区三区在线看 | 成人午夜激情影院| 日韩av中文字幕一区二区| 国产精品毛片大码女人| 日韩一区二区三区观看| 91亚洲精品久久久蜜桃| 免费看日韩a级影片| 亚洲男女毛片无遮挡| 久久久亚洲高清| 欧美精品自拍偷拍| 91行情网站电视在线观看高清版| 精品一区二区久久| 午夜精品一区二区三区电影天堂| 中文字幕av在线一区二区三区| 日韩一区二区三区视频在线观看| 色综合久久精品| 成人爽a毛片一区二区免费| 日韩av中文字幕一区二区三区| 亚洲精品一卡二卡| 国产精品久久久久久久浪潮网站| 精品久久国产老人久久综合| 欧美性感一区二区三区| 色女孩综合影院| av一区二区不卡| 成人精品视频一区| 亚洲一区二区三区在线看| 国产精品国产三级国产| 国产日产欧美一区二区三区| 日韩精品一区二区三区在线| 在线不卡欧美精品一区二区三区| 一本一本久久a久久精品综合麻豆| 国产高清不卡二三区| 国产一区二区在线影院| 国产麻豆一精品一av一免费| 蜜臂av日日欢夜夜爽一区| 日本女优在线视频一区二区| 亚洲电影欧美电影有声小说| 亚洲香肠在线观看| 亚洲国产成人av| 日韩福利电影在线观看| 国产一区二区三区四区五区入口 | 在线看日本不卡| 色猫猫国产区一区二在线视频| 成人成人成人在线视频| 96av麻豆蜜桃一区二区| 99精品欧美一区二区三区综合在线| 成人免费av网站| 97精品电影院| 在线观看一区日韩| 欧美色老头old∨ideo| 欧美日韩综合不卡| 欧美一区二区性放荡片| 精品久久久久久久久久久久久久久| 日韩一二三区视频| 久久久久久久一区| 国产精品久久免费看| 樱花草国产18久久久久| 天堂精品中文字幕在线| 九九精品视频在线看| 国产成人自拍网| 91色婷婷久久久久合中文| 欧美亚洲一区二区在线| 欧美成人aa大片| 国产精品视频免费看| 一二三区精品视频| 蜜臂av日日欢夜夜爽一区| 国产高清亚洲一区| 91福利在线看| 精品国产免费一区二区三区香蕉| 国产女主播在线一区二区| 亚洲精选视频在线| 麻豆免费看一区二区三区| 国产大陆精品国产| 欧美午夜一区二区| 精品国产伦一区二区三区观看方式| 欧美国产精品一区二区| 亚洲一区二区在线免费看| 精品一区二区三区视频在线观看| 99久久婷婷国产综合精品| 欧美精品乱码久久久久久按摩| 久久久不卡网国产精品二区| 亚洲伦理在线免费看| 久久 天天综合| 91久久精品一区二区三区| 精品乱码亚洲一区二区不卡| 亚洲欧洲中文日韩久久av乱码| 麻豆精品视频在线观看免费 | 色激情天天射综合网| 久久综合给合久久狠狠狠97色69| 亚洲精品欧美二区三区中文字幕| 麻豆国产精品777777在线| 色88888久久久久久影院野外| 欧美成人官网二区| 色婷婷综合五月| 国内外成人在线| 欧美喷潮久久久xxxxx| 中文字幕一区视频| 精品一区二区三区视频| 7777精品伊人久久久大香线蕉完整版 | 国产精品一区不卡| 日韩久久久精品| 亚洲成人黄色影院| 91国产精品成人| 中文字幕一区二区三区四区| 国产主播一区二区三区| 欧美精品久久99久久在免费线| 亚洲欧美经典视频| 成人一级黄色片| 国产日韩欧美不卡| 国产一区二区电影| 2021国产精品久久精品| 免费成人在线网站| 欧美一卡在线观看| 亚洲va韩国va欧美va| 在线看国产一区| 一区二区免费视频| 一本大道av伊人久久综合| 国产精品超碰97尤物18| 成人黄色a**站在线观看| 91精品国产综合久久香蕉麻豆| 国产精品 欧美精品|