#include #include #include #include #include #include "minimization.h" /**************************************************************************************************/ /************* This is the place where you code your goal function to be minimized ************/ /**************************************************************************************************/ float a, b, c, d; float my_gaol_function() { float res; /* a quadratic test case, with a minimum in (a,b) = (0 , 0) */ res = (a - 1.0)*(a + 1.0) + b*b + c*c + d*d; /* a function with a banana-like deep valley : minimum in (a,b) = (1.0, 1.0) */ /* res = 10.0*(a*a - b)*(a*a - b) + (1-a)*(1-a); */ return res; } void test_tuning(void) { float tolerance; a = 20.5; b = 0.5; c = 0.0; d = 0.0; record_coefficient_to_tune(&a, "a", 1); /* active */ record_coefficient_to_tune(&b, "b", 1); /* active */ record_coefficient_to_tune(&c, "c", 0); /* inactive */ record_coefficient_to_tune(&d, "d", 0); /* inactive */ record_function_to_minimize(&my_gaol_function); init_goal_value_cache(); tolerance = 0.001; tune_parameters_by_conjugate_gradients(tolerance); free_goal_value_cache(); free_tuned_parameters(); } int main(void) { test_tuning(); }