public void acceptClusterer(BatchClustererEvent ce) {
    if (ce.getTestSet() == null || 
        ce.getTestOrTrain() == BatchClustererEvent.TEST ||
        ce.getTestSet().isStructureOnly()) {
      return;
    }

    Instances trainHeader = new Instances(ce.getTestSet().getDataSet(), 0);
    String titleString = ce.getClusterer().getClass().getName();		      
    titleString = titleString.
      substring(titleString.lastIndexOf('.') + 1,
                titleString.length());

    String prefix = "";
    String relationName = (m_includeRelationName)
    ? trainHeader.relationName()
    : "";
    try {
      prefix = m_env.substitute(m_filenamePrefix);
    } catch (Exception ex) {
      stop(); // stop all processing
      String message = "[SerializedModelSaver] " 
        + statusMessagePrefix() 
        + " Can't save model. Reason: " 
        + ex.getMessage();
      if (m_logger != null) {
        m_logger.logMessage(message);
        m_logger.statusMessage(statusMessagePrefix()
            + "ERROR (See log for details)");
      } else {
        System.err.println(message);
      }
      return;
    }
    String fileName = "" 
      + prefix
      + relationName
      + titleString
      + "_"
      + ce.getSetNumber() 
      + "_" + ce.getMaxSetNumber();
    fileName = sanitizeFilename(fileName);
    
    String dirName = m_directory.getPath();
    try {
      dirName = m_env.substitute(dirName);
    } catch (Exception ex) {
      stop(); // stop all processing
      String message = "[SerializedModelSaver] "
        + statusMessagePrefix() + " Can't save model. Reason: " 
                           + ex.getMessage();
      if (m_logger != null) {
        m_logger.logMessage(message);
        m_logger.statusMessage(statusMessagePrefix()
            + "ERROR (See log for details)");
      } else {
        System.err.println(message);
      }
      return;
    }
    File tempFile = new File(dirName);
    fileName = tempFile.getAbsolutePath() 
      + File.separator
      + fileName;

    saveModel(fileName, trainHeader, ce.getClusterer());
  }