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

📄 tsptabulist.java

📁 一个java的tabu search算法框架
💻 JAVA
字号:
public class TSPTabuList implements net.iharder.opents.TabuList {    int   tenure;    int[] tabuList;    int   pos;        public TSPTabuList( int tenure )    {        this.tenure = tenure;        tabuList = new int[ tenure ];        for( int i = 0; i < tenure; i++ )            tabuList[i] = -1;    }   // end constructor            public void setTabu(    net.iharder.opents.Solution fromSoln,     net.iharder.opents.Move move)    {        TSPSwapMove mv = (TSPSwapMove)move;        tabuList[ pos++ % tenure ] =             mv.pos1             * ((TSPSolution)fromSoln).tour.length            + mv.pos2;    }   // end setTabu         public boolean isTabu(    net.iharder.opents.Solution fromSoln,     net.iharder.opents.Move move)    {        TSPSwapMove mv   = (TSPSwapMove)move;        int         hash = mv.pos1                            * ((TSPSolution)fromSoln).tour.length                            + mv.pos2;        for( int i = 0; i < tenure; i++ )            if( tabuList[i] == hash )                return true;         return false;    }   // end isTabu    }   // end class TSPTabuList

⌨️ 快捷键说明

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