// Path: src/main/java/org/avmframework/objective/ObjectiveValue.java
// public abstract class ObjectiveValue<T extends ObjectiveValue> implements Comparable<T> {
// 
//   public abstract boolean isOptimal();
// 
//   public boolean betterThan(T other) {
//     return compareTo(other) > 0;
//   }
// 
//   public boolean sameAs(T other) {
//     return compareTo(other) == 0;
//   }
// 
//   public boolean worseThan(T other) {
//     return compareTo(other) < 0;
//   }
// }


import org.avmframework.objective.ObjectiveValue;
package org.avmframework;


/**
 * A Monitor instance is used by an AVM object to keep track of the candidate solution with the best
 * objective value, the number of objective function evaluations that have taken place, and other
 * information. It is also responsible for triggering a {@link
 * org.avmframework.TerminationException} when the conditions of the search's {@link
 * org.avmframework.TerminationPolicy} have been satisfied.
 *
 * @author Phil McMinn
 */
public class Monitor {

  /** The termination policy being used by the search. */
  protected TerminationPolicy tp;

  /** The best objective value observed so far during hte search. */
  protected ObjectiveValue bestObjVal;

  /** The vector with the best objective value observed so far by the search. */
  protected Vector bestVector;

  /**
   * The number of objective function evaluations that have taken place so far. The count includes
   * non-unique vectors. So if the same vector is evaluated twice, both evaluations will be recorded
   * by this counter.
   */
  protected int numEvaluations;

  /**
   * The number of unique objective function evaluations that have taken place so far. If a vector
   * is evaluated more than once, this count should not increase.
   */
  protected int numUniqueEvaluations;

  /** The number of times the AVM search has been restarted. */
  protected int numRestarts;

  /** The system time (in milliseconds) that the search was started. */
  protected long startTime;

  /** The system time (in milliseconds) that the search was ended. */
  protected long endTime;

  /**
   * Constructs a Monitor instance.
   *
   * @param tp The termination policy being used by the search.
   */
  public Monitor(TerminationPolicy tp) {
    this.tp = tp;
    bestObjVal = null;
    bestVector = null;
    numEvaluations = 0;
    numUniqueEvaluations = 0;
    numRestarts = 0;
    startTime = System.currentTimeMillis();
  }

  /**
   * Gets the best objective value observed by the search so far.
   *
   * @return THe best objective value.
   */
  public ObjectiveValue getBestObjVal() {
    return bestObjVal;
  }

  /**
   * Gets the vector with the best objective value observed by the search so far.
   *
   * @return The best vector.
   */
  public Vector getBestVector() {
// Path: src/main/java/org/avmframework/objective/ObjectiveValue.java
// public abstract class ObjectiveValue<T extends ObjectiveValue> implements Comparable<T> {
// 
//   public abstract boolean isOptimal();
// 
//   public boolean betterThan(T other) {
//     return compareTo(other) > 0;
//   }
// 
//   public boolean sameAs(T other) {
//     return compareTo(other) == 0;
//   }
// 
//   public boolean worseThan(T other) {
//     return compareTo(other) < 0;
//   }
// }


// Path: src/main/java/org/avmframework/Monitor.java
import org.avmframework.objective.ObjectiveValue;

package org.avmframework;


/**
 * A Monitor instance is used by an AVM object to keep track of the candidate solution with the best
 * objective value, the number of objective function evaluations that have taken place, and other
 * information. It is also responsible for triggering a {@link
 * org.avmframework.TerminationException} when the conditions of the search's {@link
 * org.avmframework.TerminationPolicy} have been satisfied.
 *
 * @author Phil McMinn
 */
public class Monitor {

  /** The termination policy being used by the search. */
  protected TerminationPolicy tp;

  /** The best objective value observed so far during hte search. */
  protected ObjectiveValue bestObjVal;

  /** The vector with the best objective value observed so far by the search. */
  protected Vector bestVector;

  /**
   * The number of objective function evaluations that have taken place so far. The count includes
   * non-unique vectors. So if the same vector is evaluated twice, both evaluations will be recorded
   * by this counter.
   */
  protected int numEvaluations;

  /**
   * The number of unique objective function evaluations that have taken place so far. If a vector
   * is evaluated more than once, this count should not increase.
   */
  protected int numUniqueEvaluations;

  /** The number of times the AVM search has been restarted. */
  protected int numRestarts;

  /** The system time (in milliseconds) that the search was started. */
  protected long startTime;

  /** The system time (in milliseconds) that the search was ended. */
  protected long endTime;

  /**
   * Constructs a Monitor instance.
   *
   * @param tp The termination policy being used by the search.
   */
  public Monitor(TerminationPolicy tp) {
    this.tp = tp;
    bestObjVal = null;
    bestVector = null;
    numEvaluations = 0;
    numUniqueEvaluations = 0;
    numRestarts = 0;
    startTime = System.currentTimeMillis();
  }

  /**
   * Gets the best objective value observed by the search so far.
   *
   * @return THe best objective value.
   */
  public ObjectiveValue getBestObjVal() {
    return bestObjVal;
  }

  /**
   * Gets the vector with the best objective value observed by the search so far.
   *
   * @return The best vector.
   */
  public Vector getBestVector() {
    return bestVector;