def manual_schedule(use_file,
                    students,
                    sol,
                    feasible_projects,
                    annealer,
                    use_diversity,
                    filename,
                    temp,
                    iters,
                    output_file="output.csv"):
    '''
		Parameters
		----------
		use_file: indicates if we want to use the data from the file or not (bool).
		students: student attributes (2d numpy array of ints).
		sol: a solution (a Project list).
		annealer: the Annealer object (Annealer).
		use_diversity: indicates which energy function we want to use (bool).
		    If use_diversity is True, then we use the energy function from
		    perry_geo_annealing_diversity.
		    If use_diversity is False, then we use the energy function from 
		    perry_geo_annealing.py.
		filename: file that the input should come from (string).
		output_file: file that the output should go to (string).

		Returns
		-------
		Nothing. Writes to the output file and prints updates and solution
		to console.
		

	'''

    inv_cov_mat_tup = distance.create_inv_cov_mat_from_data(
        use_file, students, filename)
    if (len(sol) < 2):
        error = "There is only one team, so we cannot perform simulated annealing."
        raise CompError(error)

    state = (sol, inv_cov_mat_tup, feasible_projects, students)
    print "Initial energy is " + str(pg.energy(state))
    # Manually set the annealing schedule.
    state, e = annealer.anneal(state, temp, 0.01, iters, updates=iters / 10)

    #auto = annealer.auto(state, 90)
    #print auto
    print "Final energy is " + str(e)
    if (use_diversity):
        print "Calculated final energy is " + str(diversity.energy(state))
    else:
        print "Calculated final energy is " + str(pg.energy(state))

    util.print_final_solution(state, use_diversity, output_file)
    util.list_penalties(state)
    # Only print the unranked students if we a care about the students' rankings.
    if (not (use_diversity)):
        util.list_unranked_students(state)
        util.list_low_interest_students(state)
def manual_schedule(use_file, students, sol, feasible_projects,  annealer, use_diversity, filename, temp, iters, output_file = "output.csv"):
	'''
		Parameters
		----------
		use_file: indicates if we want to use the data from the file or not (bool).
		students: student attributes (2d numpy array of ints).
		sol: a solution (a Project list).
		annealer: the Annealer object (Annealer).
		use_diversity: indicates which energy function we want to use (bool).
		    If use_diversity is True, then we use the energy function from
		    perry_geo_annealing_diversity.
		    If use_diversity is False, then we use the energy function from 
		    perry_geo_annealing.py.
		filename: file that the input should come from (string).
		output_file: file that the output should go to (string).

		Returns
		-------
		Nothing. Writes to the output file and prints updates and solution
		to console.
		

	'''

	inv_cov_mat_tup = distance.create_inv_cov_mat_from_data(use_file, students, filename)
	if (len(sol) < 2):
		error = "There is only one team, so we cannot perform simulated annealing."
		raise CompError(error)

	state = (sol, inv_cov_mat_tup, feasible_projects, students)
	print "Initial energy is " + str(pg.energy(state))
	# Manually set the annealing schedule.
        state, e = annealer.anneal(state, temp, 0.01, iters, updates=iters/10)

        #auto = annealer.auto(state, 90)
        #print auto
	print "Final energy is " + str(e)
	if (use_diversity):
		print "Calculated final energy is " + str(diversity.energy(state))
	else:
		print "Calculated final energy is " + str(pg.energy(state))

	util.print_final_solution(state, use_diversity, output_file)
        util.list_penalties(state)
	# Only print the unranked students if we a care about the students' rankings.
	if (not(use_diversity)):
		util.list_unranked_students(state)
		util.list_low_interest_students(state)
예제 #3
0
    coding_ability = random.randint(0,4)
    work_experience = random.randint(0,4)
    return classes.Student("noname noname", student_ID, program, business_ability,coding_ability,work_experience,[], rankings_can_be_empty = True)

if (__name__ == "__main__"):
    #generate 1000 students
    '''students = [random_student(i) for i in range(1000)]
    inv_cov_mat_tup = distance.create_inv_cov_mat_from_data(False, students, None)
    print inv_cov_mat_tup
    print(len(students))
    print(inv_cov_mat_tup[0].shape)
    for s in students:
        print s.get_numerical_student_properties()'''
    
    students = util.create_students_from_input('students.csv')
    inv_cov_mat_tup = distance.create_inv_cov_mat_from_data(False, students,None)
    projects = [classes.Project(i, 5, 6) for i in range(1,2001)]
    diversities = []
    for p in projects:
        p.students = np.random.choice(students, 5, replace=False).tolist()
        diversities.append((p.ID,p.calculate_diversity(inv_cov_mat_tup)))
        
    def keyval(tup):
        return tup[1]

    diversities.sort(key = keyval, reverse = True)

    print "The hundred most diverse teams are: " + str([vals for vals in diversities[:100]])
    for team in [vals[0] for vals in diversities[:100]]:
        print "Team " + str(projects[team-1].ID) + " has numerical properties:"
        for s in projects[team-1].students: