Key Information

Register
Submit
The challenge is finished.

Challenge Overview

This code challenge has been set up to allow submission of MATLAB solutions for the “How Much Should A Nation Save” Marathon Match that is currently running in parallel with this one.  Each day submissions from this challenge will be tested and included in the marathon match leaderboard.  By submitting to this challenge you are participating in that Marathon Match.  You do not need to wait for the submission deadline to submit your solution as you would for a typical code challenge.  Our testers will be working behind the scenes to score your solution and include the results in the leaderboard.   You may not submit both a MATLAB and non-MATLAB solution.  Just one solution type per Topcoder member please.

MATLAB Support!

Free MATLAB! Mathworks has very kindly agreed to support this challenge by granting access to MATLAB to competitors! Competitors can click here to request software from MATLAB. License periods are 30 days.  Here is the link to the trial instructions.

Prizes

There are no separate prizes for the MATLAB submissions but there are prizes available for the Marathon Match as a whole.  By submitting to this Code challenge you will be participating in the “How Much Should A Nation Save” Marathon Match and will be eligible for one of the following prizes.

1st - $2000
2nd - $1250
3rd - $750
4th - $500
5th - $400
6th - $300
7th - $200
8th - $100
Total - $5,500

Additional Opportunities ($1,200 + Co-Authoring)

An additional (12) $100 awards will be awarded to the 12 best write-ups that competitors (winners and non-winners) submit to describe their approach used. These methods will be evaluated by a panel of experts from MIT and Crowd Innovation Laboratory at Harvard University. The main evaluation criteria are validity, flexibility, performance and originality. The competitors having developed the best approach, as judged by Harvard and MIT, will not only have a chance to win an extra $100 per person but may also be invited as co-authors to write a research paper featuring the results of the challenge. Note that winners are required to write a description of the approach used to be awarded any of the prizes (see the "Requirements To Win A Prize" section below).

Background

How much of its income should a nation save? To tackle this problem, economists traditionally use mathematical models focused on the decisions of a representative agent living for T periods. At each period, the agent chooses how much to consume and save while facing uncertainty about future income. The agent's overall well-being is measured by a utility function that is increasing in consumption and the utility of future consumption is discounted by a factor β < 1. The agent gets an income that can be either consumed or invested into capital Kt+1. The returns on this investment are uncertain and will generate the agent's income in the next period.

In this challenge, your task is to develop an algorithm that dictates how much the agent should consume and save at each period in order to maximize his or her expected well-being. This task can be thought of as if you were the main adviser of a policy maker that is deciding about the optimal level of investments of a country in order to maximize the national welfare.

This match is first of two challenges which will take place this year in this problem domain.

Objective

You have to make a series of decisions about consumption Ct and invested capital Kt+1 to solve the following maximization problem.

The operator Et is the expectation with respect to consumption at a given time t. Your preferences towards consumption in a given period are characterized by the following utility function.

You'd rather prefer to consume a given quantity today than tomorrow. That is, utility in future periods is discounted by a discounting factor 0 < β < 1. The sum of consumption and invested capital must be less than or equal to the wage Wt which is determined by:

where 1 ≤ δ < 0 is the depreciation rate of capital, 0 < α < 1 is the productivity of capital and Zt is the realization of an exogenous random variable distributed as follows.

where 0 < ρ < 1 is the degree of correlation with past shocks and εt is a normal random variable with zero mean and standard deviation σ. Initial conditions K0 > 0 and Z0 > 0 are given.

To solve the problem, you have to develop a decision rule for consumption which delivers the optimal choice of consumption Ct as a function of the level of capital Kt, the realized shock Zt, and the parameters of the economy that satisfies the following optimality conditions.

Analytical decision rules that satisfy these optimality conditions are not known. Researchers typically turn to numerical methods to find approximate solutions. For example, a standard procedure is based upon a Taylor's series expansion of the decision rule when shocks are deterministic. The effectiveness of many of these algorithms is discussed by Taylor and Uhlig (1990). You are encouraged to implement one of such methods or come up with a new one.

Functions

Your task is to develop two functions: SetEconomyParameters and ConsumptionDecisionRule.

SetEconomyParameters will be called once at the beginning of each test case. ConsumptionDecisionRule will be called iteratively T times for each test case (for times t = 0 to t = T-1) with each call considering N concurrent simulations.

SetEconomyParameters receives the following arguments:

β (beta) - Future utility discount factor

η (eta) - Consumption utility parameter

α (alpha) - Productivity of capital

δ (delta) - Depreciation rate of capital

ρ (rho) - Degree of correlation with previous shocks

σ (sigma) - Standard deviation of εt

N - Number of concurrent simulations

T - Total number of time periods

