/**
   * Loads definitions of all agents
   *
   * @param node
   */
  @SuppressWarnings("unchecked")
  private void loadAgents(Node root, ClassLoader classLoader) throws Exception {
    ArrayList<Node> list = XmlDocUtils.getChildrenByTagName(root, "agents");
    // No agents
    if (list.size() < 1) return;

    list = XmlDocUtils.getChildrenByTagName(list.get(0), "agent");
    Class<? extends Agent> agentType;

    for (int i = 0; i < list.size(); i++) {
      Node node = list.get(i);

      // Agent's priority
      int priority = XmlDocUtils.getIntegerValue(node, "priority", Observer.LOW_PRIORITY);
      // Agent's step time
      RationalNumber time = RationalNumber.parse(XmlDocUtils.getValue(node, "time", "1"));
      // Agent's class
      String className = node.getTextContent().trim();
      if (classLoader != null) {
        agentType = (Class<Agent>) classLoader.loadClass(className);
      } else {
        agentType = (Class<Agent>) Class.forName(className);
      }

      // Add agent's definition to the model
      addAgentType(agentType, time, priority);
    }
  }
  /**
   * Loads basic model parameters
   *
   * @param model
   * @param root
   */
  private void loadBasicModelParameters(Node root) {
    /* Load tick size */
    RationalNumber tickTime = RationalNumber.parse(XmlDocUtils.getValue(root, "tick", "1"));

    // Set model's tick time
    setTickTime(tickTime);

    // Set model's default observer and execution mode
    ArrayList<Node> nodes = XmlDocUtils.getChildrenByTagName(root, "setup");

    String defaultObserver =
        XmlDocUtils.getValue(nodes.get(0), "observer", ObserverFactory.DEFAULT_OBSERVER_NAME);
    int defaultExecutionMode = ExecutionMode.SERIAL_MODE;
    try {
      defaultExecutionMode =
          ExecutionMode.parse(XmlDocUtils.getValue(nodes.get(0), "mode", "serial"));
    } catch (Exception e) {
      logger.error(e);
    }

    setDefaultObserver(defaultObserver, defaultExecutionMode);
  }