Package com.heatonresearch.aifh.aco

Examples of com.heatonresearch.aifh.aco.DiscreteACO


     */
    public void solve() {
        StringBuilder builder = new StringBuilder();

        initCities();
        DiscreteACO aco = new DiscreteACO(this, 50);

        int sameSolutionCount = 0;
        int iteration = 1;
        double lastSolution = Double.MAX_VALUE;

        while (sameSolutionCount < MAX_SAME_SOLUTION) {
            aco.iteration();

            double thisSolution = aco.getBestCost();

            builder.setLength(0);
            builder.append("Iteration: ");
            builder.append(iteration++);
            builder.append(", Best Path Length = ");
            builder.append(thisSolution);

            System.out.println(builder.toString());

            if (Math.abs(lastSolution - thisSolution) < 1.0) {
                sameSolutionCount++;
            } else {
                sameSolutionCount = 0;
            }

            lastSolution = thisSolution;
        }

        System.out.println("Good solution found:");
        int[] best = aco.getBestTour();
        displaySolution(best);
    }
View Full Code Here

TOP

Related Classes of com.heatonresearch.aifh.aco.DiscreteACO

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.