ConsumptionDecisionRule receives the following arguments:

Kt - Invested capital at current time for each of the N concurrent simulations

Zt - Shock at current time for each of the N concurrent simulations

ConsumptionDecisionRule must return the consumption for this time period for each of the N concurrent simulations. Consumption at each time period for each simulation must be real, non-negative, and not greater than the current wage.

Data Sets

Test cases are defined by a specific configuration of the economy's parameters, the time horizon T, and the number of simulations N. Test cases have been randomly split into three sets: example, provisional, and system. The example set contains 800 test cases can be downloaded here. The provisional set contains 400 test cases and is used for provisional scoring. The system set contains 800 test cases and is used for system testing resulting in your final score.

Scoring

For each test case, the method ConsumptionDecisionRule is called iteratively for each time t from t = 0 to t = T-1.

- Each test case has N simulations of the shocks and each simulation runs for T periods.

- In each iteration t < T of a simulation i, the evaluation program computes the wage Wt of the period, given the realized variable εt and the initial conditions Zt-1 and Kt. Using your implemented decision rule, a consumption Ct is computed. This step also gives the capital in the next period Kt+1, given the budget constraint. All values are then saved and used as initial conditions for the next iteration.

- At the last iteration t = T of a simulation, we do not request a decision for the last period but make an arbitrary choice to consume the entire capital.

- At this point, it computes (the deterministic version of) the Euler conditions residuals in each period where i is the index of the current simulation:

- This value is then averaged as follows.

Where

Your score for each test case is the averaged Euler conditions residuals over all N simulations multiplied by 1,000,000. Scores over each test case in a set of test cases (example, provisional, or system) are averaged to find your final score.

Limits

- Each test case must complete within 120 seconds.

- The memory limit is 2048 megabytes.

- There is no explicit code size limit. The implicit source code size limit is around 1 MB (it is not advisable to submit codes of size close to that or larger).

General Notes

- You can include open source code in your submission, provided it is free for you to use and would be for the client as well. Code from open source libraries under the Apache2, BSD or MIT licenses will be accepted. Other open source licenses may be accepted too, just be sure to ask us first.

- We’ll be executing the provisional and system tests with the most recent version of MATLAB - R2016a.  This is the same version provided in the trial above.

- Use the Code Questions forum attached to this code challenge to ask general questions or report problems, but please do not post comments and questions that reveal information about the problem itself or possible solution techniques.   

 

Requirements to Win a Prize

In order to receive a prize, you must do all the following:

- Achieve a score in the top 8 according to system test results (see the Scoring section above).

- Within 7 days from the announcement of the challenge winners, complete a full description of your approach through an online survey. Topcoder will send qualifying contestants a URL to the survey that should be completed.

- We must be able to reproduce your solution. If any parameters were obtained from the training data set, you will also need to provide the program(s) used to generate these parameters. There is no restriction on the programming language/libraries used to generate these training parameters, provided they are in accordance with the restrictions listed above.

- To win one of the “Write-Up” prizes ($100 each) above it is suggested that you include a written explanation about your algorithm and approach and send it to the copilot.   



Final Submission Guidelines

1. Only MATLAB code will be accepted in this code challenge.

2. You may submit code multiple times over the course of the challenge.  You do not need to wait until the submission deadline to submit your submission.

3.  Our testers are going to strive to update the leaderboard with the scores from the latest submission you’ve provided once per day if it has been updated.  If participation is very high with MATLAB submissions, the interval could be longer -- 36 or 48 hours.

4.  You should create two MATLAB scripts for your submission:

a. ConsumptionDecisionRule.m should contain a ConsumptionDecisionRule function with the same signature as this example function which always uses 50% consumption:

function [ C_t ] = ConsumptionDecisionRule( K_t, Z_t )

   global beta eta alpha delta rho sigma N T

   W_t = (1 - delta) * K_t + Z_t .* (K_t .^ alpha);

   C_t = 0.5 * W_t;

End

b. SetEconomyParameters.m should contain a SetEconomyParameter function with the same signature as this example function:

function [] = SetEconomyParameters( beta_, eta_, alpha_, delta_, rho_, sigma_, N_, T_ )

   global beta eta alpha delta rho sigma N T

   beta = beta_;

   eta = eta_;

   alpha = alpha_;

   delta = delta_;

   rho = rho_;

   sigma = sigma_;

   N = N_;

   T = T_;

End

5.  The MATLAB test script (NationSaveTester.m) which will call these two functions is provided.  You can find this in the Code Document forums attached to this challenge. 

 

ELIGIBLE EVENTS:

2016 TopCoder(R) Open

REVIEW STYLE:

Final Review:

Community Review Board

Approval:

User Sign-Off

SHARE:

ID: 30055018