public boolean verify(VrpProblem problem) {
    double[][] distances = problem.getDistances();
    double[] distancesFromDepot = problem.getDistancesFromDepot();
    
//    int toursCost = calcToursCost(routes, problem);
    
    int[] windowStartTimes = problem.getWindowStartTimes();
    int[] windowEndTimes = problem.getWindowEndTimes();
    int[] serviceTimes = problem.getServiceTimes();
    int[] demands = problem.getDemands();
    boolean[] visited = new boolean[problem.getNumCities()];
    
    //follow the paths and make sure that the time constraints hold
    for (List<Integer> route : routes) {
      Iterator<Integer> iter = route.iterator();
      if (route.isEmpty()) {
        System.out.println("EMPTY ROUTE!!!");
        continue;
      }
      int prev = iter.next();
      if (windowEndTimes[prev] < distancesFromDepot[prev]) {
        System.out.println("first node violated time constraint: endTime=" + 
            windowEndTimes[prev] + ", dist=" + distancesFromDepot[prev]);
        return false;
      }
      visited[prev] = true;
      int remCapacity = problem.getVehicleCapacity() - demands[prev];
      double minVisitTime = Math.max(windowStartTimes[prev], distancesFromDepot[prev]);
      
      while (iter.hasNext()) {
        int cur = iter.next();
        visited[cur] = true;
        double nextMinVisitTime = Math.max(minVisitTime + serviceTimes[prev] + distances[prev][cur], windowStartTimes[cur]);
        if (nextMinVisitTime > windowEndTimes[cur]) {
          System.out.println(minVisitTime + "\t" + serviceTimes[prev] + "\t" + distances[prev][cur]);
          System.out.println("violated time constraint for " + prev + "->" + cur + 
              ": endTime=" + windowEndTimes[cur] + ", visitTime=" + nextMinVisitTime);
          return false;
        }
        minVisitTime = nextMinVisitTime;
        
        remCapacity -= demands[cur];
        if (remCapacity < 0) {
          System.out.println("violated capacity constraint");
          return false;
        }
        prev = cur;
      }
    }  
    
    for (boolean b : visited) {
      if (!b) {
        System.out.println("one of the nodes not visited");
        return false;
      }
    }
    
//    if (toursCost != this.toursCost) {
//      System.out.println("tour costs do not match: " + toursCost + " != " + this.toursCost);
//      return false;
//    }
    
    return true;
  }