⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 permutation.java

📁 这是多目标进化算法包
💻 JAVA
字号:
/** * Permutation.java * * @author juanjo durillo * @version 1.0 */package jmetal.base.variable;import jmetal.base.Configuration.*;import jmetal.base.Variable;import jmetal.util.PseudoRandom;/** * Implements a permutation of integer decision variable */public class Permutation extends Variable {    /**   * Stores a permutation of <code>int</code> values   */  public int [] vector_;    /**   * Stores the length of the permutation   */  public int size_;    /**   * Constructor   */  public Permutation() {	setVariableType(VariableType_.Permutation) ;    size_   = 0;    vector_ = null;  } //Permutation  /**   * Constructor   * @param size Length of the permutation   */  public Permutation(int size) {	setVariableType(VariableType_.Permutation) ;	size_   = size;    vector_ = new int[size_];        int [] randomSequence = new int[size_];        for(int k = 0; k < size_; k++){      int num           = PseudoRandom.randInt();      randomSequence[k] = num;      vector_[k]        = k;    }     // sort value and store index as fragment order    for(int i = 0; i < size_-1; i++){      for(int j = i+1; j < size_; j++) {        if(randomSequence[i] > randomSequence[j]){          int temp          = randomSequence[i];          randomSequence[i] = randomSequence[j];          randomSequence[j] = temp;          temp       = vector_[i];          vector_[i] = vector_[j];          vector_[j] = temp;        }      }    }  } //Permutation    /**    * Copy Constructor   * @param permutation The permutation to copy   */  public Permutation(Permutation permutation) {    setVariableType(VariableType_.Permutation) ;    size_   = permutation.size_;    vector_ = new int[size_];        for (int i = 0; i < size_; i++) {      vector_[i] = permutation.vector_[i];    }  } //Permutation    /**    * Create an exact copy of the <code>Permutation</code> object.   * @return An exact copy of the object.   */  public Variable deepCopy() {    return new Permutation(this);  } //deepCopy    /**   * Returns the length of the permutation.   * @return The length   */  public int getLength(){    return size_;  } //getNumberOfBits    /**   * Returns a string representing the object   * @return The string   */   public String toString(){    String string ;         string = "" ;    for (int i = 0; i < size_ ; i ++)      string += vector_[i] + " " ;          return string ;  } // toString  }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -