// Path: MetaHeuristics4Java/src/main/java/de/mh4j/solver/termination/TerminationCondition.java
// public interface TerminationCondition {
// 
//     // TODO add javadoc
//     boolean shouldTerminate();
// 
// }
// 
// Path: MetaHeuristics4Java/src/main/java/de/mh4j/util/RNGGenerator.java
// public abstract class RNGGenerator {
//     private final static Logger log = (Logger) LoggerFactory.getLogger(RNGGenerator.class);
// 
//     private static Random seedGenerator;
// 
//     public static void setMasterSeed(long masterSeed) {
//         seedGenerator = new Random(masterSeed);
//         log.info("Initialized random number generator with master seed {}", masterSeed);
//     }
// 
//     public static Random createRandomNumberGenerator() {
//         if (seedGenerator == null) {
//             setMasterSeed(System.currentTimeMillis());
//         }
//         long seed = seedGenerator.nextLong();
//         return new Random(seed);
//     }
// 
// }


import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import org.slf4j.LoggerFactory;
import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.Logger;
import de.mh4j.solver.termination.TerminationCondition;
import de.mh4j.util.RNGGenerator;
/*
 * Copyright 2012   Friedrich Große, Paul Seiferth,
 *                  Sebastian Starroske, Yannik Stein
 *
 * This file is part of MetaHeuristics4Java.
 *
 * MetaHeuristics4Java is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * MetaHeuristics4Java is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with MetaHeuristics4Java. If not, see <http://www.gnu.org/licenses/>.
 */

package de.mh4j.solver;




/**
 * A Solver is the representation of an algorithm that can find or approximate
 * solutions to a given optimization problem.
 * 
 * TODO write more about the possible implementation and utilization of a solver
 * 
 * @param <GenericSolutionType>
 *            the actual Type of the solution class.
 * 
 * @author Friedrich Große <friedrich.grosse@gmail.com>
 */
public abstract class AbstractSolver<GenericSolutionType> implements Solver<GenericSolutionType> {
    protected final Logger log = (Logger) LoggerFactory.getLogger(getClass());

    protected final Random randomizer;

    private final List<SolverStateListener<GenericSolutionType>> stateListeners = new ArrayList<>(2);
// Path: MetaHeuristics4Java/src/main/java/de/mh4j/solver/termination/TerminationCondition.java
// public interface TerminationCondition {
// 
//     // TODO add javadoc
//     boolean shouldTerminate();
// 
// }
// 
// Path: MetaHeuristics4Java/src/main/java/de/mh4j/util/RNGGenerator.java
// public abstract class RNGGenerator {
//     private final static Logger log = (Logger) LoggerFactory.getLogger(RNGGenerator.class);
// 
//     private static Random seedGenerator;
// 
//     public static void setMasterSeed(long masterSeed) {
//         seedGenerator = new Random(masterSeed);
//         log.info("Initialized random number generator with master seed {}", masterSeed);
//     }
// 
//     public static Random createRandomNumberGenerator() {
//         if (seedGenerator == null) {
//             setMasterSeed(System.currentTimeMillis());
//         }
//         long seed = seedGenerator.nextLong();
//         return new Random(seed);
//     }
// 
// }


// Path: MetaHeuristics4Java/src/main/java/de/mh4j/solver/AbstractSolver.java
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import org.slf4j.LoggerFactory;
import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.Logger;
import de.mh4j.solver.termination.TerminationCondition;
import de.mh4j.util.RNGGenerator;

/*
 * Copyright 2012   Friedrich Große, Paul Seiferth,
 *                  Sebastian Starroske, Yannik Stein
 *
 * This file is part of MetaHeuristics4Java.
 *
 * MetaHeuristics4Java is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * MetaHeuristics4Java is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with MetaHeuristics4Java. If not, see <http://www.gnu.org/licenses/>.
 */

package de.mh4j.solver;




/**
 * A Solver is the representation of an algorithm that can find or approximate
 * solutions to a given optimization problem.
 * 
 * TODO write more about the possible implementation and utilization of a solver
 * 
 * @param <GenericSolutionType>
 *            the actual Type of the solution class.
 * 
 * @author Friedrich Große <friedrich.grosse@gmail.com>
 */
public abstract class AbstractSolver<GenericSolutionType> implements Solver<GenericSolutionType> {
    protected final Logger log = (Logger) LoggerFactory.getLogger(getClass());

    protected final Random randomizer;

    private final List<SolverStateListener<GenericSolutionType>> stateListeners = new ArrayList<>(2);
    private final List<TerminationCondition> terminationConditions = new ArrayList<>(1);