JSoC 2020 : Working with Differential Equations and Neural Networks
I was selected for JSoC 2020 for the project "Neural Networks for solving differential equations". It took me a while to understand the workflow before writing the proposal. My mentor Chris Rackauckas guided me through the entire project.
I first started finishing my existing work on Kolmogorov Equations solver. And then moved on to the next, optimal stopping problem solver.
For understanding Optimal Stopping Problem, we can take an example of an American Option. An American option can be exercised before its maturity and thus we need to determine an optimal stopping time to exercise the American option given the discounted pay-off function at the maturity time T. Considering that we can model a stock price at any time t as a solution to following SDE :
We intend to calculate :
Role of Neural networks:
We first discretise the above problem using Euler-Maruyama Scheme.
In order to calculate the above supremum we express this as:
Clearly the sum over all n of inline_formula not implemented is one. The second term in the above expression checks if it is already one for some k. We take inline_formula not implemented as our neural network with N-dimensional output and thus the problem reduces to a standard maximisation problem. Another important property of the model is that the last layer should always be a softmax function in order to satisfy the sum over n equals one condition.
Defining the Problem and solver code:
We define this as a simple SDEProblem based on the process the stock follows as mentioned in the first equation and pass the terminal condition as an additional argument.
First things first , Adding and pre-compiling necessary dependencies:
Defining a problem with inline_formula not implemented and inline_formula not implemented Considering N = 50, we define a dt. In the below test case we are considering an American Max Put Option wherein the discounted pay-off function is given as :
formula not implemented
K is the strike price of the option and d is dimension of the option
Current loss is: 2524.253987862823
Current loss is: 2489.263232272373
Current loss is: 2471.457534305023
Current loss is: 2458.9085680322796
Current loss is: 2447.2153805159915
Current loss is: 2435.3093299294724
Current loss is: 2429.9547728037087
Current loss is: 2422.8942299221344
Current loss is: 2414.988211734707
Current loss is: 2412.6343432123012
Current loss is: 2412.2056946202247
Current loss is: 2412.124209968425
Current loss is: 2412.106143915984
Current loss is: 2412.101580404619
Current loss is: 2412.100316748297
Current loss is: 2412.0999285616
Current loss is: 2412.100169640128
Current loss is: 2412.0996839795744
Current loss is: 2412.0998712077762
Current loss is: 2412.100056927651
We test the price against the Binomial Tree method, for different initial values we obtain :
The accuracy of above graph tend to improve on increasing the number of trajectories.
Post Optimal Stopping Time Problem :
After this task was merged , I moved on to the following tasks :
Adding GPU and some extra features to the Kolmogorov Solver in order to improve the next task i.e. the tutorial.