Commit 9554bb47 authored by Martin Beseda's avatar Martin Beseda

Merge branch 'dev'

parents c6d023eb a86ff2e6
Summary **Summary**
(Summarize the bug encountered concisely) (Summarize the bug encountered concisely)
Steps to reproduce **Steps to reproduce**
(How one can reproduce the issue - this is very important) (How one can reproduce the issue - this is very important)
What is the current bug behavior? **What is the current bug behavior?**
(What actually happens) (What actually happens)
What is the expected correct behavior? **What is the expected correct behavior?**
(What you should see instead) (What you should see instead)
Relevant logs and/or screenshots **Relevant logs and/or screenshots**
(Paste any relevant logs - please use code blocks (```) to format console output, (Paste any relevant logs - please use code blocks (```) to format console output,
logs, and code as it's very hard to read otherwise.) logs, and code as it's very hard to read otherwise.)
Possible fixes **Possible fixes**
(If you can, link to the line of code that might be responsible for the problem) (If you can, link to the line of code that might be responsible for the problem)
......
Summary **Summary**
(Summarize the bug encountered concisely) (Summarize the bug encountered concisely)
Associated classes **Associated classes**
(Classes, which need to be modified, if any) (Classes, which need to be modified, if any)
......
################################################################################ ################################################################################
# #
# CMake script for finding ExprTk. # CMake script for finding ExprTk.
# The default CMake search process is used to locate files. # The default CMake search process is used to locate files.
# #
# This script creates the following variables: # This script creates the following variables:
# EXPRTK_FOUND: Boolean that indicates if the package was found # EXPRTK_FOUND: Boolean that indicates if the package was found
# EXPRTK_INCLUDE_DIRS: Paths to the necessary header files # EXPRTK_INCLUDE_DIRS: Paths to the necessary header files
# #
################################################################################ ################################################################################
# Find headers and libraries # Find headers and libraries
FIND_PATH( FIND_PATH(
EXPRTK_INCLUDE_DIR EXPRTK_INCLUDE_DIR
NAMES NAMES
exprtk.hpp exprtk.hpp
HINTS HINTS
$ENV{EXPRTK_INCLUDE_DIR} $ENV{EXPRTK_INCLUDE_DIR}
$ENV{EXPRTK_ROOT} $ENV{EXPRTK_ROOT}
${EXPRTK_ROOT} ${EXPRTK_ROOT}
PATHS PATHS
/usr/local /home
/usr /usr/local
/opt/local /usr
PATH_SUFFIXES /opt/local
include PATH_SUFFIXES
) include
# Set EXPRTK_FOUND honoring the QUIET and REQUIRED arguments )
INCLUDE(FindPackageHandleStandardArgs) # Set EXPRTK_FOUND honoring the QUIET and REQUIRED arguments
FIND_PACKAGE_HANDLE_STANDARD_ARGS( INCLUDE(FindPackageHandleStandardArgs)
ExprTk FIND_PACKAGE_HANDLE_STANDARD_ARGS(
"ExprTk was NOT found!" ExprTk
EXPRTK_INCLUDE_DIR) "ExprTk was NOT found!"
EXPRTK_INCLUDE_DIR)
# Output variables
IF(EXPRTK_FOUND) # Output variables
# Include dirs IF(EXPRTK_FOUND)
SET(EXPRTK_INCLUDE_DIRS ${EXPRTK_INCLUDE_DIR}) # Include dirs
ELSE() SET(EXPRTK_INCLUDE_DIRS ${EXPRTK_INCLUDE_DIR})
MESSAGE(FATAL_ERROR "Set, please, the variable EXPRTK_INCLUDE_DIR to the folder, where 'exprtk.hpp' is located..") ELSE()
ENDIF(EXPRTK_FOUND) MESSAGE(FATAL_ERROR "Set, please, the variable EXPRTK_INCLUDE_DIR to the folder, where 'exprtk.hpp' is located..")
ENDIF(EXPRTK_FOUND)
# Advanced options for not cluttering the cmake UIs:
MARK_AS_ADVANCED(EXPRTK_INCLUDE_DIR) # Advanced options for not cluttering the cmake UIs:
MARK_AS_ADVANCED(EXPRTK_INCLUDE_DIR)
include_directories(${EXPRTK_INCLUDE_DIRS})
include_directories(${EXPRTK_INCLUDE_DIRS})
...@@ -41,14 +41,14 @@ ...@@ -41,14 +41,14 @@
and go to the folder with `Boost` and go to the folder with `Boost`
``` ```
cd FOLDER_WITH_BOOST cd "folder with Boost"
bootstrap.bat bootstrap.bat
b2.exe --build-type=complete b2.exe --build-type=complete
``` ```
- set `BOOST_ROOT` variable to the path of your folder with `Boost` - set `BOOST_ROOT` variable to the path of your folder containing `Boost`
``` ```
setx BOOST_ROOT YOUR_PATH setx BOOST_ROOT "path to your Boost folder"
``` ```
- go to the `lib4neuro` folder and run - go to the `lib4neuro` folder and run
......
...@@ -15,4 +15,4 @@ set MAKEFILE_GENERATOR="Visual Studio 15 2017" ...@@ -15,4 +15,4 @@ set MAKEFILE_GENERATOR="Visual Studio 15 2017"
call clean.bat call clean.bat
cmake -G %MAKEFILE_GENERATOR% -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -DCMAKE_BUILD_TYPE=%BUILD_TYPE% -DCMAKE_CXX_COMPILER=%CXX_COMPILER% -DCMAKE_C_COMPILER=%C_COMPILER% -DBOOST_ROOT=%BOOST_ROOT% -DBOOST_LIBRARYDIR=%BOOST_LIBRARYDIR% -DBOOST_INCLUDEDIR=%BOOST_INCLUDEDIR% -DBoost_DEBUG:BOOL=ON . cmake -G %MAKEFILE_GENERATOR% -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -DCMAKE_BUILD_TYPE=%BUILD_TYPE% -DCMAKE_CXX_COMPILER=%CXX_COMPILER% -DCMAKE_C_COMPILER=%C_COMPILER% -DBOOST_ROOT=%BOOST_ROOT% -DBOOST_LIBRARYDIR=%BOOST_LIBRARYDIR% -DBOOST_INCLUDEDIR=%BOOST_INCLUDEDIR% -DBoost_DEBUG:BOOL=ON .
cmake --build . --config %BUILD_TYPE% && (echo Build complete.) || (echo "Build finished with errors!") cmake --build . --config %BUILD_TYPE% && (echo (Build complete.); echo (For examples have a look at the folder build/bin/examples.)) || (echo "Build finished with errors!")
...@@ -13,4 +13,4 @@ CXX_COMPILER="g++-8" ...@@ -13,4 +13,4 @@ CXX_COMPILER="g++-8"
$(pwd)/clean.sh $(pwd)/clean.sh
cmake -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DCMAKE_CXX_COMPILER=${CXX_COMPILER} . cmake -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DCMAKE_CXX_COMPILER=${CXX_COMPILER} .
cmake --build . --config ${BUILD_TYPE} -- -j${N_CORES} && (tput setaf 2; echo "Build complete."; tput sgr 0; ) || (tput setaf 1; echo "Build finished with errors!"; tput sgr 0; exit 1;) cmake --build . --config ${BUILD_TYPE} -- -j${N_CORES} && (tput setaf 2; echo "Build complete."; echo "For examples have a look at the folder build/bin/examples."; tput sgr 0; ) || (tput setaf 1; echo "Build finished with errors!"; tput sgr 0; exit 1;)
#TODO uncomment add_subdirectory(tests bin/unit-tests)
#add_subdirectory(tests bin/unit-tests) add_subdirectory(examples bin/examples)
add_subdirectory(examples bin/examples)
add_library(4neuro SHARED
add_library(4neuro SHARED Neuron/Neuron.cpp
Neuron/Neuron.cpp Neuron/NeuronBinary.cpp
Neuron/NeuronBinary.cpp Neuron/NeuronConstant.cpp
Neuron/NeuronConstant.cpp Neuron/NeuronLinear.cpp
Neuron/NeuronLinear.cpp Neuron/NeuronLogistic.cpp
Neuron/NeuronLogistic.cpp Network/NeuralNetwork.cpp
Network/NeuralNetwork.cpp Network/NeuralNetworkSum.cpp
Network/NeuralNetworkSum.cpp NetConnection/ConnectionFunctionGeneral.cpp
NetConnection/ConnectionFunctionGeneral.cpp NetConnection/ConnectionFunctionIdentity.cpp
NetConnection/ConnectionFunctionIdentity.cpp LearningMethods/ParticleSwarm.cpp
LearningMethods/ParticleSwarm.cpp DataSet/DataSet.cpp
DataSet/DataSet.cpp ErrorFunction/ErrorFunctions.cpp
ErrorFunction/ErrorFunctions.cpp Solvers/DESolver.cpp
Solvers/DESolver.cpp LearningMethods/ILearningMethods.h)
LearningMethods/ILearningMethods.h)
#list(REMOVE_ITEM Boost_LIBRARIES "optimized" "debug") add_library(boost_unit_test SHARED boost_test_lib_dummy.cpp)
# add_library(exprtk SHARED exprtk.cpp)
#set(TMP "")
#set(TMP2 "") target_link_libraries(4neuro ${Boost_LIBRARIES} boost_unit_test exprtk)
#foreach(e ${Boost_LIBRARIES})
# string(REPLACE "/" "\\" TMP2 ${e})
# list(APPEND TMP ${TMP2})
#endforeach(e)
#
#set(Boost_LIBRARIES ${TMP})
message("Boost_LIBRARIES sadf: ${Boost_LIBRARIES}")
target_link_libraries(4neuro ${Boost_LIBRARIES})
add_library(boost_unit_test SHARED boost_test_lib_dummy.cpp)
add_library(exprtk SHARED exprtk.cpp)
...@@ -2,4 +2,6 @@ ...@@ -2,4 +2,6 @@
// Created by David on 11.07.2018. // Created by David on 11.07.2018.
// //
#define BOOST_TEST_MODULE neuron_test #define BOOST_TEST_MODULE unit_test
#include <boost/test/included/unit_test.hpp>
//#include<unit_test.hpp>
...@@ -3,41 +3,44 @@ ...@@ -3,41 +3,44 @@
############## ##############
add_executable(neuron_test neuron_test.cpp) add_executable(neuron_test neuron_test.cpp)
target_link_libraries(neuron_test boost_unit_test 4neuro) target_link_libraries(neuron_test 4neuro)
add_executable(linear_neuron_test NeuronLinear_test.cpp) add_executable(linear_neuron_test NeuronLinear_test.cpp)
target_link_libraries(linear_neuron_test boost_unit_test 4neuro) target_link_libraries(linear_neuron_test 4neuro)
add_executable(constant_neuron_test NeuronConstant_test.cpp)
target_link_libraries(constant_neuron_test 4neuro)
add_executable(binary_neuron_test NeuronBinary_test.cpp) add_executable(binary_neuron_test NeuronBinary_test.cpp)
target_link_libraries(binary_neuron_test boost_unit_test 4neuro) target_link_libraries(binary_neuron_test 4neuro)
add_executable(logistic_neuron_test NeuronLogistic_test.cpp) add_executable(logistic_neuron_test NeuronLogistic_test.cpp)
target_link_libraries(logistic_neuron_test boost_unit_test 4neuro) target_link_libraries(logistic_neuron_test 4neuro)
add_executable(connection_weight_test ConnectionWeight_test.cpp)
target_link_libraries(connection_weight_test boost_unit_test 4neuro)
add_executable(connection_test Connection_test.cpp) add_executable(connectionFunctionGeneral_test ConnectionFunctionGeneral_test.cpp)
target_link_libraries(connection_test boost_unit_test 4neuro) target_link_libraries(connectionFunctionGeneral_test 4neuro)
add_executable(neural_network_test NeuralNetwork_test.cpp) add_executable(neural_network_test NeuralNetwork_test.cpp)
target_link_libraries(neural_network_test boost_unit_test 4neuro) target_link_libraries(neural_network_test 4neuro)
add_executable(connection_weight_identity_test ConnectionWeightIdentity_test.cpp) add_executable(connection_Function_identity_test ConnectionFunctionIdentity_test.cpp)
target_link_libraries(connection_weight_identity_test boost_unit_test 4neuro) target_link_libraries(connection_Function_identity_test 4neuro)
add_executable(dataset_test DataSet_test.cpp) add_executable(dataset_test DataSet_test.cpp)
target_link_libraries(dataset_test boost_unit_test 4neuro) target_link_libraries(dataset_test 4neuro)
add_executable(errorfunction_test ErrorFunctions_test.cpp) add_executable(errorfunction_test ErrorFunctions_test.cpp)
target_link_libraries(errorfunction_test boost_unit_test 4neuro) target_link_libraries(errorfunction_test 4neuro)
add_executable(particle_swarm_test ParticleSwarm_test.cpp) add_executable(particle_swarm_test ParticleSwarm_test.cpp)
target_link_libraries(particle_swarm_test boost_unit_test 4neuro) target_link_libraries(particle_swarm_test 4neuro)
add_executable(particle_test Particle_test.cpp) add_executable(particle_test Particle_test.cpp)
target_link_libraries(particle_test boost_unit_test 4neuro) target_link_libraries(particle_test 4neuro)
add_executable(NeuralNetworkSum_test NeuralNetworkSum_test.cpp) add_executable(NeuralNetworkSum_test NeuralNetworkSum_test.cpp)
target_link_libraries(NeuralNetworkSum_test boost_unit_test 4neuro) target_link_libraries(NeuralNetworkSum_test 4neuro)
add_executable(DESolver_test DESolver_test.cpp)
target_link_libraries(DESolver_test 4neuro)
/**
* DESCRIPTION OF THE CLASS
*
* @author David Vojtek
* @date 2018
*/
#define BOOST_TEST_NO_MAIN
#include <boost/test/unit_test.hpp>
#include "../NetConnection/ConnectionFunctionGeneral.h"
#include "../Neuron/NeuronLinear.h"
#include <iostream>
/**
* Boost testing suite for testing ConnectionFunctionGeneral.h
*/
BOOST_AUTO_TEST_SUITE(Connection_test)
/**
* Test of constructor of Connection
*/
BOOST_AUTO_TEST_CASE(Connection_construction__test) {
BOOST_CHECK_NO_THROW(ConnectionFunctionGeneral *functionGeneral = new ConnectionFunctionGeneral());
std::vector<size_t> param_indices;
param_indices.push_back(0);
std::string paramToFunction = "this do nothing! Why is it here?";
BOOST_CHECK_NO_THROW(ConnectionFunctionGeneral *functionGeneral = new ConnectionFunctionGeneral(param_indices,
paramToFunction));
}
BOOST_AUTO_TEST_CASE(Connection_eval_test) {
ConnectionFunctionGeneral *functionGeneral = new ConnectionFunctionGeneral();
//TODO implementation not finnish yet;
std::vector<double> parameter_space;
BOOST_CHECK_EQUAL(0, functionGeneral->eval(parameter_space));
}
BOOST_AUTO_TEST_CASE(Connection_eval_partial_derivative_test) {
//TODO function not implemented yet
}
BOOST_AUTO_TEST_SUITE_END()
\ No newline at end of file
/**
* DESCRIPTION OF THE CLASS
*
* @author David Vojtek
* @date 2018
*/
#define BOOST_TEST_NO_MAIN
#include <boost/test/unit_test.hpp>
#include "../NetConnection/ConnectionFunctionIdentity.h"
/**
* Boost testing suite for testing ConnectionWeightIdentity.h
*/
BOOST_AUTO_TEST_SUITE(ConnectionWeightIdentity_test)
/**
* Test of correct construction of ConnectionFunctionIdentity
*/
BOOST_AUTO_TEST_CASE(ConnectionWeightIdentity_construction_test) {
std::vector<double> weight_array = {1, 2, 3, 4, 5};
//Test of none exception when creation new instance of ConnectionFunctionIdentity
BOOST_CHECK_NO_THROW(ConnectionFunctionIdentity *CFI = new ConnectionFunctionIdentity() );
BOOST_CHECK_NO_THROW(ConnectionFunctionIdentity *CFI = new ConnectionFunctionIdentity(2) );
}
/**
* Test of eval method
*/
BOOST_AUTO_TEST_CASE(ConnectionWeightIdentity_eval_test) {
ConnectionFunctionIdentity *CFI1 = new ConnectionFunctionIdentity();
ConnectionFunctionIdentity *CFI2 = new ConnectionFunctionIdentity(0);
ConnectionFunctionIdentity *CFI3 = new ConnectionFunctionIdentity(2);
std::vector<double> parameter_space;
parameter_space.push_back(5);
//Test of correct output of eval method
BOOST_CHECK_EQUAL(1, CFI1->eval(parameter_space));
BOOST_CHECK_EQUAL(5, CFI2->eval(parameter_space));
BOOST_CHECK_THROW(CFI3->eval(parameter_space), std::out_of_range);
}
BOOST_AUTO_TEST_SUITE_END()
///**
//* DESCRIPTION OF THE CLASS
//*
//* @author David Vojtek
//* @date 2018
//*/
//
//#define BOOST_TEST_NO_MAIN
//
//#include <boost/test/unit_test.hpp>
//#include "../NetConnection/ConnectionFunctionIdentity.h"
//
///**
// * Boost testing suite for testing ConnectionWeightIdentity.h
// */
//BOOST_AUTO_TEST_SUITE(ConnectionWeightIdentity_test)
//
// /**
// * Test of correct construction of ConnectionWeightIdentity
// */
// BOOST_AUTO_TEST_CASE(ConnectionWeightIdentity_construction_test) {
// std::vector<double> weight_array = {1, 2, 3, 4, 5};
// //Test of none exception when creation new instance of ConnectionFunctionIdentity
// BOOST_CHECK_NO_THROW(ConnectionFunctionIdentity CWI(&weight_array));
// }
//
// /**
// * Test of eval method
// */
// BOOST_AUTO_TEST_CASE(ConnectionWeightIdentity_eval_test) {
// std::vector<double> weight_array = {1, 2, 3, 4, 5};
// ConnectionFunctionIdentity CWI(&weight_array);
// int para[5] = {3, 1, 2, 3, 4};
// CWI.SetParamIndices(para);
//
// //Test of correct output of eval method
// BOOST_CHECK_EQUAL(4, CWI.eval());
// }
//
//BOOST_AUTO_TEST_SUITE_END()
///**
// * DESCRIPTION OF THE CLASS
// *
// * @author David Vojtek
// * @date 2018
// */
//
//#define BOOST_TEST_NO_MAIN
//
//#include <boost/test/unit_test.hpp>
//#include "../NetConnection/ConnectionFunctionGeneral.h"
//
///**
// * Boost testing suite for testing ConnectionWeight.h
// */
//BOOST_AUTO_TEST_SUITE(ConnectionWeight_test)
//
// /**
// * Test of construction of ConnectionWeight
// */
// BOOST_AUTO_TEST_CASE(ConnectionWeight_construction__test) {
// std::vector<double> * w_array = nullptr ;
//
// //Tests of no exception when, create new instance
// BOOST_CHECK_NO_THROW( ConnectionFunctionGeneral conn(2, w_array ));
// BOOST_CHECK_NO_THROW( ConnectionFunctionGeneral conn);
// }
//
// /**
// * Test of setParamIndices and SetParamIndex methods
// */
// BOOST_AUTO_TEST_CASE(ConnectionWeight_param_test){
// std::vector<double> w_array= {0,1,2,3,4} ;
//
// ConnectionFunctionGeneral conn(5, &w_array );
// ConnectionFunctionGeneral connbad(7, &w_array);
// int para[5]={0,1,2,3,4};
//
// //Test of no exception when call SetParamIndices method on instance created with with correct parameters
// BOOST_CHECK_NO_THROW(conn.SetParamIndices(para));
// //Test of no exception when call SetParamIndex method on instance created with with correct parameters
// BOOST_CHECK_NO_THROW(conn.SetParamIndex(2,2));
// // Features not implemented yet
// //Test of expected exception out_of_range when call SetParamIndices method on instance created with with incorrect parameters
// //BOOST_CHECK_THROW(connbad.SetParamIndices(para), std::out_of_range);
// //Test of expected exception out_of_range when call SetParamIndex method on instance created with incorrect parameters
// //BOOST_CHECK_THROW(connbad.SetParamIndex(2,8), std::out_of_range);
// }
//
// /**
// * Test of eval method
// */
// BOOST_AUTO_TEST_CASE(ConnectionWeight_eval__test) {
// std::vector<double> w_array= {1,2,3,4,5} ;
//
// ConnectionFunctionGeneral conn(5, &w_array );
// int para[5]={1,2,3,4,5};
// conn.SetParamIndices(para);
//
// //Test of correct output after calling eval() method
// BOOST_CHECK_EQUAL(120, conn.eval());
// }
//
// /**
// * Test of adjust_weights method
// */
// BOOST_AUTO_TEST_CASE(ConnectionWeight_weight_adjustment_test) {
// std::vector<double> w_array= {1,2,3,4,5} ;
// double w_array2[5] = {5,4,3,2,1};
//
// ConnectionFunctionGeneral conn(5, &w_array);
// int para[5]={0,1,2,3,4};
// conn.SetParamIndices(para);
// conn.adjust_weights(w_array2);
//
// //Test of correct eval output after adjusting weights
// BOOST_CHECK_EQUAL(7776, conn.eval());
// }
//
// /**
// * Test of set_weights method
// */
// BOOST_AUTO_TEST_CASE(ConnectionWeight_weight_set_test) {
// std::vector<double> w_array= {2,3,4,5,6} ;
// double w_array2[5] = {1,2,3,4,5};
// ConnectionFunctionGeneral conn(5, &w_array );
// conn.eval();
// int para[5]={0,1,2,3,4};
// conn.SetParamIndices(para);
// conn.set_weights(w_array2);
//
// //Test of correct eval output after setting new weights
// BOOST_CHECK_EQUAL(120, conn.eval());
// }
//
//
//BOOST_AUTO_TEST_SUITE_END()
\ No newline at end of file
///**
// * DESCRIPTION OF THE CLASS
// *
// * @author David Vojtek
// * @date 2018
// */
//
//#define BOOST_TEST_NO_MAIN
//
//#include <boost/test/unit_test.hpp>
//
//
//#include "../NetConnection/ConnectionFunctionGeneral.h"
//#include "../Neuron/NeuronLinear.h"
//#include <iostream>
///**
// * Boost testing suite for testing ConnectionFunctionGeneral.h
// */
//
//BOOST_AUTO_TEST_SUITE(Connection_test)
//
///**
// * Test of constructor of Connection
// */
//BOOST_AUTO_TEST_CASE(Connection_construction__test) {
//
// Neuron *neuron1 = new NeuronLinear(2, 3);
// Neuron *neuron2 = new NeuronLinear(4, 5);
// std::vector<double> w_array = {2, 3, 4, 5, 6};
//
// ConnectionWeight *conn = new ConnectionWeight(2, &w_array);
// Connection connection(neuron1, neuron2, conn);
// //Test of correct input neuron
// BOOST_CHECK_EQUAL(neuron1, connection.get_neuron_in());
// //Test of correct output neuron
// BOOST_CHECK_EQUAL(neuron2, connection.get_neuron_out());
//}
//
///**
// * Test of pass_signal method
// */
//BOOST_AUTO_TEST_CASE(Connection_pass_signal_test) {
//
// Neuron *neuron1 = new NeuronLinear(2, 3);
// Neuron *neuron2 = new NeuronLinear(4, 5);
// std::vector<double> w_array = {2, 3, 4, 5, 6};
// std::function<double(double *, int *, int)> f = [](double *weight_array, int *index_array, int n_params) {
// double a = weight_array[0];
// double b = weight_array[1];
// return (a + 1.5 * b);
// };
//
//
// ConnectionWeight *conn = new ConnectionWeight(2, &w_array);
//
// Connection connection(neuron1, neuron2, conn);
//
// neuron1->activate();
// neuron2->activate();
// // test of neuron state before passing signal
// BOOST_CHECK_EQUAL(4, neuron2->get_state());
// connection.pass_signal();
// neuron2->activate();
// // test of neuron state after passing signal
// BOOST_CHECK_EQUAL(7204, neuron2->get_state());
//
//}
//
//
//BOOST_AUTO_TEST_SUITE_END()
\ No newline at end of file
/**
* DESCRIPTION OF THE CLASS
*
* @author David Vojtek
* @date 2018
*/
#define BOOST_TEST_NO_MAIN
#include <boost/test/unit_test.hpp>
#include <iostream>
#include <boost/test/output_test_stream.hpp>
#include "../Solvers/DESolver.h"
/**
* Boost testing suite for testing DESolver.h
*
*/
BOOST_AUTO_TEST_SUITE(DESolver_test)
/**
* Test of MultiIndex construction test
*/
BOOST_AUTO_TEST_CASE(MultiIndex_construction_test) {
BOOST_CHECK_NO_THROW(MultiIndex multiIndex(2));
}
/**
* Test of MultiIndex set_partial_deravitive method
*/
BOOST_AUTO_TEST_CASE(MultiIndex_set_partial_derivative_test) {
MultiIndex multiIndex(2);
BOOST_CHECK_NO_THROW(multiIndex.set_partial_derivative(0, 1));
BOOST_CHECK_NO_THROW(multiIndex.set_partial_derivative(1, 2));
//BOOST_CHECK_THROW(multiIndex.set_partial_derivative(2, 3), std::out_of_range);
}
/**
* Testo of MultiIndex get_partial_derivative_degrees method
*/
BOOST_AUTO_TEST_CASE(MultiIndex_get_partial_derivative_degrees_test) {
MultiIndex multiIndex(2);
multiIndex.set_partial_derivative(0, 1);
multiIndex.set_partial_derivative(1, 2);
BOOST_CHECK_EQUAL(1, multiIndex.get_partial_derivatives_degrees()->at(0));
BOOST_CHECK_EQUAL(2, multiIndex.get_partial_derivatives_degrees()->at(1));
}
/**
* Test of MultiIndex operator< method
*/
BOOST_AUTO_TEST_CASE(MultiIndex_operator_test) {
MultiIndex multiIndex1(1);
multiIndex1.set_partial_derivative(0, 1);
MultiIndex multiIndex2(2);
multiIndex2.set_partial_derivative(0, 1);
multiIndex2.set_partial_derivative(1, 2);
MultiIndex multiIndex3(1);
multiIndex3.set_partial_derivative(0, 2);
BOOST_CHECK(multiIndex1.operator<(multiIndex2));
//BOOST_CHECK_THROW(multiIndex2.operator<(multiIndex1), std::out_of_range);
BOOST_CHECK(!multiIndex1.operator<(multiIndex1));
BOOST_CHECK(multiIndex1.operator<((multiIndex3)));
}
/**
* Test of MultiIndex toString method
*/
BOOST_AUTO_TEST_CASE(MultiIndex_toString_test) {
MultiIndex multiIndex(2);
BOOST_CHECK_EQUAL("0, 0", multiIndex.to_string());
}
/**
* Test of MultiIndex get_degree method
*/
BOOST_AUTO_TEST_CASE(MultiIndex_get_degree_test) {
MultiIndex multiIndex(2);
BOOST_CHECK_EQUAL(0, multiIndex.get_degree());
multiIndex.set_partial_derivative(0, 1);
multiIndex.set_partial_d