Bilt | OA | Volunteers
Anonymous User
1363

administered via byteboard

tech reasoning / design doc part

image

image

image

image

image

Coding part

Task List
You may do these tasks in any order, but take note that they are listed in the order your team has prioritized completing them.

Reminder that you are NOT expected to complete all tasks. You are expected to write clean, readable code. Remember to add comments explaining what you were working on if you run out of time in the middle of a task.

Task 1
We have decided to move forward with an interest-based approach to matching Volunteers with Tasks.

a. Implement the method with the following prototype in AssignmentServer.java:

public List getInterestedVolunteers(Task task)

This method should return a list of all Volunteer objects which have the given Task in their interestedTasks lists. If no volunteers list the task, it should return an empty list.

b. Additionally, we want to be able to compare tasks based on an objective measure of desirability across volunteers. We have decided to use a simple calculation for this purpose: a task's desirability score for a given volunteer is calculated by the function 1 / (x + 1), where x is the index of the task in the volunteer's interestedTasks list.

Implement the method with the following prototype in Volunteer.java:

public Double getTaskDesirabilityScore(Task task)

This method should return the given Task's desirability score for the current Volunteer, by simply implementing the function described above. If the Task does not appear in the Volunteer's interestedTasks list, the method should return 0.

Task 2
A Task's overall desirability is the sum of its desirability scores for all Volunteers who have included the Task in their interestedTasks lists. Implement the method with the following prototype in AssignmentServer.java:

public List getTasksByDesirability()

This method should return a list of Tasks sorted from greatest to least overall desirability, and with people-facing Tasks listed before the other Tasks.

We recently conducted internal research that shows that volunteers are more satisfied with their work and more likely to volunteer again when they are given a people-facing task. Moving people-facing tasks directly to the front of the desirability list ensures that we distribute those tasks effectively.

Task 3
Some volunteers have expressed dissatisfaction with the tasks they've been assigned. We want to track and increase volunteer satisfaction, so we have established a Volunteer Satisfaction Score. You can call getVolunteerSatisfactionScore() from Util.java to determine the score for current assignments.

In AssignmentServer.java, implement the method with the following prototype:

public void assignTasksImproved()

In this function, suggest and implement changes so that our assignment server yields higher volunteer satisfaction than it does with the assignTasks() function as currently implemented. Note that we are not looking for a perfect solution; our clients would prefer one or two completed minor improvements to the current algorithm over an "optimal" solution that is buggy or incomplete.

You are welcome to add any helper methods, implement any algorithm and/or use any underlying data structures you like, but you are encouraged to make sure your decisions are well documented and your code is appropriately decomposed.

import java.util.*;

public class AssignmentServer {

    // A map of task ids to Tasks.
    Map<Integer, Task> tasks;

    // A list of all volunteers in the server.
    ArrayList<Volunteer> volunteers;

    // A map of Volunteers to assigned Tasks.
    Map<Volunteer, Set<Task>> assignments;

    public AssignmentServer() {
        tasks = new HashMap<>();
        volunteers = new ArrayList<>();
        assignments = new HashMap<>();
    }

    public void importTasksFromCSV(String csvFileName) {
        this.tasks = Util.loadTasks(csvFileName);
    }

    public void importVolunteersFromCSV(String csvFileName) {
        this.volunteers.addAll(Util.loadVolunteers(csvFileName, this.tasks));
    }

    /**
     * Returns a List of the volunteers who have indicated interest in the 
	 * given task.
     */
    public List<Volunteer> getInterestedVolunteers(Task task) {

        // TODO: Implement this method. See the README for more details.

//         This method should return a list of all Volunteer objects which have the given Task in their interestedTasks lists. 
        //    If no volunteers list the task, it should return an empty list.
        //      Additionally, we want to be able to compare tasks based on an objective measure of desirability across volunteers. 
        //      We have decided to use a simple calculation for this purpose:
        //      a task's desirability score for a given volunteer is calculated by the function 1 / (x + 1), where x is the index of the task in the volunteer's interestedTasks list.

        return new ArrayList<>();
    }

    /**
     * Returns a List of Tasks sorted by desirability.
     */
    public List<Task> getTasksByDesirability() {

        // TODO: Implement this method. See the README for more details.

        return new ArrayList<>();
    }

    /**
     * Assigns Tasks to Volunteers by inserting them into the assignment map,
     * in order of desirability. Tasks are assigned to the first Volunteer with
     * interest. If there are no interested Volunteers, they are assigned to the
     * first available Volunteer.
     */
    public void assignTasks() {
        for (Task task : getTasksByDesirability()) {
            List<Volunteer> interestedVolunteers =
                getInterestedVolunteers(task);
            if (interestedVolunteers.size() > 0) {
                // Assign task to the first interested volunteer
                assignTask(task, interestedVolunteers.get(0));
            }
            else {
                // Assign the task to the first available volunteer
                assignTask(task, volunteers.get(0));
            }
        }
    }

    /**
     * Assigns Tasks to Volunteers based on their interest.
     */
    public void assignTasksImproved() {

        // TODO: Implement this method. See the README for more details.

    }

    /**
     * Adds the given task to the specified volunteer's Set of assigned Tasks.
     */
    public void assignTask(Task task, Volunteer volunteer) {
        if (!this.assignments.containsKey(volunteer)) {
            this.assignments.put(volunteer,  new HashSet<>());
        }
        this.assignments.get(volunteer).add(task);
    }

    public ArrayList<Task> getTasks() { return new ArrayList<Task>(this.tasks.values()); }

    public Map<Volunteer, Set<Task>> getAssignments() { return this.assignments; }

    public ArrayList<Volunteer> getVolunteers() { return this.volunteers; }
}
Comments (0)