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

📄 saimpl.java

📁 新型模拟退火算法解决TSP优化问题。自能退火。可用于大多数情况下的优化问题。
💻 JAVA
字号:
package test;

/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2005</p>
 * <p>Company: </p>
 * @author not attributable
 * @version 1.0
 */

public abstract class SAImpl
    implements SAInterface {

    double leakRate = .001;
    double potentialEnergy = 0; //势能
    double kineticEnergy = 100000; //动能

    public SAImpl(double lRate, double kEnergy) {
	this.leakRate = lRate;
	this.kineticEnergy = kEnergy;
    }

    /**
     * disturb
     *
     * @return boolean
     * @todo Implement this test.SAInterface method
     */
    public abstract boolean disturb(int range);

    /**
     * weight
     *
     * @return boolean
     * @todo Implement this test.SAInterface method
     */
    public abstract double weight();

    /**
     * optimize
     *
     * @param limit int
     * @todo Implement this test.SAInterface method
     */
    public void optimize(int range, int limit) {
	int count = 0;
	long tcount = 0;
	while (count < limit) {
	    if (disturb(range)) {
		count = 0;
	    }
	    else {
		count += 1;
	    }

	    if (tcount++ % 1000000 == 0) {
		System.out.println("tpower = " + (potentialEnergy + kineticEnergy) +
				   "; Potential Energy = " +
				   potentialEnergy + "; Kinetic Energy = " + kineticEnergy);
	    }
	}

	System.out.println("");
	System.out.println("Potential Energy = " + potentialEnergy);
	System.out.println("weight = " + weight());

    }

}

⌨️ 快捷键说明

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