Package net.sf.cpsolver.itc.heuristics.search.ItcHillClimber

Examples of net.sf.cpsolver.itc.heuristics.search.ItcHillClimber.NeighbourSelector


            if (ext instanceof ItcParameterWeightOscillation)
                ((ItcParameterWeightOscillation) ext).addOscillationListener(this);
        }
        iTotalBonus = 0;
        for (Enumeration e = iNeighbourSelectors.elements(); e.hasMoreElements();) {
            NeighbourSelector s = (NeighbourSelector) e.nextElement();
            s.init(solver);
            iTotalBonus += s.getBonus();
        }
    }
View Full Code Here


            iTotalBonus += s.getBonus();
        }
    }

    private void addNeighbourSelection(NeighbourSelection ns, double bonus) {
        iNeighbourSelectors.add(new NeighbourSelector(ns, bonus, iUpdatePoints));
    }
View Full Code Here

    private double totalPoints() {
        if (!iUpdatePoints)
            return iTotalBonus;
        double total = 0;
        for (Enumeration e = iNeighbourSelectors.elements(); e.hasMoreElements();) {
            NeighbourSelector ns = (NeighbourSelector) e.nextElement();
            total += ns.getPoints();
        }
        return total;
    }
View Full Code Here

                + "current value is " + sDF2.format(solution.getModel().getTotalValue()) + " (" + sDF2.format(100.0 * iBound / solution.getModel().getTotalValue()) + "%), "
                + "#idle=" + iNrIdle + ", "
                + "Pacc=" + sDF5.format(100.0 * iAcceptedMoves / iMoves) + "%");
        if (iUpdatePoints)
            for (Enumeration e = iNeighbourSelectors.elements(); e.hasMoreElements();) {
                NeighbourSelector ns = (NeighbourSelector) e.nextElement();
                sLog.info("  " + ns + " (" + sDF2.format(ns.getPoints()) + " pts, " + sDF2.format(100.0 * (iUpdatePoints ? ns.getPoints() : ns.getBonus()) / totalPoints()) + "%)");
            }
        iAcceptedMoves = iMoves = 0;
    }
View Full Code Here

            }
            if (iAlterBound) {
                iBound = Math.max(solution.getBestValue() + 2.0, Math.pow(iUpperBoundRate, Math.max(1, iNrIdle)) * solution.getBestValue());
                iAlterBound = false;
            }
            NeighbourSelector ns = null;
            if (iRandomSelection) {
                ns = (NeighbourSelector) ToolBox.random(iNeighbourSelectors);
            } else {
                double points = (ToolBox.random() * totalPoints());
                for (Enumeration e = iNeighbourSelectors.elements(); e.hasMoreElements();) {
                    ns = (NeighbourSelector) e.nextElement();
                    points -= (iUpdatePoints ? ns.getPoints() : ns.getBonus());
                    if (points <= 0)
                        break;
                }
            }
            Neighbour n = ns.selectNeighbour(solution);
            if (n != null)
                return n;
        }
    }
View Full Code Here

        iReheatLength = Math.round(iReheatLengthCoef*iTemperatureLength);
        iRestoreBestLength = Math.round(iRestoreBestLengthCoef*iTemperatureLength);
        solver.currentSolution().addSolutionListener(this);
        iTotalBonus = 0;
        for (Enumeration e=iNeighbourSelectors.elements();e.hasMoreElements();) {
            NeighbourSelector s = (NeighbourSelector)e.nextElement();
            s.init(solver);
            iTotalBonus += s.getBonus();
        }
    }
View Full Code Here

            iTotalBonus += s.getBonus();
        }
    }
   
    private void addNeighbourSelection(NeighbourSelection ns, double bonus) {
        iNeighbourSelectors.add(new NeighbourSelector(ns, bonus, iUpdatePoints));
    }
View Full Code Here

    private double totalPoints() {
        if (!iUpdatePoints) return iTotalBonus;
        double total = 0;
        for (Enumeration e=iNeighbourSelectors.elements();e.hasMoreElements();) {
            NeighbourSelector ns = (NeighbourSelector)e.nextElement();
            total += ns.getPoints();
        }
        return total;
    }
View Full Code Here

            (prob(-1)<1.0?"p(-1)="+sDF2.format(100.0*prob(-1))+"%, ":"")+
            "p(+1)="+sDF2.format(100.0*prob(1))+"%, "+
            "p(+10)="+sDF5.format(100.0*prob(10))+"%)");
            if (iUpdatePoints)
                for (Enumeration e=iNeighbourSelectors.elements();e.hasMoreElements();) {
                    NeighbourSelector ns = (NeighbourSelector)e.nextElement();
                    sLog.info("  "+ns+" ("+sDF2.format(ns.getPoints())+" pts, "+sDF2.format(100.0*(iUpdatePoints?ns.getPoints():ns.getBonus())/totalPoints())+"%)");
                }
            iAcceptIter=new int[] {0,0,0};
            iMoves = 0; iAbsValue = 0;
        }
        iLastCoolingIter=iIter;
View Full Code Here

    }
   
    private Neighbour genMove(Solution solution) {
        while (true) {
            if (incIter(solution)) return null;
            NeighbourSelector ns = null;
            if (iRandomSelection) {
                ns = (NeighbourSelector)ToolBox.random(iNeighbourSelectors);
            } else {
                double points = (ToolBox.random()*totalPoints());
                for (Enumeration e=iNeighbourSelectors.elements();e.hasMoreElements();) {
                    ns = (NeighbourSelector)e.nextElement();
                    points -= (iUpdatePoints?ns.getPoints():ns.getBonus());
                    if (points<=0) break;
                }
            }
            Neighbour n = ns.selectNeighbour(solution);
            if (n!=null) return n;
        }
    }
View Full Code Here

TOP

Related Classes of net.sf.cpsolver.itc.heuristics.search.ItcHillClimber.NeighbourSelector

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.