public boolean validateForAClient(Vehicle vehicle, Client cli) {

    double load = vehicle.getLoad();
    double distance = 0;
    double requirementTotal = 0.0; // 这个配送路线上所有的需求之和

    Client[] newClients = new Client[vehicle.getClients().length + 2];
    for (int i = 0; i < vehicle.getClients().length; i++) {
      newClients[i] = vehicle.getClients()[i];
    }

    newClients[newClients.length - 2] = cli;
    newClients[newClients.length - 1] = clients[0];
    Client prevClient = clients[0];

    for (Client client : newClients) {
      load += client.getSupply() - client.getRequirement();
      distance += Client.getDistance(prevClient, client);
      prevClient = client;
      requirementTotal += client.getRequirement();
    }

    // 这条路径上的用户需求之和不能大于卡车的运输能力
    if (requirementTotal > vehicle.getMaxLoad()) {
      //  System.out.println("requirement > maxLoad");
      return false;
    }

    if (load > vehicle.getMaxLoad() || load < 0) {
      //   System.out.println("overload");
      return false;
    }
    if (distance > vehicle.getMaxDistance()) {
      //    System.out.println("over distance");
      return false;
    }
    return true;
  }
  public boolean validate(Vehicle vehicle, List<Path> paths, Path path) {
    double load = vehicle.getLoad();

    double distance = 0;
    double requirementTotal = 0.0; // 这个配送路线上所有的需求之和

    List newPath = new LinkedList();
    for (Path p : paths) {
      newPath.add(p);
    }
    newPath.add(path);

    Client[] clientsOnPath = getPath(newPath);
    Client prevClient = clientsOnPath[0];
    for (Client client : clientsOnPath) {
      load += client.getSupply() - client.getRequirement();
      distance += Client.getDistance(prevClient, client);
      prevClient = client;
      requirementTotal += client.getRequirement();
    }
    // 这条路径上的用户需求之和不能大于卡车的运输能力
    if (requirementTotal > vehicle.getMaxLoad()) {
      //  System.out.println("requirement > maxLoad");
      return false;
    }

    if (load > vehicle.getMaxLoad() || load < 0) {
      //  System.out.println("overload");
      return false;
    }
    if (distance > vehicle.getMaxDistance()) {
      //   System.out.println("over distance");
      return false;
    }
    return true;
  }