src/demo/TSP.java
private void route(boolean redraw) throws MatrixException, NeuralNetworkException, DynamicParamException, AgentException {
        resetRoute();

        getAgent().newEpisode();
        episodeID++;
        timeStamp = 0;
        while (!isTerminalState()) {
            timeStamp++;
            getAgent().newStep();
            getAgent().act();
        }
        getAgent().endEpisode();

        if (tour.lastDistance > 0 && tour.lastDistance == getTotalDistance()) unchangedDistanceCount++;
        else unchangedDistanceCount = 0;
        if (unchangedDistanceCount >= 20) getAgent().resetPolicy();

        if (redraw) {
            jFrame.remove(tspPanel);
            tspPanel = new TSPPanel();
            jFrame.add(tspPanel);
            tspPanel.addCities(tour.visitedCities, tour.visitedCitiesPrevious, tour.visitedCitiesMin);
            jFrame.revalidate();
            tspPanel.paintImmediately(0, 0, (int)(0.8 * xWindowSize), (int)(0.8 * yWindowSize));
        }
    }
/**
     * Single journey of travelling salesman taken by deep agent.
     *
     * @param redraw if true current journey is drawn to window.
     * @throws MatrixException throws exception if matrix operation fails.
     * @throws NeuralNetworkException throws exception if building of neural network fails.
     * @throws DynamicParamException throws exception if parameter (params) setting fails.
     */
Single journey of travelling salesman taken by deep agent.
@param redraw if true current journey is drawn to window.
@throws MatrixException throws exception if matrix operation fails.
@throws NeuralNetworkException throws exception if building of neural network fails.
@throws DynamicParamException throws exception if parameter (params) setting fails.
Single journey of travelling salesman taken by deep agent . @param redraw if true current journey is drawn to window . @throws MatrixException throws exception if matrix operation fails . @throws NeuralNetworkException throws exception if building of neural network fails . @throws DynamicParamException throws exception if parameter ( params ) setting fails .
private void route(boolean redraw) throws MatrixException, NeuralNetworkException, DynamicParamException, AgentException {
        resetRoute();
        getAgent().newEpisode();
        episodeID++;
        timeStamp = 0;
        while (!isTerminalState()) {
            timeStamp++;
            getAgent().newStep();
            getAgent().act();
        }
        getAgent().endEpisode();
        if (tour.lastDistance > 0 && tour.lastDistance == getTotalDistance()) unchangedDistanceCount++;
        else unchangedDistanceCount = 0;
        if (unchangedDistanceCount >= 20) getAgent().resetPolicy();
        if (redraw) {
            jFrame.remove(tspPanel);
            tspPanel = new TSPPanel();
            jFrame.add(tspPanel);
            tspPanel.addCities(tour.visitedCities, tour.visitedCitiesPrevious, tour.visitedCitiesMin);
            jFrame.revalidate();
            tspPanel.paintImmediately(0, 0, (int)(0.8 * xWindowSize), (int)(0.8 * yWindowSize));
        }
    }
private void route ( boolean redraw ) throws MatrixException , NeuralNetworkException , DynamicParamException , AgentException { resetRoute ( ) ; getAgent ( ) . newEpisode ( ) ; episodeID ++ ; timeStamp = 0 ; while ( ! isTerminalState ( ) ) { timeStamp ++ ; getAgent ( ) . newStep ( ) ; getAgent ( ) . act ( ) ; } getAgent ( ) . endEpisode ( ) ; if ( tour . lastDistance > 0 && tour . lastDistance == getTotalDistance ( ) ) unchangedDistanceCount ++ ; else unchangedDistanceCount = 0 ; if ( unchangedDistanceCount >= 20 ) getAgent ( ) . resetPolicy ( ) ; if ( redraw ) { jFrame . remove ( tspPanel ) ; tspPanel = new TSPPanel ( ) ; jFrame . add ( tspPanel ) ; tspPanel . addCities ( tour . visitedCities , tour . visitedCitiesPrevious , tour . visitedCitiesMin ) ; jFrame . revalidate ( ) ; tspPanel . paintImmediately ( 0 , 0 , ( int ) ( 0.8 * xWindowSize ) , ( int ) ( 0.8 * yWindowSize ) ) ; } }
Single journey of travelling salesman taken by deep agent.
Single journey of travelling salesman taken by deep agent .