/** * This program conducts a genetic algorithm on "chromosomes" of * 6 real parameters a1, b1, c1, a2, b2, c2 maximizing whatever * function is supplied at the method "objective". Here that function * is supplied by the java class amerputExerBoundary; a program that * is outlined in the text as Algorithm 14 in Section 3.5.6. * * Created on 9/3/2010 * * (c) Copyright Ronald W. Shonkwiler * All rights reserved. * * RSS style GA to find the value of an American put option * This will be the maximum option value over all possible * exercise boundary curves. * Each curve is the sum of two parameterized log functions * * Adjust the parameters dfS0, dfX, ... just below using an editor * and recompile. */ import java.util.*; import static java.lang.System.err; public class amerputGAweb { static int nIterations= 20; //120; //GA generations static int nTrials = 3; static double dfS0 = 100; //default S0 static double dfX = 100; //default X static int dfnDays = 40; //default T in days static double dfrfr = 0.26; //risk-free rate static double dfvol = 0.40; //volatility static double dtINdays = 5; //1 for daily, could be fractional static double daysInYr = 365; static String TinYears = new String(String.format("%.2f",dfnDays/daysInYr)); static String yearVSyears = new String( (TinYears.equals("1.0")?"year":"years")); static String[] helptext = { "Implementation of the RSS style GA for maximizing an American.", "put option value over parameterized exercise boundary curves.", "Using the following parameters (change in source and recompile)", " -S default "+dfS0+"", " -X default "+dfX+"", " -T