// Adds the string corresponding to the given newSequences to the
 // set allSequencesAsCode. The latter set is intended to mirror
 // the set allSequences, but stores strings instead of Sequences.
 protected void randoopConsistencyTest2(Sequence newSequence) {
   Tracer.trace("randoopConsistencyTest2");
   // Testing code.
   if (GenInputsAbstract.debug_checks) {
     Tracer.trace("debug_checks@randoopConsistencyTest2");
     this.allsequencesAsCode.add(newSequence.toCodeString());
     this.allsequencesAsList.add(newSequence);
   }
   Tracer.trace("NO debug_checks@randoopConsistencyTest2");
 }
 // Checks that the set allSequencesAsCode contains a set of strings
 // equivalent to the sequences in allSequences.
 protected void randoopConsistencyTests(Sequence newSequence) {
   Tracer.trace("randoopConsistencyTests");
   // Testing code.
   if (GenInputsAbstract.debug_checks) {
     Tracer.trace("debug_checks@randoopConsistencyTests");
     String code = newSequence.toCodeString();
     if (this.allSequences.contains(newSequence)) {
       if (!this.allsequencesAsCode.contains(code)) {
         throw new IllegalStateException(code);
       }
     } else {
       Tracer.trace("NO debug_checks@randoopConsistencyTests");
       if (this.allsequencesAsCode.contains(code)) {
         int index = this.allsequencesAsCode.indexOf(code);
         StringBuilder b = new StringBuilder();
         Sequence co = this.allsequencesAsList.get(index);
         co.equals(newSequence);
         b.append(
             "new component:"
                 + Globals.lineSep
                 + ""
                 + newSequence.toString()
                 + ""
                 + Globals.lineSep
                 + "as code:"
                 + Globals.lineSep
                 + ""
                 + code
                 + Globals.lineSep);
         b.append(
             "existing component:"
                 + Globals.lineSep
                 + ""
                 + this.allsequencesAsList.get(index).toString()
                 + ""
                 + Globals.lineSep
                 + "as code:"
                 + Globals.lineSep
                 + ""
                 + this.allsequencesAsList.get(index).toCodeString());
         throw new IllegalStateException(b.toString());
       }
     }
   }
 }
  /**
   * Tries to create and execute a new sequence. If the sequence is new (not already in the
   * specified component manager), then it is executed and added to the manager's sequences. If the
   * sequence created is already in the manager's sequences, this method has no effect, and returns
   * null.
   */
  private ExecutableSequence createNewUniqueSequence() {

    Tracer.trace("createNewUniqueSequence");

    if (Log.isLoggingOn()) Log.logLine("-------------------------------------------");

    StatementKind statement = null;

    if (this.statements.isEmpty()) return null;

    // Select a StatementInfo
    statement = Randomness.randomMember(this.statements);
    if (Log.isLoggingOn()) Log.logLine("Selected statement: " + statement.toString());

    // jhp: add flags here
    InputsAndSuccessFlag sequences = selectInputs(statement);

    if (!sequences.success) {
      if (Log.isLoggingOn()) Log.logLine("Failed to find inputs for statement.");
      return null;
    }

    Sequence concatSeq = Sequence.concatenate(sequences.sequences);

    // Figure out input variables.
    List<Variable> inputs = new ArrayList<Variable>();
    for (Integer oneinput : sequences.indices) {
      Variable v = concatSeq.getVariable(oneinput);
      inputs.add(v);
    }

    Sequence newSequence = concatSeq.extend(statement, inputs);

    // With .5 probability, do a primitive value heuristic.
    Tracer.trace("heuristic-uniquesequence");
    if (GenInputsAbstract.repeat_heuristic && Randomness.nextRandomInt(10) == 0) {
      Tracer.trace("repeat_heuristic@heuristic-uniquesequence");
      int times = Randomness.nextRandomInt(100);
      newSequence = newSequence.repeatLast(times);
      if (Log.isLoggingOn()) Log.log(">>>" + times + newSequence.toCodeString());
    }
    Tracer.trace("NO_repeat_heuristic@heuristic-uniquesequence");

    // If parameterless statement, subsequence inputs
    // will all be redundant, so just remove it from list of statements.
    if (statement.getInputTypes().size() == 0) {
      statements.remove(statement);
    }

    // If sequence is larger than size limit, try again.
    Tracer.trace("evaluating-maxsize");
    if (newSequence.size() > GenInputsAbstract.maxsize) {
      Tracer.trace(">maxsize@evaluating-maxsize");
      if (Log.isLoggingOn())
        Log.logLine(
            "Sequence discarded because size "
                + newSequence.size()
                + " exceeds maximum allowed size "
                + GenInputsAbstract.maxsize);
      return null;
    }
    Tracer.trace("<maxsize@evaluating-maxsize");

    randoopConsistencyTests(newSequence);

    if (this.allSequences.contains(newSequence)) {
      Tracer.trace("discard existing");
      if (Log.isLoggingOn())
        Log.logLine("Sequence discarded because the same sequence was previously created.");
      return null;
    }

    this.allSequences.add(newSequence);

    for (Sequence s : sequences.sequences) {
      s.lastTimeUsed = java.lang.System.currentTimeMillis();
    }

    randoopConsistencyTest2(newSequence);

    if (Log.isLoggingOn()) {
      Log.logLine("Successfully created new unique sequence:" + newSequence.toString());
    }
    // System.out.println("###" + statement.toStringVerbose() + "###" + statement.getClass());

    // Keep track of any input sequences that are used in this sequence
    // Tests that contain only these sequences are probably redundant
    for (Sequence is : sequences.sequences) {
      subsumed_sequences.add(is);
    }

    return new ExecutableSequence(newSequence);
  }