Optimization problem for CIR Cap Calibration.
Inheritance: IOptimizationProblem
コード例 #1
0
        /// <summary>
        /// Attempts a calibration through <see cref="CapsCIROptimizationProblem"/>
        /// using caps matrices.
        /// </summary>
        /// <param name="data">The data to be used in order to perform the calibration.</param>
        /// <param name="settings">The parameter is not used.</param>
        /// <param name="controller">A controller used for the optimization process.</param>
        /// <returns>The results of the calibration.</returns>
        public EstimationResult Estimate(List<object> data, IEstimationSettings settings = null, IController controller = null, Dictionary<string, object> properties = null)
        {
            InterestRateMarketData dataset = data[0] as InterestRateMarketData;

            // Creates the context.
            Document doc = new Document();
            ProjectROV prj = new ProjectROV(doc);
            doc.Part.Add(prj);

            CapCIROptimizationProblem problem = new CapCIROptimizationProblem(dataset);
            IOptimizationAlgorithm solver = new QADE();
            IOptimizationAlgorithm solver2 = new SteepestDescent();

            DESettings o = new DESettings();
            o.NP = 50;
            o.MaxIter = 50;
            o.Verbosity = 1;
            o.Parallel = false;
            o.controller = controller;
            SolutionInfo solution = null;

            Vector x0 = new Vector(new double[] { 1, 0.01, 0.05 });
            solution = solver.Minimize(problem, o, x0);
            if (solution.errors)
                return new EstimationResult(solution.message);

            o.epsilon = 10e-10;
            o.h = 10e-10;
            o.MaxIter = 1000;

            if (solution != null)
                solution = solver2.Minimize(problem, o, solution.x);
            else
                solution = solver2.Minimize(problem, o, x0);

            if (solution.errors)
                return new EstimationResult(solution.message);

            Console.WriteLine("Solution:");
            Console.WriteLine(solution);
            string[] names = CIR.parameterNames;
            Vector values = new Vector(4);
            values[Range.New(0, 2)] = solution.x;
            values[3] = problem.r0;

            EstimationResult result = new EstimationResult(names, values);

            return result;
        }
コード例 #2
0
        /// <summary>
        /// Attempts a calibration through <see cref="CapsCIROptimizationProblem"/>
        /// using caps matrices.
        /// </summary>
        /// <param name="data">The data to be used in order to perform the calibration.</param>
        /// <param name="settings">The parameter is not used.</param>
        /// <param name="controller">A controller used for the optimization process.</param>
        /// <returns>The results of the calibration.</returns>
        public EstimationResult Estimate(List <object> data, IEstimationSettings settings = null, IController controller = null, Dictionary <string, object> properties = null)
        {
            InterestRateMarketData dataset = data[0] as InterestRateMarketData;

            // Creates the context.
            Document   doc = new Document();
            ProjectROV prj = new ProjectROV(doc);

            doc.Part.Add(prj);

            CapCIROptimizationProblem problem = new CapCIROptimizationProblem(dataset);
            IOptimizationAlgorithm    solver  = new QADE();
            IOptimizationAlgorithm    solver2 = new SteepestDescent();

            DESettings o = new DESettings();

            o.NP         = 50;
            o.MaxIter    = 50;
            o.Verbosity  = 1;
            o.Parallel   = false;
            o.controller = controller;
            SolutionInfo solution = null;

            Vector x0 = new Vector(new double[] { 1, 0.01, 0.05 });

            solution = solver.Minimize(problem, o, x0);
            if (solution.errors)
            {
                return(new EstimationResult(solution.message));
            }

            o.epsilon = 10e-10;
            o.h       = 10e-10;
            o.MaxIter = 1000;

            if (solution != null)
            {
                solution = solver2.Minimize(problem, o, solution.x);
            }
            else
            {
                solution = solver2.Minimize(problem, o, x0);
            }

            if (solution.errors)
            {
                return(new EstimationResult(solution.message));
            }

            Console.WriteLine("Solution:");
            Console.WriteLine(solution);
            string[] names  = CIR.parameterNames;
            Vector   values = new Vector(4);

            values[Range.New(0, 2)] = solution.x;
            values[3] = problem.r0;

            EstimationResult result = new EstimationResult(names, values);

            return(result);
        }