public void OptimizersTest() { //("Testing optimizers..."); setup(); // Loop over problems (currently there is only 1 problem) for (int i=0; i<costFunctions_.Count; ++i) { Problem problem = new Problem(costFunctions_[i], constraints_[i], initialValues_[i]); Vector initialValues = problem.currentValue(); // Loop over optimizers for (int j = 0; j < (optimizationMethods_[i]).Count; ++j) { double rootEpsilon = endCriterias_[i].rootEpsilon(); int endCriteriaTests = 1; // Loop over rootEpsilon for(int k=0; k<endCriteriaTests; ++k) { problem.setCurrentValue(initialValues); EndCriteria endCriteria = new EndCriteria(endCriterias_[i].maxIterations(), endCriterias_[i].maxStationaryStateIterations(), rootEpsilon, endCriterias_[i].functionEpsilon(), endCriterias_[i].gradientNormEpsilon()); rootEpsilon *= .1; EndCriteria.Type endCriteriaResult = optimizationMethods_[i][j].optimizationMethod.minimize(problem, endCriteria); Vector xMinCalculated = problem.currentValue(); Vector yMinCalculated = problem.values(xMinCalculated); // Check optimization results vs known solution if (endCriteriaResult==EndCriteria.Type.None || endCriteriaResult==EndCriteria.Type.MaxIterations || endCriteriaResult==EndCriteria.Type.Unknown) Assert.Fail("function evaluations: " + problem.functionEvaluation() + " gradient evaluations: " + problem.gradientEvaluation() + " x expected: " + xMinExpected_[i] + " x calculated: " + xMinCalculated + " x difference: " + (xMinExpected_[i]- xMinCalculated) + " rootEpsilon: " + endCriteria.rootEpsilon() + " y expected: " + yMinExpected_[i] + " y calculated: " + yMinCalculated + " y difference: " + (yMinExpected_[i]- yMinCalculated) + " functionEpsilon: " + endCriteria.functionEpsilon() + " endCriteriaResult: " + endCriteriaResult); } } } }