// Path: src/test/java/org/avmframework/AlternatingVariableMethods.java
// public static AlternatingVariableMethod anyAlternatingVariableMethodWithTerminationPolicy(
//     TerminationPolicy tp) {
//   return new AlternatingVariableMethod(new IteratedPatternSearch(), tp, new DefaultInitializer());
// }
// 
// Path: src/test/java/org/avmframework/ObjectiveFunctions.java
// public static ObjectiveFunction flat() {
//   ObjectiveFunction objFun =
//       new ObjectiveFunction() {
//         @Override
//         protected ObjectiveValue computeObjectiveValue(Vector vector) {
//           return NumericObjectiveValue.higherIsBetterObjectiveValue(1.0);
//         }
//       };
//   return objFun;
// }
// 
// Path: src/test/java/org/avmframework/Vectors.java
// public static Vector singleIntegerVector() {
//   return integerVector(1);
// }


import static junit.framework.TestCase.assertTrue;
import static org.avmframework.AlternatingVariableMethods.anyAlternatingVariableMethodWithTerminationPolicy;
import static org.avmframework.ObjectiveFunctions.flat;
import static org.avmframework.Vectors.singleIntegerVector;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
    AlternatingVariableMethod avm = anyAlternatingVariableMethodWithTerminationPolicy(tp);
    Monitor monitor = avm.search(singleIntegerVector(), flat());
    assertEquals(limit, monitor.getNumRestarts());
  }

  @Test
  public void testNoEvaluations() {
    testEvaluations(0);
  }

  @Test
  public void testOneEvaluation() {
    testEvaluations(1);
  }

  @Test
  public void testOneHundredEvaluations() {
    testEvaluations(100);
  }

  protected void testEvaluations(int limit) {
    TerminationPolicy tp = TerminationPolicy.createMaxEvaluationsTerminationPolicy(limit);
    AlternatingVariableMethod avm = anyAlternatingVariableMethodWithTerminationPolicy(tp);
    Monitor monitor = avm.search(singleIntegerVector(), flat());
    assertEquals(limit, monitor.getNumEvaluations());
  }

  @Test
  public void testTimeLimit() {
    int minTime = 5;
// Path: src/test/java/org/avmframework/AlternatingVariableMethods.java
// public static AlternatingVariableMethod anyAlternatingVariableMethodWithTerminationPolicy(
//     TerminationPolicy tp) {
//   return new AlternatingVariableMethod(new IteratedPatternSearch(), tp, new DefaultInitializer());
// }
// 
// Path: src/test/java/org/avmframework/ObjectiveFunctions.java
// public static ObjectiveFunction flat() {
//   ObjectiveFunction objFun =
//       new ObjectiveFunction() {
//         @Override
//         protected ObjectiveValue computeObjectiveValue(Vector vector) {
//           return NumericObjectiveValue.higherIsBetterObjectiveValue(1.0);
//         }
//       };
//   return objFun;
// }
// 
// Path: src/test/java/org/avmframework/Vectors.java
// public static Vector singleIntegerVector() {
//   return integerVector(1);
// }


// Path: src/test/java/org/avmframework/TestTermination.java
import static junit.framework.TestCase.assertTrue;
import static org.avmframework.AlternatingVariableMethods.anyAlternatingVariableMethodWithTerminationPolicy;
import static org.avmframework.ObjectiveFunctions.flat;
import static org.avmframework.Vectors.singleIntegerVector;
import static org.junit.Assert.assertEquals;
import org.junit.Test;

    AlternatingVariableMethod avm = anyAlternatingVariableMethodWithTerminationPolicy(tp);
    Monitor monitor = avm.search(singleIntegerVector(), flat());
    assertEquals(limit, monitor.getNumRestarts());
  }

  @Test
  public void testNoEvaluations() {
    testEvaluations(0);
  }

  @Test
  public void testOneEvaluation() {
    testEvaluations(1);
  }

  @Test
  public void testOneHundredEvaluations() {
    testEvaluations(100);
  }

  protected void testEvaluations(int limit) {
    TerminationPolicy tp = TerminationPolicy.createMaxEvaluationsTerminationPolicy(limit);
    AlternatingVariableMethod avm = anyAlternatingVariableMethodWithTerminationPolicy(tp);
    Monitor monitor = avm.search(singleIntegerVector(), flat());
    assertEquals(limit, monitor.getNumEvaluations());
  }

  @Test
  public void testTimeLimit() {
    int minTime = 5;
    TerminationPolicy tp = TerminationPolicy.createRunningTimeTerminationPolicy(minTime);