diff --git a/src/Solvers/DESolver.h b/src/Solvers/DESolver.h index f3c3379778470720355f449ca9583211514cd2db..968ee5fed85cc8cf7bf020cfb7cbae37fccefaad 100644 --- a/src/Solvers/DESolver.h +++ b/src/Solvers/DESolver.h @@ -6,6 +6,7 @@ */ //TODO incorporate uncertainities as coefficients in NeuralNetworkSum or ErrorSum + //TODO add support for multiple unknown functions to be found #ifndef INC_4NEURO_PDESOLVER_H #define INC_4NEURO_PDESOLVER_H diff --git a/src/main.cpp b/src/main.cpp index 501274bfa9a20e6feeb48810661adbb9afa5c053..2e5468a0d9bbaca2f323b6272f1225981e2d47ed 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -44,14 +44,14 @@ void test1( ){ ////////////////////// END SIMPLE EDGE WEIGHT //////////////////////////////////////// /////////////////////////BEGIN OF COMPLEX EDGE WEIGHT////////////////////////////// - std::function<double(double *, int*, int)> weight_function = [](double * weight_array, int * index_array, int n_params){ + std::function<double(double *, size_t*, size_t)> weight_function = [](double * weight_array, size_t * index_array, size_t n_params){ //w(x, y) = x + y double a = weight_array[index_array[0]]; double b = weight_array[index_array[1]]; // printf("eval: %f, %f\n", a, b); return (a + 0.0 * b); }; - int weight_indices [2] = {0, -1}; + size_t weight_indices [2] = {0, 1}; double weight_values [2] = {1.0, 5.0}; net.add_connection_general(idx1, idx2, &weight_function, weight_indices, weight_values, 2); /////////////////////////END OF COMPLEX EDGE WEIGHT////////////////////////////// diff --git a/src/tests/ErrorFunctions_test.cpp b/src/tests/ErrorFunctions_test.cpp index 16af741d9eb6be2bd0cac816c2ff1140776a7a83..550e71983c828a9efb3099c63c3603131a74bebc 100644 --- a/src/tests/ErrorFunctions_test.cpp +++ b/src/tests/ErrorFunctions_test.cpp @@ -91,7 +91,7 @@ BOOST_AUTO_TEST_SUITE(ErrorFunctions_test) } BOOST_AUTO_TEST_CASE(ErrorFunction_MSE_SUM_Construction_Test) { - BOOST_CHECK_NO_THROW(MSE_SUM mse_sum); + BOOST_CHECK_NO_THROW(ErrorSum mse_sum); } BOOST_AUTO_TEST_CASE(ErrorFunction_MSE_SUM_Add_Error_Function_Test) { @@ -107,12 +107,12 @@ BOOST_AUTO_TEST_SUITE(ErrorFunctions_test) ErrorFunction *f = new MSE(&network, &dataSet); - MSE_SUM mse_sum; + ErrorSum mse_sum; BOOST_CHECK_NO_THROW(mse_sum.add_error_function(f)); } BOOST_AUTO_TEST_CASE(ErrorFunction_MSE_SUM_Eval_Test) { - MSE_SUM mse_sum; + ErrorSum mse_sum; double weights[1] = {0}; Neuron *n1 = new NeuronLinear(1, 1); @@ -146,7 +146,7 @@ BOOST_AUTO_TEST_SUITE(ErrorFunctions_test) } BOOST_AUTO_TEST_CASE(ErrorFunction_MSE_SUM_Get_Dimension_test) { - MSE_SUM mse_sum; + ErrorSum mse_sum; BOOST_CHECK_EQUAL(0, mse_sum.get_dimension()); Neuron *n1 = new NeuronLinear(1, 1); diff --git a/src/tests/NeuralNetwork_test.cpp b/src/tests/NeuralNetwork_test.cpp index 7f5f672f086803c394c484ba10d3d7ae610c5296..0a6c0585c6f465f8e79791ca0c88cab505f3a03e 100644 --- a/src/tests/NeuralNetwork_test.cpp +++ b/src/tests/NeuralNetwork_test.cpp @@ -65,12 +65,12 @@ BOOST_AUTO_TEST_SUITE(NeuralNetwork_test) Neuron *n2 = new NeuronLinear(2, 2); network.add_neuron(n1); network.add_neuron(n2); - std::function<double(double *, int *, int)> f = [](double *weight_array, int *index_array, int n_params) { + std::function<double(double *, size_t *, size_t)> f = [](double *weight_array, size_t *index_array, size_t n_params) { double a = weight_array[0]; double b = weight_array[1]; return (a + 1.5 * b); }; - int para[5] = {0, 1, 2, 3, 4}; + size_t para[5] = {0, 1, 2, 3, 4}; double w_array[5] = {1, 2, 3, 4, 5}; network.add_connection_general(0, 1, &f, para, w_array, 5); diff --git a/src/tests/NeuronLinear_test.cpp b/src/tests/NeuronLinear_test.cpp index 07e96ae151666eb565e91ed3eaad8f70f8fd85af..85efdf634558eb3c304d490ab3ee01d59e2a350b 100644 --- a/src/tests/NeuronLinear_test.cpp +++ b/src/tests/NeuronLinear_test.cpp @@ -44,11 +44,11 @@ BOOST_AUTO_TEST_SUITE(neuronLinear_test) NeuronLinear neuron(5.0, 3.0); //Test of correct output of activation_function_get_derivative method - BOOST_CHECK_EQUAL(3.0, neuron.activation_function_get_derivative()); + BOOST_CHECK_EQUAL(3.0, neuron.activation_function_eval_derivative()); //Tests of correct outputs of activation_function_get_partial_derivative method - BOOST_CHECK_EQUAL(1.0, neuron.activation_function_get_partial_derivative(0)); - BOOST_CHECK_EQUAL(0.0, neuron.activation_function_get_partial_derivative(1)); - BOOST_CHECK_EQUAL(0.0, neuron.activation_function_get_partial_derivative(10000)); + BOOST_CHECK_EQUAL(1.0, neuron.activation_function_eval_partial_derivative(0)); + BOOST_CHECK_EQUAL(0.0, neuron.activation_function_eval_partial_derivative(1)); + BOOST_CHECK_EQUAL(0.0, neuron.activation_function_eval_partial_derivative(10000)); } BOOST_AUTO_TEST_SUITE_END() diff --git a/src/tests/NeuronLogistic_test.cpp b/src/tests/NeuronLogistic_test.cpp index 4edab726dee04646407b9f3c724cfb46a576bc50..1baaef5082e4e41128e2e06c31d3420d435d733f 100644 --- a/src/tests/NeuronLogistic_test.cpp +++ b/src/tests/NeuronLogistic_test.cpp @@ -44,11 +44,11 @@ BOOST_AUTO_TEST_SUITE(neuronLogistic_test) NeuronLogistic neuron(3.0, 2.0); //Test of correct output of activation_function_get_derivative method - BOOST_CHECK_CLOSE(0.0042850850699, neuron.activation_function_get_derivative(), 0.00001); + BOOST_CHECK_CLOSE(0.0042850850699, neuron.activation_function_eval_derivative(), 0.00001); //Tests of correct outputs of activation_function_get_partial_derivative method - BOOST_CHECK_CLOSE(-0.0068569236644, neuron.activation_function_get_partial_derivative(0), 0.00001); - BOOST_CHECK_CLOSE(-0.0042850850699, neuron.activation_function_get_partial_derivative(1), 0.00001); - BOOST_CHECK_EQUAL(0.0, neuron.activation_function_get_partial_derivative(10000)); + BOOST_CHECK_CLOSE(-0.0068569236644, neuron.activation_function_eval_partial_derivative(0), 0.00001); + BOOST_CHECK_CLOSE(-0.0042850850699, neuron.activation_function_eval_partial_derivative(1), 0.00001); + BOOST_CHECK_EQUAL(0.0, neuron.activation_function_eval_partial_derivative(10000)); } BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file diff --git a/src/tests/NeuronTanh.cpp b/src/tests/NeuronTanh.cpp index 951b30dc36821ef40325edbb4e8daca7127c8658..cac6e0982d00011a03c6917ca6f5b439e7527d96 100644 --- a/src/tests/NeuronTanh.cpp +++ b/src/tests/NeuronTanh.cpp @@ -42,10 +42,10 @@ BOOST_AUTO_TEST_SUITE(neuronTanh_test) NeuronTanh neuron(2.0); //Test of correct output of activation_function_get_derivative method - BOOST_CHECK_CLOSE(-0.0706508248531644, neuron.activation_function_get_derivative(), 0.00001); + BOOST_CHECK_CLOSE(-0.0706508248531644, neuron.activation_function_eval_derivative(), 0.00001); //Tests of correct outputs of activation_function_get_partial_derivative method - BOOST_CHECK_CLOSE(-0.0706508248531644, neuron.activation_function_get_partial_derivative(0), 0.00001); - BOOST_CHECK_EQUAL(0.0, neuron.activation_function_get_partial_derivative(10000)); + BOOST_CHECK_CLOSE(-0.0706508248531644, neuron.activation_function_eval_partial_derivative(0), 0.00001); + BOOST_CHECK_EQUAL(0.0, neuron.activation_function_eval_partial_derivative(10000)); } BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file