private FdmBase GetFdm(ISde sde)
    {
        Console.WriteLine("Create FDM");
        Console.WriteLine("1. Euler, 2. Extrapolated Euler, 3. Milstein, 4. Predictor-Corrector (PC),");
        Console.WriteLine("5. PC adjusted, 6. PC midpoint, 7. Exact, 8. Discrete Milstein,");
        Console.WriteLine("9. Karhunen Loeve, 10. Platen 1.0 strong scheme, 11. Heun");
        Console.WriteLine("12. Derivative Free, 13. FRKI (Runge Kutta), 14. Heun2: ");
        int c = Convert.ToInt32(Console.ReadLine());

        FdmBase fdm;

        int NT = 500;

        Console.Write("How many NT? ");
        NT = Convert.ToInt32(Console.ReadLine());

        double a, b;

        switch (c)
        {
        case 1:

            fdm = new EulerFdm(sde, NT);
            break;

        case 2:

            fdm = new ExtrapolatedEulerFdm(sde, NT);
            break;

        case 3:

            fdm = new MilsteinFdm(sde, NT);
            break;

        case 4:
            a   = 0.5;
            b   = 0.5;
            fdm = new PredictorCorrectorFdm(sde, NT, a, b);
            break;

        case 5:
            a   = 0.5;
            b   = 0.5;
            fdm = new ModifiedPredictorCorrectorFdm(sde, NT, a, b);
            break;

        case 6:
            a   = 0.5;
            b   = 0.5;
            fdm = new MidpointPredictorCorrectorFdm(sde, NT, a, b);
            break;

        case 7:
            fdm = new ExactFdm(sde, NT);
            break;

        case 8:
            fdm = new DiscreteMilsteinFdm(sde, NT);
            break;

        case 9:
            int N = 100;     // Series truncation value
            // IRng rng = new PolarMarsagliaSitmo();

            //     fdm = new KarhunenLoeve(sde, NT, N, rng);
            fdm = new Platen_01_Explicit(sde, NT);
            break;

        case 10:
            fdm = new Platen_01_Explicit(sde, NT);
            break;

        case 11:
            fdm = new Heun(sde, NT);
            break;

        case 12:
            fdm = new DerivativeFree(sde, NT);
            break;

        case 13:
            fdm = new FRKI(sde, NT);
            break;

        case 14:
            fdm = new Heun2(sde, NT);
            break;

        default:
            fdm = new ExtrapolatedEulerFdm(sde, NT);
            break;
        }

        return(fdm);
    }
Beispiel #2
0
    private FdmBase GetFdm(ISde sde)
    {
        Console.WriteLine("Create FDM");
        Console.WriteLine("1. Euler, 2. Extrapolated Euler, 3. Milstein, 4. Predictor-Corrector (PC),");
        Console.WriteLine("5. PC adjusted, 6. PC midpoint, 7. Exact, 8. Discrete Milstein,");
        Console.WriteLine("9. Platen 1.0 strong scheme, 10. Platen 1.0 strong scheme, 11. Heun");
        Console.WriteLine("12. Derivative Free, 13. FRKI (Runge Kutta), 14. Heun2, 15. Fitted PC: ");
        int c = Convert.ToInt32(Console.ReadLine());

        FdmBase fdm;

        int NT;

        Console.Write("How many NT? ");
        NT = Convert.ToInt32(Console.ReadLine());

        double a, b;

        switch (c)
        {
        case 1:

            fdm = new EulerFdm(sde, NT);
            break;

        case 2:

            fdm = null;    // new ExtrapolatedEulerFdm(sde, NT);
            break;

        case 3:

            fdm = new MilsteinFdm(sde, NT);
            break;

        case 4:
            a   = 0.5;
            b   = 0.5;
            fdm = new PredictorCorrectorFdm(sde, NT, a, b);
            break;

        case 5:
            a   = 0.5;
            b   = 0.5;
            fdm = new ModifiedPredictorCorrectorFdm(sde, NT, a, b);
            break;

        case 6:
            a   = 0.5;
            b   = 0.5;
            fdm = new MidpointPredictorCorrectorFdm(sde, NT, a, b);
            break;

        case 7:
            fdm = new ExactFdm(sde, NT, IC, v, r);
            break;

        case 8:
            fdm = new DiscreteMilsteinFdm(sde, NT);
            break;

        case 9:

            fdm = new Platen_01_Explicit(sde, NT);
            break;

        case 10:
            fdm = new Platen_01_Explicit(sde, NT);
            break;

        case 11:
            fdm = new Heun(sde, NT);
            break;

        case 12:
            fdm = new DerivativeFree(sde, NT);
            break;

        case 13:
            fdm = new FRKI(sde, NT);
            break;

        case 14:
            fdm = new Heun2(sde, NT);
            break;

        case 15:
            a   = 0.5;
            b   = 0.5;
            fdm = new FittedMidpointPredictorCorrectorFdm(sde, NT, a, b);
            break;

        default:
            fdm = null;    // new ExtrapolatedEulerFdm(sde, NT);
            break;
        }

        return(fdm);
    }