Your core program involves simulating the population in a hypothetical company. This company has a number of ranks of employees, and two or more categories of employees. You can represent the...


Your core program involves simulating the population in a hypothetical company. This company has a number of ranks of employees, and two or more categories of employees. You can represent the population in several ways, but we will use a list of dictionaries. Each dictionary represents one rank in the company hierarchy and maps a category to how many employees of that category are employed at that rank. (You then have a list of these dictionaries to represent the different ranks.)


During each cycle ("generation") of the simulation, you will randomly generate a performance score for each employee. The top 10% are promoted one rank, the bottom 10% are demoted one rank. There is no rank above the "top" rank, so no promotion happens there. There is no rank below the "bottom" rank, so the bottom 10% are fired and replaced by a uniformly random selection of people across the different categories.


The catch is that different categories aren't quite scored fairly. For example, category A might be scored (1,100), but category B is scored (0,99). This is only a 1 percentage point difference, but it will have a much larger than 1 percentage point effect.



Your program should get input from files in its current working directory whose names end with ".company". Process all such files. (This will allow me to easily test your program.)


Each .company file will have the following format:



  1. First line: a name for the company

  2. Second line: the number of generations to simulate

  3. Third line: a JSON-encoded dictionary mapping each category name to the bias (positive or negative) applied to their scores. A bias of 0 means a score range from 1 to 100 inclusive. A bias of -1 gives a range from 0 to 99. A bias of 5 gives a range from 6 to 105. Etc.

  4. Remaining lines: Each a JSON-encoded dictionary mapping each category name to a number of employees. These lines are ordered from the top rank (first) to the bottom rank (last). You may assume that all ranks are the same size. This is a simplifying assumption to make it easier for us to simulate.


Your program should, for each company, print the name of the company and the resulting populations at each rank after the last generation. Please print this in a readable format (i.e. don't just print the dictionaries directly!)

Apr 13, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here