src/demo/TSP.java
private void updateState() {
        Matrix state;
        if (compactState) {
            state = new DMatrix(2 * tour.cities.size(), 1);
            for (Integer index : tour.cities.keySet()) {
                City city = tour.cities.get(index);
                boolean visited = tour.visitedCities.contains(index);
                state.setValue(2 * index, 0, city.xNormalized * (visited ? -1 : 1));
                state.setValue(2 * index + 1, 0, city.yNormalized * (visited ? -1 : 1));
            }
        }
        else {
            state = new DMatrix(4 * tour.cities.size(), 1);
            for (Integer index : tour.cities.keySet()) {
                City city = tour.cities.get(index);
                int visited = tour.visitedCities.contains(index) ? 0 : tour.cities.size();
                state.setValue(visited + 2 * index, 0, city.xNormalized);
                state.setValue(visited + 2 * index + 1, 0, city.yNormalized);
            }
        }

        environmentState = new EnvironmentState(episodeID, timeStamp, state, tour.getUnvisitedCities());
    }
/**
     * Updates state. State is updates based on coordinates of cities and cities visited (negated coordinates).
     *
     */
Updates state. State is updates based on coordinates of cities and cities visited (negated coordinates).
Updates state . State is updates based on coordinates of cities and cities visited ( negated coordinates ) .
private void updateState() {
        Matrix state;
        if (compactState) {
            state = new DMatrix(2 * tour.cities.size(), 1);
            for (Integer index : tour.cities.keySet()) {
                City city = tour.cities.get(index);
                boolean visited = tour.visitedCities.contains(index);
                state.setValue(2 * index, 0, city.xNormalized * (visited ? -1 : 1));
                state.setValue(2 * index + 1, 0, city.yNormalized * (visited ? -1 : 1));
            }
        }
        else {
            state = new DMatrix(4 * tour.cities.size(), 1);
            for (Integer index : tour.cities.keySet()) {
                City city = tour.cities.get(index);
                int visited = tour.visitedCities.contains(index) ? 0 : tour.cities.size();
                state.setValue(visited + 2 * index, 0, city.xNormalized);
                state.setValue(visited + 2 * index + 1, 0, city.yNormalized);
            }
        }
        environmentState = new EnvironmentState(episodeID, timeStamp, state, tour.getUnvisitedCities());
    }
private void updateState ( ) { Matrix state ; if ( compactState ) { state = new DMatrix ( 2 * tour . cities . size ( ) , 1 ) ; for ( Integer index : tour . cities . keySet ( ) ) { City city = tour . cities . get ( index ) ; boolean visited = tour . visitedCities . contains ( index ) ; state . setValue ( 2 * index , 0 , city . xNormalized * ( visited ? - 1 : 1 ) ) ; state . setValue ( 2 * index + 1 , 0 , city . yNormalized * ( visited ? - 1 : 1 ) ) ; } } else { state = new DMatrix ( 4 * tour . cities . size ( ) , 1 ) ; for ( Integer index : tour . cities . keySet ( ) ) { City city = tour . cities . get ( index ) ; int visited = tour . visitedCities . contains ( index ) ? 0 : tour . cities . size ( ) ; state . setValue ( visited + 2 * index , 0 , city . xNormalized ) ; state . setValue ( visited + 2 * index + 1 , 0 , city . yNormalized ) ; } } environmentState = new EnvironmentState ( episodeID , timeStamp , state , tour . getUnvisitedCities ( ) ) ; }
Updates state.
Updates state .