Come and take it!
Optimization Challenge, MSBA 6310, Summer 2018
Description
Come and take it! was the battle cry during the American revolution in 1778 at Fort Morris,
Georgia, and again in 1835 at the Battle of Gonzales during the Texas Revolution. So it seems we
have a history of ghting the status quo.
When data was gathered for the us_states.csv le, the US population was approximately 275
million people (it is currently believed to be over 300 million). Continuing in the tradition of early
Americans, from time to time various US states (notably Texas and California) threaten to secede
from the Union and become their own country. In this programming challenge, you are a data
scientist for the US government and you have been asked to explore some rudimentary secession
scenarios and what those scenarios might mean for the US Federal government.
Objectives
After participating in this activity, you will be able to:
• Review and solve a real life data analysis scenario that has no one right answer.
• Explore and implement advanced analysis techniques.
• Apply the knowledge and skills you've gained during the rst 6 labs in a holistic manner.
Deliverables
1. Create a new GitHub repository named msba6310-challenge2 to hold your work for this
challenge. This should be a private repository. Only the instructor, TA, you, and your
partner (if any) should have access to this repository. Setup the webhook as you did for your
labs repository.
2. Register your team name to initiate your participation in the programming challenge. You
will not appear on the leaderboard until you register successfully.
3. Write the 2 functions described below and commit each function to your repository in a .py
le of the same name. Each time you commit a new version of a le, it will be evaluated /
timed and the leader board will be updated.
1
Timeline
Unlike a traditional assignment with a singular due date, programming challenges will last approximately
one week each:
• This challenge will begin on Monday (July 30) after class.
• Each time someone commits a new version of a le, it will be evaluated / timed and the leader
board will be updated.
• This challenge will conclude on Monday (Aug 6) at 8am.
• Testing will be conducted the week of July 23. Register and commit early if you want to
participate in the testing phase!
Getting Started
The le border_data.csv contains information on which US states share borders and the length of
each border. Use this le in combination with the us_states.csv le to write two functions:
1. new_nation_n_states: This function accepts 1 parameter (n) and returns the most populous
"new nation" carved out from n US states. The states must be contiguous; that is they must
each share a border with another state in the new nation.
2. new_nation_with_pop: This function accepts 1 parameter (a population, in millions) and
returns a list of all possible new nations, consisting of a minimum number of states, with at
least that many people. Once again the states in each new nation must be contiguous!
Place each function in its own .py le of the same name. For example, the new_nation_n_states
function should go in the new_nation_n_states.py le. Here are some example function calls:
In [1]: new_nation_n_states(1)
Out[1]: (('CA',), 34888000)
In [2]: new_nation_n_states(2)
Out[2]: (('CA', 'AZ'), 39325000)
In [3]: new_nation_n_states(3)
Out[3]: (('WA', 'CA', 'OR'), 44362000)
In [4]: new_nation_n_states(4)
Out[4]: (('NM', 'TX', 'CA', 'AZ'), 61187000)
The most populous US state is California (CA), so it makes sense that the largest nation carved from
1 existing state would simply be CA. The largest nation consisting of 2 states would be California
and Arizona, which share a border, and so on. Here are some additional example function calls:
2
In [1]: new_nation_with_pop(34)
Out[1]: [('CA',)]
In [2]: new_nation_with_pop(40)
Out[2]:
[('WA', 'CA', 'OR'),
('NM', 'CA', 'AZ'),
('NY', 'PA', 'OH'),
('NV', 'CA', 'AZ'),
('CO', 'CA', 'AZ'),
('CA', 'AZ', 'UT'),
('CA', 'AZ', 'OR')]
In [3]: new_nation_with_pop(50)
Out[3]: [('NJ', 'NY', 'PA', 'OH'), ('NM', 'TX', 'CA', 'AZ'), ('NY', 'PA', 'OH', 'MI')]
California has over 30 million people, so the minimum number of states required for a nation of at
least 30 million is just 1. To get at least 40 million people you need a combination of 3 contiguous
states. There are 7 options that have at least 40 million. To get at least 50 million people you need
a combination of 4 contiguous states, and there are 3 options that achieve this result.
Evaluation
Because this is a computationally intense problem, your solution will be given a maximum time
window (about 5 seconds) for evaluation. Your place on the leader board will be calculated using
the following metrics (in this order):
1. Highest n (or pop): A function that calculates for n = 6 in 5 seconds or less will place
higher than a function that can only calculate for n = 4.
2. Time: A function that calculates n = 6 in 4.536 seconds will place higher than a function
that calculates the same n in 4.846 seconds.
In addition, a couple of scenarios will result in not appearing on the leader board or disappearing
from a previously held position:
1. Invalid Solution: For example, the states you return do not border each other or the population
of those states does not add up correctly.
2. Suboptimal Solution: You hold the top spot on the leaderboard with n = 4 and a valid
solution with a population of 70 million. Another team then calculates a solution for n = 4
with a population of only 61,187,000.
3
You will earn up to 60 points for each programming challenge. To allow you to self-select your
personal level of eort, you can expect to earn points according to the following denitions:
Approx.
Approx. Letter
Pts Expectation Grade Description
- Participate only a few times
Up to 45 Meets C - Basic solution with obvious limitations
- Final points based on participation level
- Participate many times over the course of the week
48 52 Exceeds B - Brute force implementations accepted
- Final points based on participation level
- Participate many times over the course of the week
54 60 Outstanding A - Consistently on top of the leader board
- Final points based on participation + performance
A Few Notes
1. Again, please have reasonable expectations of the infrastructure. This is a computationally
intense problem, and performing the evaluations can be time consuming even for the fastest
computer. Per the syllabus we will aim to resolve any and all issues within 24 hours.
2. Please do not attempt to defeat, subvert, or hack the system on your way to the top. Obviously
you could precompute some of these scenarios on a powerful computer and then hard-code
them into your function, but that is not the objective. If you have any question as to what
is an acceptable strategy, please ask! Attempting to subvert the system could result in disqualication
(0 points for the assignment) and in extreme cases could be considered academic
misconduct.
4
版权所有:编程辅导网 2021 All Rights Reserved 联系方式:QQ:99515681 微信:codinghelp 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。