// curve optimization called here- adjust optimization parameters here
            internal void calculate()
            {
                FittingCost costFunction = costFunction_;
                Constraint  constraint   = new NoConstraint();

                // start with the guess solution, if it exists
                Vector x = new Vector(size(), 0.0);

                if (!curve_.guessSolution_.empty())
                {
                    x = curve_.guessSolution_;
                }

                if (curve_.maxEvaluations_ == 0)
                {
                    //Don't calculate, simply use given parameters to provide a fitted curve.
                    //This turns the fittedbonddiscountcurve into an evaluator of the parametric
                    //curve, for example allowing to use the parameters for a credit spread curve
                    //calculated with bonds in one currency to be coupled to a discount curve in
                    //another currency.
                    return;
                }

                //workaround for backwards compatibility
                OptimizationMethod optimization = optimizationMethod_;

                if (optimization == null)
                {
                    optimization = new Simplex(curve_.simplexLambda_);
                }

                Problem problem = new Problem(costFunction, constraint, x);

                double rootEpsilon         = curve_.accuracy_;
                double functionEpsilon     = curve_.accuracy_;
                double gradientNormEpsilon = curve_.accuracy_;

                EndCriteria endCriteria = new EndCriteria(curve_.maxEvaluations_,
                                                          curve_.maxStationaryStateIterations_,
                                                          rootEpsilon,
                                                          functionEpsilon,
                                                          gradientNormEpsilon);

                optimization.minimize(problem, endCriteria);
                solution_ = problem.currentValue();

                numberOfIterations_ = problem.functionEvaluation();
                costValue_          = problem.functionValue();

                // save the results as the guess solution, in case of recalculation
                curve_.guessSolution_ = solution_;
            }