/*
 * Copyright 2013 Centro de Investigación en Tecnoloxías da Información (CITIUS).
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package es.usc.citius.lab.hipster.algorithm.factory;


import es.usc.citius.lab.hipster.algorithm.ADStar;
import es.usc.citius.lab.hipster.algorithm.problem.HeuristicSearchProblem;
import es.usc.citius.lab.hipster.function.ScalarFunction;
import es.usc.citius.lab.hipster.function.impl.BinaryOperation;
import es.usc.citius.lab.hipster.node.NodeFactory;
import es.usc.citius.lab.hipster.node.adstar.ADStarNode;
import es.usc.citius.lab.hipster.node.adstar.ADStarNodeBuilder;
import es.usc.citius.lab.hipster.node.adstar.ADStarNodeUpdater;

import java.util.Iterator;

public class ADStarIteratorFactory<S, T extends Comparable<T>> implements
        AlgorithmIteratorFactory<S, ADStarNode<S,T>> {
    private final HeuristicSearchProblem<S, T> f;
    private final BinaryOperation<T> costAccumulator;
    private ScalarFunction<T> scale;
    private T min;
    private T max;
    private double epsilon;

    public ADStarIteratorFactory(HeuristicSearchProblem<S, T> problem, BinaryOperation<T> costAccumulator, ScalarFunction<T> scale, double epsilon, T min, T max) {
        this.f = problem;
        this.max = max;
        this.min = min;
        this.epsilon = epsilon;
        this.scale = scale;
        this.costAccumulator = costAccumulator;
    }

    public Iterator<ADStarNode<S, T>> create() {

        NodeFactory<S, ADStarNode<S, T>> defaultBuilder = new ADStarNodeBuilder<S, T>(
                this.min, this.max);

        ADStarNodeUpdater<S, T> updater = new ADStarNodeUpdater<S, T>(
                f.getCostFunction(), f.getHeuristicFunction(), this.costAccumulator, this.scale,
                this.epsilon);

        return new ADStar<S, T>(f.getInitialState(), f.getGoalState(),
                f.getTransitionFunction(), f.getTransitionFunction(),
                defaultBuilder, updater);
    }

}

@@ -641,16 +641,17 @@
 se.%0A */%0A
+%0A
 package 
@@ -696,17 +696,16 @@
 ctory;%0A%0A
-%0A
 import e
@@ -1213,344 +1213,1292 @@
 r;%0A%0A
-public class ADStarIteratorFactory%3CS, T extends Comparable%3CT%3E%3E implements%0A        AlgorithmIteratorFactory%3CS, ADStarNode%3CS,T%3E%3E %7B%0A    private final HeuristicSearchProblem%3CS, T%3E f;%0A    private final BinaryOperation%3CT%3E costAccumulator;%0A    private ScalarFunction%3CT%3E scale;%0A    private T min;%0A    private T max;%0A    private double epsilon;%0A
+/**%0A * This class is an implementation of %7B@link es.usc.citius.lab.hipster.algorithm.factory.AlgorithmIteratorFactory%7D%0A * to obtain the the %7B@link es.usc.citius.lab.hipster.algorithm.ADStar%7D iterator to solve a search problem%0A * given its definition.%0A *%0A * @param %3CS%3E class defining the state%0A * @param %3CT%3E class defining the cost%0A * %0A * @author Adri%C3%A1n Gonz%C3%A1lez Sieira %3C%3Ca href=%22adrian.gonzalez@usc.es%22%3Eadrian.gonzalez@usc.es%3C/a%3E%3E%0A * @since 0.1.0%0A */%0Apublic class ADStarIteratorFactory%3CS, T extends Comparable%3CT%3E%3E implements%0A        AlgorithmIteratorFactory%3CS, ADStarNode%3CS,T%3E%3E %7B%0A    private final HeuristicSearchProblem%3CS, T%3E f;%0A    private final BinaryOperation%3CT%3E costAccumulator;%0A    private ScalarFunction%3CT%3E scale;%0A    private T min;%0A    private T max;%0A    private double epsilon;%0A%0A    /**%0A     * Main constructor for ADStar factory that takes the definition of a heuristic problem%0A     * the accumulation operation and the scaling operations for the cost type and the sub-optimal%0A     * bounded value to do the search.%0A     * %0A     * @param problem heuristic problem definition%0A     * @param costAccumulator accumulation operation for the cost type%0A     * @param scale scaling operation for the cost type%0A     * @param epsilon sub-optimal bounded value to do the search%0A     */
 %0A   
@@ -2644,22 +2644,8 @@
 ilon
-, T min, T max
 ) %7B%0A
@@ -2693,35 +2693,90 @@
 x = 
-max;%0A        this.min = min
+costAccumulator.getMaxElem();%0A        this.min = costAccumulator.getIdentityElem()
 ;%0A  

Fix previous commit