public int migrate() {
		int numMigrations = 0;
		for (Agent a : agents) {
			if (Math.abs(a.getOpinion() - a.getGroup().getavg()) > this.Constants._epsilon
					|| a.getGroup().getAgents().size() < Constants.minAgents) {
				boolean changed = false;
				Group holdG = null;
				double probRoll = gen.nextDouble();
				a.calcEx();
				for (Group b : a.exGroups) {
					// probRoll = gen.nextDouble();
					if (!changed) {
						double prob1 = 1 - Math
								.abs(a.getOpinion() - b.getavg()); // holder for
																	// calculating
																	// probability
						double prob2 = prob1 / a.prob(); // actual probability
						if (prob2 >= probRoll) {
							holdG = b;
							changed = true;
							migrations++;
							break;
						}
					}
				}

				if (changed) {
					graph.migrateAgentToGroup(a, holdG);
					numMigrations++;
				} else {
					if (Constants.DynamicGroups) {
						// probRoll = gen.nextDouble();
						if (probRoll <= Math.abs(a.getOpinion()
								- a.getGroup().getavg())) {
							Group group = new Group("G-" + groupnum);
							groups.add(group);
							groupnum++;
							graph.migrateAgentToGroup(a, group);
						}
					}
				}
			}
		}
		return numMigrations;
	}