mysolution.java

来自「TabuSearch的一个小程序。用禁忌搜索解决TSP问题」· Java 代码 · 共 44 行

JAVA
44
字号
import org.coinor.opents.*;public class MySolution extends SolutionAdapter {    public int[] tour;        public MySolution(){} // Appease clone()        public MySolution( double[][] customers )    {        // Crudely initialize solution        tour = new int[ customers.length ];        for( int i = 0; i < customers.length; i++ )            tour[i] = i;    }   // end constructor            public Object clone()    {           MySolution copy = (MySolution)super.clone();        copy.tour = (int[])this.tour.clone();        return copy;    }   // end clone            public String toString()    {        StringBuffer s = new StringBuffer();                s.append( "Solution value: " + getObjectiveValue()[0] );        s.append( "Sequence: [ " );                for( int i = 0; i < tour.length - 1; i++ )            s.append( tour[i] ).append( ", " );                s.append( tour[ tour.length - 1 ] );        s.append( " ]" );                return s.toString();    }   // end toString    }   // end class MySolution

⌨️ 快捷键说明

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