diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 83afd697f9b04ea39794d2b305877132d2381759..aab94c9b03d1378132baa1a11361d7dece6ebe11 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -40,28 +40,45 @@ win_visual_studio_static_deps: # - cd ..\.. # # +win_visual_studio_shared_deps: + tags: + - Win + + before_script: + - call VsDevCmd.bat + - cd build_scripts\windows + - call win_download_dependencies.bat + - cd ..\.. + - cd build_scripts\windows + - set DEPENDENCIES_LINK_TYPE=shared + - call win_VS_build_x64_debug.bat + + script: + - call win_run_tests.bat + + # Latest Ubuntu with Boost and Exprtk # in system directories, Boost # installed from the official repository # => only dynamical linking possible -#ubuntu_boost_system: -# tags: -# - centos7 -# -# image: martinbeseda/dockertest:latest -# -# before_script: -# - rm -rf external_dependencies -# - git clone https://github.com/ArashPartow/exprtk.git -# - cp exprtk/exprtk.hpp /usr/include -# - export TERM=xterm -# - cd build_scripts/linux -# - export DEPENDENCIES_LINK_TYPE=shared -# - ./linux_gcc_build_x64_debug_system.sh -# -# script: -# - './linux_run_tests.sh' -# +ubuntu_boost_system: + tags: + - centos7 + + image: martinbeseda/dockertest:latest + + before_script: + - rm -rf external_dependencies + - git clone https://github.com/ArashPartow/exprtk.git + - cp exprtk/exprtk.hpp /usr/include + - export TERM=xterm + - cd build_scripts/linux + - export DEPENDENCIES_LINK_TYPE=shared + - ./linux_gcc_build_x64_debug_system.sh + + script: + - './linux_run_tests.sh' + # Latest Ubuntu with Boost and Exprtk # compiled locally as submodules and # linked statically @@ -74,14 +91,13 @@ ubuntu_boost_local_static_deps: before_script: - cd build_scripts/linux - ./download_dependencies.sh + - cd ../.. + - cd build_scripts/linux - export DEPENDENCIES_LINK_TYPE=static - ./linux_gcc_build_x64_debug_local.sh - - cd ../.. script: - - cd build_scripts/linux - './linux_run_tests.sh' - - cd ../.. # Latest Ubuntu with Boost and Exprtk # compiled locally as submodules and @@ -95,14 +111,14 @@ ubuntu_boost_local_dynamic_deps: before_script: - cd build_scripts/linux - ./download_dependencies.sh + - cd ../.. + - cd build_scripts/linux - export DEPENDENCIES_LINK_TYPE=shared - ./linux_gcc_build_x64_debug_local.sh - - cd ../.. script: - - cd build_scripts/linux - './linux_run_tests.sh' - - cd ../.. + #code_quality: # image: docker:stable diff --git a/CMakeLists.txt b/CMakeLists.txt index a2a03cd7399ad45e2d4fb2c96bda1c574ac9c21a..2465df77a1e77982413901f676037f154d5ec9db 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,14 @@ message("Using CMake ${CMAKE_VERSION}") #TODO request newer version of CMake >=3.12 +#TODO rewrite to use add_compile_definitions +if(WIN32) + add_compile_options("/D BOOST_ALL_NO_LIB") + add_compile_options("/D NOMINMAX") +else() + add_compile_options("-DBOOST_TEST_DYN_LINK") +endif() + #------------# # Build type # #------------# @@ -15,7 +23,6 @@ if (NOT CMAKE_BUILD_TYPE) FORCE) elseif("CMAKE_BUILD_TYPE" STREQUAL "Debug") #TODO rewrite to use add_compile_definitions - add_compile_options(-DDEBUG) endif (NOT CMAKE_BUILD_TYPE) #------------------------# @@ -25,12 +32,6 @@ if(NOT DEPENDENCIES_LINK_TYPE AND NOT ENV{DEPENDENCIES_LINK_TYPE}) message(FATAL_ERROR "Please, set the variable DEPENDENCIES_LINK_TYPE to either 'static' or 'shared'!") endif() -#------------------------# -# Linking of boost_test_framework -#------------------------# -add_compile_options("-DBOOST_ALL_NO_LIB") -add_compile_options("-DBOOST_TEST_DYN_LINK") - #--------------------------------# # Setting C++ compiler flags # #--------------------------------# @@ -42,7 +43,8 @@ if( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel" ) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -xHost" ) elseif( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC" ) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W0 /bigobj") - add_compile_options("-D_SCL_SECURE_NO_WARNINGS") + add_compile_options("/D _SCL_SECURE_NO_WARNINGS") + add_compile_options("/D_CRT_SECURE_NO_WARNINGS") else() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") endif() @@ -63,12 +65,6 @@ set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}) set(Boost_USE_MULTITHREADED ON) set(Boost_DEBUG ON) -#set(CMAKE_INCLUDE_PATH ${BOOST_INCLUDEDIR} "${CMAKE_CURRENT_LIST_DIR}/external_dependencies/boost" ${CMAKE_INCLUDE_PATH}) -#set(CMAKE_LIBRARY_PATH ${BOOST_LIBRARYDIR} "${CMAKE_CURRENT_LIST_DIR}/external_dependencies/boost/stage/lib" ${CMAKE_LIBRARY_PATH}) - -message("CMAKE_INCLUDE_PATH: ${CMAKE_INCLUDE_PATH}") -message("CMAKE_LIBRARY_PATH: ${CMAKE_LIBRARY_PATH}") - find_package( Boost @@ -120,10 +116,4 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin) #----------------------------------------# message("Running CMake in: ${SRC_DIR} ${PROJECT_BINARY_DIR}") -if("${BUILD_LIB}" STREQUAL "no") - #TODO this can be removed once we have restructured the compilation of our library - link_directories(${LIB4NEURO_DIR}) - include_directories(${Boost_INCLUDE_DIRS} ${ROOT_DIR}/include ${EXPRTK_INCLUDE_DIR}) -endif() - add_subdirectory(${SRC_DIR} ${PROJECT_BINARY_DIR}) diff --git a/Doxyfile b/Doxyfile index b70fc203828d0883f952d9dcfa6eddd6f2a28934..ef0669e86ec99b4dc92f337f1de0aede6be3f31c 100644 --- a/Doxyfile +++ b/Doxyfile @@ -1,4 +1,4 @@ -# Doxyfile 1.8.14 +# Doxyfile 1.8.13 # This file describes the settings to be used by the documentation system # doxygen (www.doxygen.org) for a project. @@ -20,8 +20,8 @@ # This tag specifies the encoding used for all characters in the config file # that follow. The default is UTF-8 which is also the encoding used for all text # before the first occurrence of this tag. Doxygen uses libiconv (or the iconv -# built into libc) for the transcoding. See -# https://www.gnu.org/software/libiconv/ for the list of possible encodings. +# built into libc) for the transcoding. See http://www.gnu.org/software/libiconv +# for the list of possible encodings. # The default value is: UTF-8. DOXYFILE_ENCODING = UTF-8 @@ -32,13 +32,13 @@ DOXYFILE_ENCODING = UTF-8 # title of most generated pages and in a few other places. # The default value is: My Project. -PROJECT_NAME = "lib4neuro" +PROJECT_NAME = lib4neuro # The PROJECT_NUMBER tag can be used to enter a project or revision number. This # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = +PROJECT_NUMBER = # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a @@ -51,14 +51,14 @@ PROJECT_BRIEF = "Massivelly-parallel neural networks library" # pixels and the maximum width should not exceed 200 pixels. Doxygen will copy # the logo to the output directory. -PROJECT_LOGO = "img/lib4neuro_logo.png" +PROJECT_LOGO = /home/martin/4Neuro/img/lib4neuro_logo.png # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path # into which the generated documentation will be written. If a relative path is # entered, it will be relative to the location where doxygen was started. If # left blank the current directory will be used. -OUTPUT_DIRECTORY = "docs" +OUTPUT_DIRECTORY = /home/martin/4Neuro/docs # If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub- # directories (in 2 levels) under the output directory of each output format and @@ -162,7 +162,7 @@ FULL_PATH_NAMES = YES # will be relative from the directory where doxygen is started. # This tag requires that the tag FULL_PATH_NAMES is set to YES. -STRIP_FROM_PATH = +STRIP_FROM_PATH = # The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the # path mentioned in the documentation of a class, which tells the reader which @@ -171,7 +171,7 @@ STRIP_FROM_PATH = # specify the list of include paths that are normally passed to the compiler # using the -I flag. -STRIP_FROM_INC_PATH = +STRIP_FROM_INC_PATH = # If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but # less readable) file names. This can be useful is your file systems doesn't @@ -238,13 +238,13 @@ TAB_SIZE = 4 # "Side Effects:". You can put \n's in the value part of an alias to insert # newlines. -ALIASES = +ALIASES = # This tag can be used to specify a number of word-keyword mappings (TCL only). # A mapping has the form "name=value". For example adding "class=itcl::class" # will allow you to use the command class in the itcl::class meaning. -TCL_SUBST = +TCL_SUBST = # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources # only. Doxygen will then generate output that is more tailored for C. For @@ -291,7 +291,7 @@ OPTIMIZE_OUTPUT_VHDL = NO # Note that for custom extensions you also need to set FILE_PATTERNS otherwise # the files are not read by doxygen. -EXTENSION_MAPPING = +EXTENSION_MAPPING = # If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments # according to the Markdown format, which allows for more readable @@ -337,7 +337,7 @@ BUILTIN_STL_SUPPORT = NO CPP_CLI_SUPPORT = NO # Set the SIP_SUPPORT tag to YES if your project consists of sip (see: -# https://www.riverbankcomputing.com/software/sip/intro) sources only. Doxygen +# http://www.riverbankcomputing.co.uk/software/sip/intro) sources only. Doxygen # will parse them like normal C++ but will assume all classes use public instead # of private inheritance when no explicit protection keyword is present. # The default value is: NO. @@ -435,13 +435,13 @@ LOOKUP_CACHE_SIZE = 0 # normally produced when WARNINGS is set to YES. # The default value is: NO. -EXTRACT_ALL = NO +EXTRACT_ALL = YES # If the EXTRACT_PRIVATE tag is set to YES, all private members of a class will # be included in the documentation. # The default value is: NO. -EXTRACT_PRIVATE = YES +EXTRACT_PRIVATE = NO # If the EXTRACT_PACKAGE tag is set to YES, all members with package or internal # scope will be included in the documentation. @@ -453,7 +453,7 @@ EXTRACT_PACKAGE = NO # included in the documentation. # The default value is: NO. -EXTRACT_STATIC = YES +EXTRACT_STATIC = NO # If the EXTRACT_LOCAL_CLASSES tag is set to YES, classes (and structs) defined # locally in source files will be included in the documentation. If set to NO, @@ -524,7 +524,7 @@ INTERNAL_DOCS = NO # and Mac users are advised to set this option to NO. # The default value is: system dependent. -CASE_SENSE_NAMES = YES +CASE_SENSE_NAMES = NO # If the HIDE_SCOPE_NAMES tag is set to NO then doxygen will show members with # their full class and namespace scopes in the documentation. If set to YES, the @@ -648,7 +648,7 @@ GENERATE_DEPRECATEDLIST= YES # sections, marked by \if <section_label> ... \endif and \cond <section_label> # ... \endcond blocks. -ENABLED_SECTIONS = +ENABLED_SECTIONS = # The MAX_INITIALIZER_LINES tag determines the maximum number of lines that the # initial value of a variable or macro / define can have for it to appear in the @@ -690,7 +690,7 @@ SHOW_NAMESPACES = YES # by doxygen. Whatever the program writes to standard output is used as the file # version. For an example see the documentation. -FILE_VERSION_FILTER = +FILE_VERSION_FILTER = # The LAYOUT_FILE tag can be used to specify a layout file which will be parsed # by doxygen. The layout file controls the global structure of the generated @@ -703,17 +703,17 @@ FILE_VERSION_FILTER = # DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE # tag is left empty. -LAYOUT_FILE = +LAYOUT_FILE = # The CITE_BIB_FILES tag can be used to specify one or more bib files containing # the reference definitions. This must be a list of .bib files. The .bib # extension is automatically appended if omitted. This requires the bibtex tool -# to be installed. See also https://en.wikipedia.org/wiki/BibTeX for more info. +# to be installed. See also http://en.wikipedia.org/wiki/BibTeX for more info. # For LaTeX the style of the bibliography can be controlled using # LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the # search path. See also \cite for info how to create references. -CITE_BIB_FILES = +CITE_BIB_FILES = #--------------------------------------------------------------------------- # Configuration options related to warning and progress messages @@ -778,7 +778,7 @@ WARN_FORMAT = "$file:$line: $text" # messages should be written. If left blank the output is written to standard # error (stderr). -WARN_LOGFILE = +WARN_LOGFILE = #--------------------------------------------------------------------------- # Configuration options related to the input files @@ -790,12 +790,12 @@ WARN_LOGFILE = # spaces. See also FILE_PATTERNS and EXTENSION_MAPPING # Note: If this tag is empty the current directory is searched. -INPUT = "src" +INPUT = /home/martin/4Neuro/src # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses # libiconv (or the iconv built into libc) for the transcoding. See the libiconv -# documentation (see: https://www.gnu.org/software/libiconv/) for the list of +# documentation (see: http://www.gnu.org/software/libiconv) for the list of # possible encodings. # The default value is: UTF-8. @@ -873,7 +873,7 @@ RECURSIVE = YES # Note that relative paths are relative to the directory from which doxygen is # run. -EXCLUDE = +EXCLUDE = # The EXCLUDE_SYMLINKS tag can be used to select whether or not files or # directories that are symbolic links (a Unix file system feature) are excluded @@ -889,7 +889,7 @@ EXCLUDE_SYMLINKS = NO # Note that the wildcards are matched against the file with absolute path, so to # exclude all test directories for example use the pattern */test/* -EXCLUDE_PATTERNS = +EXCLUDE_PATTERNS = # The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names # (namespaces, classes, functions, etc.) that should be excluded from the @@ -900,13 +900,13 @@ EXCLUDE_PATTERNS = # Note that the wildcards are matched against the file with absolute path, so to # exclude all test directories use the pattern */test/* -EXCLUDE_SYMBOLS = +EXCLUDE_SYMBOLS = # The EXAMPLE_PATH tag can be used to specify one or more files or directories # that contain example code fragments that are included (see the \include # command). -EXAMPLE_PATH = +EXAMPLE_PATH = # If the value of the EXAMPLE_PATH tag contains directories, you can use the # EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and @@ -926,7 +926,7 @@ EXAMPLE_RECURSIVE = NO # that contain images that are to be included in the documentation (see the # \image command). -IMAGE_PATH = +IMAGE_PATH = # The INPUT_FILTER tag can be used to specify a program that doxygen should # invoke to filter for each input file. Doxygen will invoke the filter program @@ -947,7 +947,7 @@ IMAGE_PATH = # need to set EXTENSION_MAPPING for the extension otherwise the files are not # properly processed by doxygen. -INPUT_FILTER = +INPUT_FILTER = # The FILTER_PATTERNS tag can be used to specify filters on a per file pattern # basis. Doxygen will compare the file name with each pattern and apply the @@ -960,7 +960,7 @@ INPUT_FILTER = # need to set EXTENSION_MAPPING for the extension otherwise the files are not # properly processed by doxygen. -FILTER_PATTERNS = +FILTER_PATTERNS = # If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using # INPUT_FILTER) will also be used to filter the input files that are used for @@ -975,14 +975,14 @@ FILTER_SOURCE_FILES = NO # *.ext= (so without naming a filter). # This tag requires that the tag FILTER_SOURCE_FILES is set to YES. -FILTER_SOURCE_PATTERNS = +FILTER_SOURCE_PATTERNS = # If the USE_MDFILE_AS_MAINPAGE tag refers to the name of a markdown file that # is part of the input, its contents will be placed on the main page # (index.html). This can be useful if you have a project on for instance GitHub # and want to reuse the introduction page also for the doxygen output. -USE_MDFILE_AS_MAINPAGE = +USE_MDFILE_AS_MAINPAGE = #--------------------------------------------------------------------------- # Configuration options related to source browsing @@ -995,7 +995,7 @@ USE_MDFILE_AS_MAINPAGE = # also VERBATIM_HEADERS is set to NO. # The default value is: NO. -SOURCE_BROWSER = NO +SOURCE_BROWSER = YES # Setting the INLINE_SOURCES tag to YES will include the body of functions, # classes and enums directly into the documentation. @@ -1043,7 +1043,7 @@ SOURCE_TOOLTIPS = YES # If the USE_HTAGS tag is set to YES then the references to source code will # point to the HTML generated by the htags(1) tool instead of doxygen built-in # source browser. The htags tool is part of GNU's global source tagging system -# (see https://www.gnu.org/software/global/global.html). You will need version +# (see http://www.gnu.org/software/global/global.html). You will need version # 4.8.6 or higher. # # To use it do the following: @@ -1070,6 +1070,25 @@ USE_HTAGS = NO VERBATIM_HEADERS = YES +# If the CLANG_ASSISTED_PARSING tag is set to YES then doxygen will use the +# clang parser (see: http://clang.llvm.org/) for more accurate parsing at the +# cost of reduced performance. This can be particularly helpful with template +# rich C++ code for which doxygen's built-in parser lacks the necessary type +# information. +# Note: The availability of this option depends on whether or not doxygen was +# generated with the -Duse-libclang=ON option for CMake. +# The default value is: NO. + +CLANG_ASSISTED_PARSING = NO + +# If clang assisted parsing is enabled you can provide the compiler with command +# line options that you would normally use when invoking the compiler. Note that +# the include paths will already be set by doxygen for the files and directories +# specified with INPUT and INCLUDE_PATH. +# This tag requires that the tag CLANG_ASSISTED_PARSING is set to YES. + +CLANG_OPTIONS = + #--------------------------------------------------------------------------- # Configuration options related to the alphabetical class index #--------------------------------------------------------------------------- @@ -1094,7 +1113,7 @@ COLS_IN_ALPHA_INDEX = 5 # while generating the index headers. # This tag requires that the tag ALPHABETICAL_INDEX is set to YES. -IGNORE_PREFIX = +IGNORE_PREFIX = #--------------------------------------------------------------------------- # Configuration options related to the HTML output @@ -1138,7 +1157,7 @@ HTML_FILE_EXTENSION = .html # of the possible markers and block names see the documentation. # This tag requires that the tag GENERATE_HTML is set to YES. -HTML_HEADER = +HTML_HEADER = # The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each # generated HTML page. If the tag is left blank doxygen will generate a standard @@ -1148,7 +1167,7 @@ HTML_HEADER = # that doxygen normally uses. # This tag requires that the tag GENERATE_HTML is set to YES. -HTML_FOOTER = +HTML_FOOTER = # The HTML_STYLESHEET tag can be used to specify a user-defined cascading style # sheet that is used by each HTML page. It can be used to fine-tune the look of @@ -1160,7 +1179,7 @@ HTML_FOOTER = # obsolete. # This tag requires that the tag GENERATE_HTML is set to YES. -HTML_STYLESHEET = +HTML_STYLESHEET = # The HTML_EXTRA_STYLESHEET tag can be used to specify additional user-defined # cascading style sheets that are included after the standard style sheets @@ -1173,7 +1192,7 @@ HTML_STYLESHEET = # list). For an example see the documentation. # This tag requires that the tag GENERATE_HTML is set to YES. -HTML_EXTRA_STYLESHEET = +HTML_EXTRA_STYLESHEET = # The HTML_EXTRA_FILES tag can be used to specify one or more extra images or # other source files which should be copied to the HTML output directory. Note @@ -1183,12 +1202,12 @@ HTML_EXTRA_STYLESHEET = # files will be copied as-is; there are no commands or markers available. # This tag requires that the tag GENERATE_HTML is set to YES. -HTML_EXTRA_FILES = +HTML_EXTRA_FILES = # The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen # will adjust the colors in the style sheet and background images according to # this color. Hue is specified as an angle on a colorwheel, see -# https://en.wikipedia.org/wiki/Hue for more information. For instance the value +# http://en.wikipedia.org/wiki/Hue for more information. For instance the value # 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300 # purple, and 360 is red again. # Minimum value: 0, maximum value: 359, default value: 220. @@ -1224,17 +1243,6 @@ HTML_COLORSTYLE_GAMMA = 80 HTML_TIMESTAMP = NO -# If the HTML_DYNAMIC_MENUS tag is set to YES then the generated HTML -# documentation will contain a main index with vertical navigation menus that -# are dynamically created via Javascript. If disabled, the navigation index will -# consists of multiple levels of tabs that are statically embedded in every HTML -# page. Disable this option to support browsers that do not have Javascript, -# like the Qt help browser. -# The default value is: YES. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_DYNAMIC_MENUS = YES - # If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML # documentation will contain sections that can be hidden and shown after the # page has loaded. @@ -1258,12 +1266,12 @@ HTML_INDEX_NUM_ENTRIES = 100 # If the GENERATE_DOCSET tag is set to YES, additional index files will be # generated that can be used as input for Apple's Xcode 3 integrated development -# environment (see: https://developer.apple.com/tools/xcode/), introduced with +# environment (see: http://developer.apple.com/tools/xcode/), introduced with # OSX 10.5 (Leopard). To create a documentation set, doxygen will generate a # Makefile in the HTML output directory. Running make will produce the docset in # that directory and running make install will install the docset in # ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at -# startup. See https://developer.apple.com/tools/creatingdocsetswithdoxygen.html +# startup. See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html # for more information. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. @@ -1323,7 +1331,7 @@ GENERATE_HTMLHELP = NO # written to the html output directory. # This tag requires that the tag GENERATE_HTMLHELP is set to YES. -CHM_FILE = +CHM_FILE = # The HHC_LOCATION tag can be used to specify the location (absolute path # including file name) of the HTML help compiler (hhc.exe). If non-empty, @@ -1331,7 +1339,7 @@ CHM_FILE = # The file has to be specified with full path. # This tag requires that the tag GENERATE_HTMLHELP is set to YES. -HHC_LOCATION = +HHC_LOCATION = # The GENERATE_CHI flag controls if a separate .chi index file is generated # (YES) or that it should be included in the master .chm file (NO). @@ -1344,7 +1352,7 @@ GENERATE_CHI = NO # and project file content. # This tag requires that the tag GENERATE_HTMLHELP is set to YES. -CHM_INDEX_ENCODING = +CHM_INDEX_ENCODING = # The BINARY_TOC flag controls whether a binary table of contents is generated # (YES) or a normal table of contents (NO) in the .chm file. Furthermore it @@ -1375,11 +1383,11 @@ GENERATE_QHP = NO # the HTML output folder. # This tag requires that the tag GENERATE_QHP is set to YES. -QCH_FILE = +QCH_FILE = # The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help # Project output. For more information please see Qt Help Project / Namespace -# (see: http://doc.qt.io/qt-4.8/qthelpproject.html#namespace). +# (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#namespace). # The default value is: org.doxygen.Project. # This tag requires that the tag GENERATE_QHP is set to YES. @@ -1387,7 +1395,8 @@ QHP_NAMESPACE = org.doxygen.Project # The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt # Help Project output. For more information please see Qt Help Project / Virtual -# Folders (see: http://doc.qt.io/qt-4.8/qthelpproject.html#virtual-folders). +# Folders (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#virtual- +# folders). # The default value is: doc. # This tag requires that the tag GENERATE_QHP is set to YES. @@ -1395,31 +1404,33 @@ QHP_VIRTUAL_FOLDER = doc # If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom # filter to add. For more information please see Qt Help Project / Custom -# Filters (see: http://doc.qt.io/qt-4.8/qthelpproject.html#custom-filters). +# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom- +# filters). # This tag requires that the tag GENERATE_QHP is set to YES. -QHP_CUST_FILTER_NAME = +QHP_CUST_FILTER_NAME = # The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the # custom filter to add. For more information please see Qt Help Project / Custom -# Filters (see: http://doc.qt.io/qt-4.8/qthelpproject.html#custom-filters). +# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom- +# filters). # This tag requires that the tag GENERATE_QHP is set to YES. -QHP_CUST_FILTER_ATTRS = +QHP_CUST_FILTER_ATTRS = # The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this # project's filter section matches. Qt Help Project / Filter Attributes (see: -# http://doc.qt.io/qt-4.8/qthelpproject.html#filter-attributes). +# http://qt-project.org/doc/qt-4.8/qthelpproject.html#filter-attributes). # This tag requires that the tag GENERATE_QHP is set to YES. -QHP_SECT_FILTER_ATTRS = +QHP_SECT_FILTER_ATTRS = # The QHG_LOCATION tag can be used to specify the location of Qt's # qhelpgenerator. If non-empty doxygen will try to run qhelpgenerator on the # generated .qhp file. # This tag requires that the tag GENERATE_QHP is set to YES. -QHG_LOCATION = +QHG_LOCATION = # If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files will be # generated, together with the HTML files, they form an Eclipse help plugin. To @@ -1502,7 +1513,7 @@ EXT_LINKS_IN_WINDOW = NO FORMULA_FONTSIZE = 10 -# Use the FORMULA_TRANSPARENT tag to determine whether or not the images +# Use the FORMULA_TRANPARENT tag to determine whether or not the images # generated for formulas are transparent PNGs. Transparent PNGs are not # supported properly for IE 6.0, but are supported on all modern browsers. # @@ -1514,7 +1525,7 @@ FORMULA_FONTSIZE = 10 FORMULA_TRANSPARENT = YES # Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see -# https://www.mathjax.org) which uses client side Javascript for the rendering +# http://www.mathjax.org) which uses client side Javascript for the rendering # instead of using pre-rendered bitmaps. Use this if you do not have LaTeX # installed or if you want to formulas look prettier in the HTML output. When # enabled you may also need to install MathJax separately and configure the path @@ -1541,18 +1552,18 @@ MATHJAX_FORMAT = HTML-CSS # MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax # Content Delivery Network so you can quickly see the result without installing # MathJax. However, it is strongly recommended to install a local copy of -# MathJax from https://www.mathjax.org before deployment. -# The default value is: https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/. +# MathJax from http://www.mathjax.org before deployment. +# The default value is: http://cdn.mathjax.org/mathjax/latest. # This tag requires that the tag USE_MATHJAX is set to YES. -MATHJAX_RELPATH = https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/ +MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest # The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax # extension names that should be enabled during MathJax rendering. For example # MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols # This tag requires that the tag USE_MATHJAX is set to YES. -MATHJAX_EXTENSIONS = +MATHJAX_EXTENSIONS = # The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces # of code that will be used on startup of the MathJax code. See the MathJax site @@ -1560,7 +1571,7 @@ MATHJAX_EXTENSIONS = # example see the documentation. # This tag requires that the tag USE_MATHJAX is set to YES. -MATHJAX_CODEFILE = +MATHJAX_CODEFILE = # When the SEARCHENGINE tag is enabled doxygen will generate a search box for # the HTML output. The underlying search engine uses javascript and DHTML and @@ -1603,7 +1614,7 @@ SERVER_BASED_SEARCH = NO # # Doxygen ships with an example indexer (doxyindexer) and search engine # (doxysearch.cgi) which are based on the open source search engine library -# Xapian (see: https://xapian.org/). +# Xapian (see: http://xapian.org/). # # See the section "External Indexing and Searching" for details. # The default value is: NO. @@ -1616,11 +1627,11 @@ EXTERNAL_SEARCH = NO # # Doxygen ships with an example indexer (doxyindexer) and search engine # (doxysearch.cgi) which are based on the open source search engine library -# Xapian (see: https://xapian.org/). See the section "External Indexing and +# Xapian (see: http://xapian.org/). See the section "External Indexing and # Searching" for details. # This tag requires that the tag SEARCHENGINE is set to YES. -SEARCHENGINE_URL = +SEARCHENGINE_URL = # When SERVER_BASED_SEARCH and EXTERNAL_SEARCH are both enabled the unindexed # search data is written to a file for indexing by an external tool. With the @@ -1636,7 +1647,7 @@ SEARCHDATA_FILE = searchdata.xml # projects and redirect the results back to the right project. # This tag requires that the tag SEARCHENGINE is set to YES. -EXTERNAL_SEARCH_ID = +EXTERNAL_SEARCH_ID = # The EXTRA_SEARCH_MAPPINGS tag can be used to enable searching through doxygen # projects other than the one defined by this configuration file, but that are @@ -1646,7 +1657,7 @@ EXTERNAL_SEARCH_ID = # EXTRA_SEARCH_MAPPINGS = tagname1=loc1 tagname2=loc2 ... # This tag requires that the tag SEARCHENGINE is set to YES. -EXTRA_SEARCH_MAPPINGS = +EXTRA_SEARCH_MAPPINGS = #--------------------------------------------------------------------------- # Configuration options related to the LaTeX output @@ -1710,7 +1721,7 @@ PAPER_TYPE = a4 # If left blank no extra packages will be included. # This tag requires that the tag GENERATE_LATEX is set to YES. -EXTRA_PACKAGES = +EXTRA_PACKAGES = # The LATEX_HEADER tag can be used to specify a personal LaTeX header for the # generated LaTeX document. The header should contain everything until the first @@ -1726,7 +1737,7 @@ EXTRA_PACKAGES = # to HTML_HEADER. # This tag requires that the tag GENERATE_LATEX is set to YES. -LATEX_HEADER = +LATEX_HEADER = # The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for the # generated LaTeX document. The footer should contain everything after the last @@ -1737,7 +1748,7 @@ LATEX_HEADER = # Note: Only use a user-defined footer if you know what you are doing! # This tag requires that the tag GENERATE_LATEX is set to YES. -LATEX_FOOTER = +LATEX_FOOTER = # The LATEX_EXTRA_STYLESHEET tag can be used to specify additional user-defined # LaTeX style sheets that are included after the standard style sheets created @@ -1748,7 +1759,7 @@ LATEX_FOOTER = # list). # This tag requires that the tag GENERATE_LATEX is set to YES. -LATEX_EXTRA_STYLESHEET = +LATEX_EXTRA_STYLESHEET = # The LATEX_EXTRA_FILES tag can be used to specify one or more extra images or # other source files which should be copied to the LATEX_OUTPUT output @@ -1756,7 +1767,7 @@ LATEX_EXTRA_STYLESHEET = # markers available. # This tag requires that the tag GENERATE_LATEX is set to YES. -LATEX_EXTRA_FILES = +LATEX_EXTRA_FILES = # If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated is # prepared for conversion to PDF (using ps2pdf or pdflatex). The PDF file will @@ -1803,7 +1814,7 @@ LATEX_SOURCE_CODE = NO # The LATEX_BIB_STYLE tag can be used to specify the style to use for the # bibliography, e.g. plainnat, or ieeetr. See -# https://en.wikipedia.org/wiki/BibTeX and \cite for more info. +# http://en.wikipedia.org/wiki/BibTeX and \cite for more info. # The default value is: plain. # This tag requires that the tag GENERATE_LATEX is set to YES. @@ -1864,14 +1875,14 @@ RTF_HYPERLINKS = NO # default style sheet that doxygen normally uses. # This tag requires that the tag GENERATE_RTF is set to YES. -RTF_STYLESHEET_FILE = +RTF_STYLESHEET_FILE = # Set optional variables used in the generation of an RTF document. Syntax is # similar to doxygen's config file. A template extensions file can be generated # using doxygen -e rtf extensionFile. # This tag requires that the tag GENERATE_RTF is set to YES. -RTF_EXTENSIONS_FILE = +RTF_EXTENSIONS_FILE = # If the RTF_SOURCE_CODE tag is set to YES then doxygen will include source code # with syntax highlighting in the RTF output. @@ -1916,7 +1927,7 @@ MAN_EXTENSION = .3 # MAN_EXTENSION with the initial . removed. # This tag requires that the tag GENERATE_MAN is set to YES. -MAN_SUBDIR = +MAN_SUBDIR = # If the MAN_LINKS tag is set to YES and doxygen generates man output, then it # will generate one additional man file for each entity documented in the real @@ -1986,9 +1997,9 @@ DOCBOOK_PROGRAMLISTING = NO #--------------------------------------------------------------------------- # If the GENERATE_AUTOGEN_DEF tag is set to YES, doxygen will generate an -# AutoGen Definitions (see http://autogen.sourceforge.net/) file that captures -# the structure of the code including all documentation. Note that this feature -# is still experimental and incomplete at the moment. +# AutoGen Definitions (see http://autogen.sf.net) file that captures the +# structure of the code including all documentation. Note that this feature is +# still experimental and incomplete at the moment. # The default value is: NO. GENERATE_AUTOGEN_DEF = NO @@ -2029,7 +2040,7 @@ PERLMOD_PRETTY = YES # overwrite each other's variables. # This tag requires that the tag GENERATE_PERLMOD is set to YES. -PERLMOD_MAKEVAR_PREFIX = +PERLMOD_MAKEVAR_PREFIX = #--------------------------------------------------------------------------- # Configuration options related to the preprocessor @@ -2070,7 +2081,7 @@ SEARCH_INCLUDES = YES # preprocessor. # This tag requires that the tag SEARCH_INCLUDES is set to YES. -INCLUDE_PATH = +INCLUDE_PATH = # You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard # patterns (like *.h and *.hpp) to filter out the header-files in the @@ -2078,7 +2089,7 @@ INCLUDE_PATH = # used. # This tag requires that the tag ENABLE_PREPROCESSING is set to YES. -INCLUDE_FILE_PATTERNS = +INCLUDE_FILE_PATTERNS = # The PREDEFINED tag can be used to specify one or more macro names that are # defined before the preprocessor is started (similar to the -D option of e.g. @@ -2088,7 +2099,7 @@ INCLUDE_FILE_PATTERNS = # recursively expanded use the := operator instead of the = operator. # This tag requires that the tag ENABLE_PREPROCESSING is set to YES. -PREDEFINED = +PREDEFINED = # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this # tag can be used to specify a list of macro names that should be expanded. The @@ -2097,7 +2108,7 @@ PREDEFINED = # definition found in the source code. # This tag requires that the tag ENABLE_PREPROCESSING is set to YES. -EXPAND_AS_DEFINED = +EXPAND_AS_DEFINED = # If the SKIP_FUNCTION_MACROS tag is set to YES then doxygen's preprocessor will # remove all references to function-like macros that are alone on a line, have @@ -2126,13 +2137,13 @@ SKIP_FUNCTION_MACROS = YES # the path). If a tag file is not located in the directory in which doxygen is # run, you must also specify the path to the tagfile here. -TAGFILES = +TAGFILES = # When a file name is specified after GENERATE_TAGFILE, doxygen will create a # tag file that is based on the input files it reads. See section "Linking to # external documentation" for more information about the usage of tag files. -GENERATE_TAGFILE = +GENERATE_TAGFILE = # If the ALLEXTERNALS tag is set to YES, all external class will be listed in # the class index. If set to NO, only the inherited external classes will be @@ -2172,7 +2183,7 @@ PERL_PATH = /usr/bin/perl # powerful graphs. # The default value is: YES. -CLASS_DIAGRAMS = YES +CLASS_DIAGRAMS = NO # You can define message sequence charts within doxygen comments using the \msc # command. Doxygen will then run the mscgen tool (see: @@ -2181,14 +2192,14 @@ CLASS_DIAGRAMS = YES # the mscgen tool resides. If left empty the tool is assumed to be found in the # default search path. -MSCGEN_PATH = +MSCGEN_PATH = # You can include diagrams made with dia in doxygen documentation. Doxygen will # then run dia to produce the diagram and insert it in the documentation. The # DIA_PATH tag allows you to specify the directory where the dia binary resides. # If left empty dia is assumed to be found in the default search path. -DIA_PATH = +DIA_PATH = # If set to YES the inheritance and collaboration graphs will hide inheritance # and usage relations if the target is undocumented or is not a class. @@ -2201,9 +2212,9 @@ HIDE_UNDOC_RELATIONS = YES # http://www.graphviz.org/), a graph visualization toolkit from AT&T and Lucent # Bell Labs. The other options in this section have no effect if this option is # set to NO -# The default value is: NO. +# The default value is: YES. -HAVE_DOT = NO +HAVE_DOT = YES # The DOT_NUM_THREADS specifies the number of dot invocations doxygen is allowed # to run in parallel. When set to 0 doxygen will base this on the number of @@ -2237,7 +2248,7 @@ DOT_FONTSIZE = 10 # the path where dot can find it using this tag. # This tag requires that the tag HAVE_DOT is set to YES. -DOT_FONTPATH = +DOT_FONTPATH = # If the CLASS_GRAPH tag is set to YES then doxygen will generate a graph for # each documented class showing the direct and indirect inheritance relations. @@ -2320,7 +2331,7 @@ INCLUDED_BY_GRAPH = YES # The default value is: NO. # This tag requires that the tag HAVE_DOT is set to YES. -CALL_GRAPH = NO +CALL_GRAPH = YES # If the CALLER_GRAPH tag is set to YES then doxygen will generate a caller # dependency graph for every global function or class method. @@ -2332,7 +2343,7 @@ CALL_GRAPH = NO # The default value is: NO. # This tag requires that the tag HAVE_DOT is set to YES. -CALLER_GRAPH = NO +CALLER_GRAPH = YES # If the GRAPHICAL_HIERARCHY tag is set to YES then doxygen will graphical # hierarchy of all classes instead of a textual one. @@ -2357,7 +2368,9 @@ DIRECTORY_GRAPH = YES # Note: If you choose svg you need to set HTML_FILE_EXTENSION to xhtml in order # to make the SVG files visible in IE 9+ (other browsers do not have this # requirement). -# Possible values are: png, jpg, gif, svg, png:gd, png:gd:gd, png:cairo, +# Possible values are: png, png:cairo, png:cairo:cairo, png:cairo:gd, png:gd, +# png:gd:gd, jpg, jpg:cairo, jpg:cairo:gd, jpg:gd, jpg:gd:gd, gif, gif:cairo, +# gif:cairo:gd, gif:gd, gif:gd:gd, svg, png:gd, png:gd:gd, png:cairo, # png:cairo:gd, png:cairo:cairo, png:cairo:gdiplus, png:gdiplus and # png:gdiplus:gdiplus. # The default value is: png. @@ -2375,32 +2388,32 @@ DOT_IMAGE_FORMAT = png # The default value is: NO. # This tag requires that the tag HAVE_DOT is set to YES. -INTERACTIVE_SVG = YES +INTERACTIVE_SVG = NO # The DOT_PATH tag can be used to specify the path where the dot tool can be # found. If left blank, it is assumed the dot tool can be found in the path. # This tag requires that the tag HAVE_DOT is set to YES. -DOT_PATH = +DOT_PATH = # The DOTFILE_DIRS tag can be used to specify one or more directories that # contain dot files that are included in the documentation (see the \dotfile # command). # This tag requires that the tag HAVE_DOT is set to YES. -DOTFILE_DIRS = +DOTFILE_DIRS = # The MSCFILE_DIRS tag can be used to specify one or more directories that # contain msc files that are included in the documentation (see the \mscfile # command). -MSCFILE_DIRS = +MSCFILE_DIRS = # The DIAFILE_DIRS tag can be used to specify one or more directories that # contain dia files that are included in the documentation (see the \diafile # command). -DIAFILE_DIRS = +DIAFILE_DIRS = # When using plantuml, the PLANTUML_JAR_PATH tag should be used to specify the # path where java can find the plantuml.jar file. If left blank, it is assumed @@ -2408,17 +2421,17 @@ DIAFILE_DIRS = # generate a warning when it encounters a \startuml command in this case and # will not generate output for the diagram. -PLANTUML_JAR_PATH = +PLANTUML_JAR_PATH = # When using plantuml, the PLANTUML_CFG_FILE tag can be used to specify a # configuration file for plantuml. -PLANTUML_CFG_FILE = +PLANTUML_CFG_FILE = # When using plantuml, the specified paths are searched for files specified by # the !include statement in a plantuml block. -PLANTUML_INCLUDE_PATH = +PLANTUML_INCLUDE_PATH = # The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of nodes # that will be shown in the graph. If the number of nodes in a graph becomes diff --git a/FindBoost.cmake b/FindBoost.cmake index 3c6ff9051d714cf927768bd91672d0db5e4ac2b6..c9aceea1b507fb839b0d34bcb318be77416a4728 100644 --- a/FindBoost.cmake +++ b/FindBoost.cmake @@ -65,10 +65,10 @@ set(TMP "") list(APPEND Boost_INCLUDE_DIRS ${TMP}) #endif() -message("Boost_INCLUDE_DIRS: ${Boost_INCLUDE_DIRS}") - if(NOT Boost_INCLUDE_DIRS) message(FATAL_ERROR "Boost include directory was not found! Please, set variable BOOST_INCLUDEDIR to the correct path.") +else() + message("Boost_INCLUDE_DIRS: ${Boost_INCLUDE_DIRS}") endif() # Create a list of requested Boost libraries with "system" names @@ -76,8 +76,10 @@ if(NOT DEPENDENCIES_LINK_TYPE) message(FATAL_ERROR "Variable DEPENDENCIES_LINK_TYPE is not set! Set it to 'static' or 'shared'.") endif() +set(LIB_PREFIX "lib") set(LIB_SUFFIX "a") # suffix for Linux static libraries if("${DEPENDENCIES_LINK_TYPE}" STREQUAL "shared" AND WIN32) + set(LIB_PREFIX "") set(LIB_SUFFIX "dll") elseif("${DEPENDENCIES_LINK_TYPE}" STREQUAL "static" AND WIN32) set(LIB_SUFFIX "lib") @@ -85,16 +87,13 @@ elseif("${DEPENDENCIES_LINK_TYPE}" STREQUAL "shared") set(LIB_SUFFIX "so") endif() -set(LIB_PREFIX "lib") -#if(WIN32) -# set(LIB_PREFIX "") -#endif() - set(REQUESTED_BOOST_LIBS "") foreach(COMPONENT ${Boost_FIND_COMPONENTS}) list(APPEND REQUESTED_BOOST_LIBS "${LIB_PREFIX}boost_${COMPONENT}.${LIB_SUFFIX}") endforeach() +message("REQUESTED_BOOST_LIBS: ${REQUESTED_BOOST_LIBS}") + # Look for libraries specified by COMPONENTS flag set(Boost_LIBRARY_DIRS "Boost_LIBRARY_DIRS-NOTFOUND") find_path( @@ -121,6 +120,8 @@ find_path( if(NOT Boost_LIBRARY_DIRS) message(FATAL_ERROR "Boost library directory was not found! Please, set variable BOOST_LIBRARYDIR to the correct path.") +else() + message("Boost_LIBRARY_DIRS: ${Boost_LIBRARY_DIRS}") endif() # Construct list of libraries' names and make them @@ -169,10 +170,10 @@ endif() INCLUDE(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS( Boost - - FAIL_MESSAGE + + FAIL_MESSAGE "Boost was NOT found!" - + REQUIRED_VARS Boost_INCLUDE_DIRS Boost_LIBRARY_DIRS diff --git a/build.sh b/build.sh index fe05cad1cf9fb33d3894ba5b9bc3ffdbe44c6606..493683988e69d7153f005082d8a1dc33394cece1 100755 --- a/build.sh +++ b/build.sh @@ -7,17 +7,17 @@ # # Modular build parameters # -BUILD_TESTS=no +BUILD_TESTS=yes BUILD_EXAMPLES=yes -BUILD_LIB=no +BUILD_LIB=yes DEPENDENCIES_LINK_TYPE=static # shared/static # Build type (Release/Debug) BUILD_TYPE=Debug # C++ compiler -CXX_COMPILER=g++ -C_COMPILER=gcc +CXX_COMPILER=g++ #/opt/intel/compilers_and_libraries/linux/bin/intel64/icpc +C_COMPILER=gcc #/opt/intel/compilers_and_libraries/linux/bin/intel64/icc if [ -z "$BUILD_TYPE" ] || [ -z "$CXX_COMPILER" ]; then (>&2 echo "Set, please, both BUILD_TYPE and CXX_COMPILER variables in the 'build.sh' script.") diff --git a/build_scripts/linux/linux_run_tests.sh b/build_scripts/linux/linux_run_tests.sh index c6464edd85a92886bf69e6c115bac19746370176..70f3e7f8e738a777e6b6ad66a47ed6c421f25e11 100755 --- a/build_scripts/linux/linux_run_tests.sh +++ b/build_scripts/linux/linux_run_tests.sh @@ -6,7 +6,7 @@ cd ../.. # UNIT TESTS # ############## for f in build/unit-tests/*_test; do - ${f} || exit -1 + ${f} || exit 1 done -cd build_scripts/linux \ No newline at end of file +cd build_scripts/linux diff --git a/build_scripts/windows/win_VS_build_x64_debug.bat b/build_scripts/windows/win_VS_build_x64_debug.bat index 15a9ce5a1298273a0521f8bb84cb3f8fd0749d26..53ce24c01ba1fdd9d709e9d83cca9c997977d128 100644 --- a/build_scripts/windows/win_VS_build_x64_debug.bat +++ b/build_scripts/windows/win_VS_build_x64_debug.bat @@ -111,5 +111,5 @@ goto final_goto :final_goto IF "%BUILD_LIB%"=="yes" call win_clean_after_lib.bat IF "%BUILD_EXAMPLES%"=="yes" call win_clean_after_examples.bat -IF "%BUILD_TESTS%"=="yes" call win_clean_after_tests.bat +IF "%BUILD_TESTS%"=="yes" call win_clean_after_tests.bat IF "%BUILD_SOMETHING_LIB%"=="yes" call win_clean_garbage.bat \ No newline at end of file diff --git a/build_scripts/windows/win_run_tests.bat b/build_scripts/windows/win_run_tests.bat index b458df1b9236b4ed4343d68f583282be2c85083d..fffb6ba1cf646cec16f4807d1cfb15e451987396 100644 --- a/build_scripts/windows/win_run_tests.bat +++ b/build_scripts/windows/win_run_tests.bat @@ -3,6 +3,6 @@ title Running 'lib4neuro' unit-tests cd ..\..\build\unit-tests rem Runs all the available Unit-Tests -for /r %%v in ("*_test.exe") do call %%v +for /r %%v in ("*_test") do %%v -cd ..\..\build_scripts\windows \ No newline at end of file +cd ..\..\build_scripts\windows diff --git a/ci_run_tests.sh b/ci_run_tests.sh index dfc202791eb6650bd81be3269dba2a8b12149955..1c1b5a5838636f3892dd5845a8b8f51791ec0f8f 100755 --- a/ci_run_tests.sh +++ b/ci_run_tests.sh @@ -3,7 +3,7 @@ ############## # UNIT TESTS # ############## -for f in build/unit-tests/bin/*_test; do +for f in build/unit-tests/*_test; do ${f} || exit -1 done diff --git a/external_dependencies/boost b/external_dependencies/boost index b587bd3bbfb42520838ccd516dabc8684fbdd8a8..86995e904fade2753938883e8716466f27620496 160000 --- a/external_dependencies/boost +++ b/external_dependencies/boost @@ -1 +1 @@ -Subproject commit b587bd3bbfb42520838ccd516dabc8684fbdd8a8 +Subproject commit 86995e904fade2753938883e8716466f27620496 diff --git a/include/4neuro.h b/include/4neuro.h new file mode 100644 index 0000000000000000000000000000000000000000..486fa50b13c33a9370b602f0feccc7291681da9d --- /dev/null +++ b/include/4neuro.h @@ -0,0 +1,26 @@ +// +// Created by martin on 7/16/18. +// + +#ifndef INC_4NEURO_4NEURO_H +#define INC_4NEURO_4NEURO_H + +//TODO make only public interface visible + +#include "../src/DataSet/DataSet.h" +#include "../src/LearningMethods/ParticleSwarm.h" +#include "../src/NetConnection/ConnectionFunctionGeneral.h" +#include "../src/NetConnection/ConnectionFunctionIdentity.h" +#include "../src/Network/NeuralNetwork.h" +//#include "../src/Network/NeuralNetworkSum.h" +#include "../src/Neuron/Neuron.h" +#include "../src/Neuron/NeuronBinary.h" +#include "../src/Neuron/NeuronLinear.h" +#include "../src/Neuron/NeuronLogistic.h" +#include "../src/Solvers/DESolver.h" +#include "../src/constants.h" +#include "../src/settings.h" +#include "../src/message.h" + + +#endif //INC_4NEURO_4NEURO_H diff --git a/include/lib4neuro.h b/include/lib4neuro.h deleted file mode 100644 index 5bf4710e93dc0c5ca00cfb6d1c4417a9003cbe57..0000000000000000000000000000000000000000 --- a/include/lib4neuro.h +++ /dev/null @@ -1,61 +0,0 @@ -// -// Created by martin on 7/16/18. -// Edited by michal on 9/15/18 -// - -#ifndef INC_4NEURO_4NEURO_H -#define INC_4NEURO_4NEURO_H - -/* PREREQUISITIES */ -//#include <string> - -/** - * If defined, the NN feed-forward will print out whats happening - */ -//#define VERBOSE_NN_EVAL - -#ifdef _WINDOWS -#define LIB4NEURO_API __declspec(dllexport) -#else -#define LIB4NEURO_API -#endif - -/* CLASSES */ -//class DataSet; - -/* ACCESSIBLE CLASS METHODS */ -//static DataSet::DataSet(std::string file_path); - -#include "../src/DataSet/DataSet.h" - -#include <iostream> -#include <fstream> -#include <utility> -#include <vector> -#include <exception> -#include <string> -#include <functional> -//#include <boost/serialization/base_object.hpp> -//#include <boost/range/size_type.hpp> -//#include <boost/serialization/vector.hpp> -//#include <boost/serialization/utility.hpp> -//#include <boost/archive/text_oarchive.hpp> -//#include <boost/archive/text_iarchive.hpp> - - -#include "../src/ErrorFunction/ErrorFunctions.h" -#include "../src/LearningMethods/ParticleSwarm.h" -#include "../src/LearningMethods/GradientDescent.h" -#include "../src/NetConnection/ConnectionFunctionGeneral.h" -#include "../src/NetConnection/ConnectionFunctionIdentity.h" -#include "../src/Network/NeuralNetwork.h" -#include "../src/Network/NeuralNetworkSum.h" -#include "../src/Solvers/DESolver.h" - -/* OK */ -#include "../src/Neuron/Neuron.h" -#include "../src/Neuron/NeuronBinary.h" -#include "../src/Neuron/NeuronLinear.h" -#include "../src/Neuron/NeuronLogistic.h" - -#endif //INC_4NEURO_4NEURO_H diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7ff3ef006dd8291a0e2b95a01442de8dccebe805..4c1c33671b791caafcd79016ef39f1dea9bdd2c7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -7,44 +7,64 @@ if ("${BUILD_EXAMPLES}" STREQUAL "yes") endif () if ("${BUILD_LIB}" STREQUAL "yes") + add_library( + exprtk_wrap + + SHARED + + General/ExprtkWrapper.cpp + ) + + target_include_directories( + exprtk_wrap + + PRIVATE + ${EXPRTK_INCLUDE_DIR} + ${Boost_INCLUDE_DIRS} + ) + + target_link_libraries( + exprtk_wrap + + PRIVATE + ${Boost_LIBRARIES} + ) + add_library(lib4neuro SHARED - Neuron/Neuron.cpp + Neuron/Neuron.cpp Neuron/NeuronBinary.cpp - Neuron/NeuronConstant.cpp + Neuron/NeuronConstant.cpp Neuron/NeuronLinear.cpp - Neuron/NeuronLogistic.cpp - Network/NeuralNetwork.cpp - Network/NeuralNetworkSum.cpp - NetConnection/ConnectionFunctionGeneral.cpp - NetConnection/ConnectionFunctionIdentity.cpp + Neuron/NeuronLogistic.cpp + Network/NeuralNetwork.cpp + Network/NeuralNetworkSum.cpp + NetConnection/ConnectionFunctionGeneral.cpp + NetConnection/ConnectionFunctionIdentity.cpp LearningMethods/ParticleSwarm.cpp LearningMethods/GradientDescent.cpp DataSet/DataSet.cpp ErrorFunction/ErrorFunctions.cpp Solvers/DESolver.cpp - General/ExprtkWrapper.cpp ) target_link_libraries( lib4neuro PRIVATE + exprtk_wrap ${Boost_LIBRARIES} ) target_include_directories( lib4neuro - #TODO Boost_INCLUDE_DIRS should be PRIVATE - rewrite code accordingly! PUBLIC - ${ROOT_DIR}/include - ${EXPRTK_INCLUDE_DIR} - ${Boost_INCLUDE_DIRS} + ${ROOT_DIR}/include PRIVATE + ${EXPRTK_INCLUDE_DIR} ${SRC_DIR} - -# ${Boost_INCLUDE_DIRS} + ${Boost_INCLUDE_DIRS} ) set_target_properties( @@ -61,8 +81,8 @@ if ("${BUILD_LIB}" STREQUAL "yes") # set(PREFIX "lib") # endif() if(WIN32 AND "${DEPENDENCIES_LINK_TYPE}" STREQUAL "shared") - message(FATAL_ERROR "Only static linking of external dependencies is supported for Windows systems now!") - elseif("${DEPENDENCIES_LINK_TYPE}" STREQUAL "static") + add_library(${PREFIX}boost_unit_test STATIC boost_test_lib_dummy.cpp) + elseif("${DEPENDENCIES_LINK_TYPE}" STREQUAL "static") add_library(${PREFIX}boost_unit_test STATIC boost_test_lib_dummy.cpp) elseif("${DEPENDENCIES_LINK_TYPE}" STREQUAL "shared") add_library(${PREFIX}boost_unit_test SHARED boost_test_lib_dummy.cpp) @@ -72,8 +92,8 @@ if ("${BUILD_LIB}" STREQUAL "yes") ${PREFIX}boost_unit_test PRIVATE - ${EXPRTK_INCLUDE_DIR} ${Boost_INCLUDE_DIRS} ) endif () + diff --git a/src/DataSet/DataSet.cpp b/src/DataSet/DataSet.cpp index 6f22cd5af01a18a2e7b1fd0d7739f56840be3ec8..b3efddc20b886503fafcc859eee0bc984767c690 100644 --- a/src/DataSet/DataSet.cpp +++ b/src/DataSet/DataSet.cpp @@ -2,7 +2,8 @@ // Created by martin on 7/13/18. // -#include "DataSet.h" + +#include "DataSetSerialization.h" InvalidDimension::InvalidDimension() : std::runtime_error("Invalid dimension specified!") {}; diff --git a/src/DataSet/DataSet.h b/src/DataSet/DataSet.h index 0c037f1c04c2b6a8c30f2effc46b40cc570b0ca7..3be44705eacee7e55d19e94ea2a44cd796589875 100644 --- a/src/DataSet/DataSet.h +++ b/src/DataSet/DataSet.h @@ -12,13 +12,8 @@ #include <exception> #include <string> #include <functional> -#include <boost/serialization/base_object.hpp> -#include <boost/range/size_type.hpp> -#include <boost/serialization/vector.hpp> -#include <boost/serialization/utility.hpp> -#include <boost/archive/text_oarchive.hpp> -#include <boost/archive/text_iarchive.hpp> +#include "../settings.h" /** * Class representing an error caused by an incorrect @@ -30,13 +25,13 @@ public: /** * Constructor with the general error message */ - InvalidDimension(); + InvalidDimension(); /** * Constructor with specific error message * @param msg Specific error message */ - explicit InvalidDimension(std::string msg); + explicit InvalidDimension(std::string msg); }; /** @@ -44,9 +39,10 @@ public: * and testing purposes. */ class DataSet { - friend class boost::serialization::access; +// friend class boost::serialization::access; private: + /** * Number of elements in the data set */ @@ -71,34 +67,25 @@ private: template <class T> std::vector<std::vector<T>> cartesian_product(const std::vector<std::vector<T>>* v); -protected: +public: + /** - * Serialization function - * @tparam Archive Boost library template - * @param ar Boost parameter - filled automatically during serialization! - * @param version Boost parameter - filled automatically during serialization! + * Struct used to access private properties from + * the serialization function */ - template<class Archive> - void serialize(Archive & ar, const unsigned int version){ - ar & this->n_elements; - ar & this->input_dim; - ar & this->output_dim; - ar & this->data; - }; - -public: + struct access; /** * Constructor reading data from the file * @param file_path Path to the file with stored data set */ - DataSet(std::string file_path); + LIB4NEURO_API DataSet(std::string file_path); /** * Constructor accepting data vector * @param data_ptr Pointer to the vector containing data */ - DataSet(std::vector<std::pair<std::vector<double>, std::vector<double>>>* data_ptr); + LIB4NEURO_API DataSet(std::vector<std::pair<std::vector<double>, std::vector<double>>>* data_ptr); /** * Creates a new data set with input values equidistantly positioned @@ -114,7 +101,7 @@ public: * @param size Number of input-output pairs generated * @param output Constant output value */ - DataSet(double lower_bound, double upper_bound, unsigned int size, double output); + LIB4NEURO_API DataSet(double lower_bound, double upper_bound, unsigned int size, double output); /** * @@ -123,39 +110,39 @@ public: * @param output_func * @param output_dim */ - DataSet(std::vector<double> &bounds, unsigned int no_elems_in_one_dim, std::vector<double> (*output_func)(std::vector<double>&), unsigned int output_dim); + LIB4NEURO_API DataSet(std::vector<double> &bounds, unsigned int no_elems_in_one_dim, std::vector<double> (*output_func)(std::vector<double>&), unsigned int output_dim); /** * Getter for number of elements * @return Number of elements in the data set */ - size_t get_n_elements(); + LIB4NEURO_API size_t get_n_elements(); /** * Returns the input dimension * @return Input dimension */ - size_t get_input_dim(); + LIB4NEURO_API size_t get_input_dim(); /** * Return the output dimension * @return Output dimension */ - size_t get_output_dim(); + LIB4NEURO_API size_t get_output_dim(); /** * Getter for the data structure * @return Vector of data */ - std::vector<std::pair<std::vector<double>, std::vector<double>>>* get_data(); + LIB4NEURO_API std::vector<std::pair<std::vector<double>, std::vector<double>>>* get_data(); /** * Adds a new pair of data to the data set * @param inputs Vector of input data * @param outputs Vector of output data corresponding to the input data */ - void add_data_pair(std::vector<double> &inputs, std::vector<double> &outputs); + LIB4NEURO_API void add_data_pair(std::vector<double> &inputs, std::vector<double> &outputs); //TODO expand method to generate multiple data types - chebyshev etc. /** @@ -170,7 +157,7 @@ public: * @param size Number of input-output pairs generated * @param output Constant output value */ - void add_isotropic_data(double lower_bound, double upper_bound, unsigned int size, double output); + LIB4NEURO_API void add_isotropic_data(double lower_bound, double upper_bound, unsigned int size, double output); /** * Adds a new data with input values equidistantly positioned @@ -184,19 +171,19 @@ public: * @param size Number of input-output pairs generated * @param output_func Function determining output value */ - void add_isotropic_data(std::vector<double> &bounds, unsigned int no_elems_in_one_dim, std::vector<double> (*output_func)(std::vector<double>&)); + LIB4NEURO_API void add_isotropic_data(std::vector<double> &bounds, unsigned int no_elems_in_one_dim, std::vector<double> (*output_func)(std::vector<double>&)); //TODO Chebyshev - ch. interpolation points, i-th point = cos(i*alpha) from 0 to pi /** * Prints the data set */ - void print_data(); + LIB4NEURO_API void print_data(); /** * Stores the DataSet object to the binary file */ - void store_text(std::string &file_path); + LIB4NEURO_API void store_text(std::string &file_path); }; #endif //INC_4NEURO_DATASET_H diff --git a/src/DataSet/DataSetSerialization.h b/src/DataSet/DataSetSerialization.h new file mode 100644 index 0000000000000000000000000000000000000000..39a1a6bc1b490f1de5dcecd441aed52471709016 --- /dev/null +++ b/src/DataSet/DataSetSerialization.h @@ -0,0 +1,46 @@ +// +// Created by martin on 9/18/18. +// + +#ifndef LIB4NEURO_DATASETSERIALIZATION_H +#define LIB4NEURO_DATASETSERIALIZATION_H + +#include <boost/serialization/base_object.hpp> +#include <boost/range/size_type.hpp> +#include <boost/serialization/vector.hpp> +#include <boost/serialization/utility.hpp> +#include <boost/archive/text_oarchive.hpp> +#include <boost/archive/text_iarchive.hpp> + +#include "DataSet.h" + +struct DataSet :: access { + template <class Archive> + static void serialize(Archive &ar, DataSet& ds, const unsigned int version) { + ar & ds.n_elements; + ar & ds.input_dim; + ar & ds.output_dim; + ar & ds.data; + } +}; + +namespace boost { + namespace serialization { + + /** + * Serialization function + * @tparam Archive Boost library template + * @param ar Boost parameter - filled automatically during serialization! + * @param ds DataSet instance + * @param version Boost parameter - filled automatically during serialization! + */ + template<class Archive> + void serialize(Archive & ar, DataSet & ds, const unsigned int version) + { + DataSet::access::serialize(ar, ds, version); + } + + } // namespace serialization +} // namespace boost + +#endif //LIB4NEURO_DATASETSERIALIZATION_H diff --git a/src/ErrorFunction/ErrorFunctions.h b/src/ErrorFunction/ErrorFunctions.h index 3bef0bd82d8924366e727f68eee1e2e3574b5454..cdecc61b55c63920d7dffbb210589709abacae50 100644 --- a/src/ErrorFunction/ErrorFunctions.h +++ b/src/ErrorFunction/ErrorFunctions.h @@ -7,14 +7,13 @@ #include "../Network/NeuralNetwork.h" #include "../DataSet/DataSet.h" -#include "exprtk.hpp" + enum ErrorFunctionType{ ErrorFuncMSE }; - class ErrorFunction { public: diff --git a/src/General/ExprtkWrapper.cpp b/src/General/ExprtkWrapper.cpp index 03738f6474be96957e52c0296d1631daa8198d3b..7abf68596a225b61f655e3bbf05e8db300aaa5a1 100644 --- a/src/General/ExprtkWrapper.cpp +++ b/src/General/ExprtkWrapper.cpp @@ -5,75 +5,86 @@ * @date 4.9.18 - */ +#include <boost/serialization/export.hpp> + +#include "exprtk.hpp" #include "ExprtkWrapper.h" +#include "ExprtkWrapperSerialization.h" +#include "../exceptions.h" + +BOOST_CLASS_EXPORT_IMPLEMENT(ExprtkWrapper); +ExprtkWrapper::ExprtkWrapper() { + // Because of serialization + // TODO implement? +} ExprtkWrapper::ExprtkWrapper( std::string expression_string ) { - this->expression_str = expression_string; + this->p_impl->expression_str = expression_string; - this->symbol_table = new symbol_table_t( ); + this->p_impl->symbol_table = new symbol_table_t( ); - this->symbol_table->add_variable("x", this->x); - this->symbol_table->add_variable("y", this->y); - this->symbol_table->add_variable("z", this->z); - this->symbol_table->add_variable("t", this->t); - this->symbol_table->add_variable("f", this->z); + this->p_impl->symbol_table->add_variable("x", this->p_impl->x); + this->p_impl->symbol_table->add_variable("y", this->p_impl->y); + this->p_impl->symbol_table->add_variable("z", this->p_impl->z); + this->p_impl->symbol_table->add_variable("t", this->p_impl->t); + this->p_impl->symbol_table->add_variable("f", this->p_impl->z); - this->expression = new expression_t( ); - this->expression->register_symbol_table( *this->symbol_table ); + this->p_impl->expression = new expression_t( ); + this->p_impl->expression->register_symbol_table( *this->p_impl->symbol_table ); - this->parser = new parser_t( ); - parser->compile(this->expression_str, *this->expression ); + this->p_impl->parser = new parser_t( ); + this->p_impl->parser->compile(this->p_impl->expression_str, *this->p_impl->expression ); } ExprtkWrapper::~ExprtkWrapper() { - if( this->expression ){ - delete this->expression; - this->expression = nullptr; + if( this->p_impl->expression ){ + delete this->p_impl->expression; + this->p_impl->expression = nullptr; } - if( this->symbol_table ){ - delete this->symbol_table; - this->symbol_table = nullptr; + if( this->p_impl->symbol_table ){ + delete this->p_impl->symbol_table; + this->p_impl->symbol_table = nullptr; } - if( this->parser ){ - delete this->parser; - this->parser = nullptr; + if( this->p_impl->parser ){ + delete this->p_impl->parser; + this->p_impl->parser = nullptr; } } double ExprtkWrapper::eval(double x1, double x2, double x3, double x4) { - this->x = x1; - this->y = x2; - this->z = x3; - this->t = x4; + this->p_impl->x = x1; + this->p_impl->y = x2; + this->p_impl->z = x3; + this->p_impl->t = x4; - return this->expression->value(); + return this->p_impl->expression->value(); } double ExprtkWrapper::eval(std::vector<double> &p) { if(p.size() > 0){ - this->x = p[0]; + this->p_impl->x = p[0]; } if(p.size() > 1){ - this->y = p[1]; + this->p_impl->y = p[1]; } if(p.size() > 2){ - this->z = p[2]; + this->p_impl->z = p[2]; } if(p.size() > 3){ - this->t = p[3]; + this->p_impl->t = p[3]; } - double result = this->expression->value(); + double result = this->p_impl->expression->value(); return result; } \ No newline at end of file diff --git a/src/General/ExprtkWrapper.h b/src/General/ExprtkWrapper.h index b3e9ca5515ee0758d82a929ac6d7ed378a932118..0b7f46d872c131d5cf32e8e42cb0d5c8e56e61c8 100644 --- a/src/General/ExprtkWrapper.h +++ b/src/General/ExprtkWrapper.h @@ -8,34 +8,37 @@ #ifndef LIB4NEURO_EXPRTKWRAPPER_H #define LIB4NEURO_EXPRTKWRAPPER_H +#include <memory> +#include <vector> - -#include "exprtk.hpp" +#include "../settings.h" class ExprtkWrapper { - typedef exprtk::symbol_table<double> symbol_table_t; - typedef exprtk::expression<double> expression_t; - typedef exprtk::parser<double> parser_t; - public: + /** + * Struct used to access private properties from + * the serialization function + */ + struct access; + /** * * @param expression_string * @param var_dim */ - ExprtkWrapper( std::string expression_string ); + LIB4NEURO_API ExprtkWrapper( std::string expression_string ); /** * */ - ExprtkWrapper( ); + LIB4NEURO_API ExprtkWrapper( ); /** * */ - ~ExprtkWrapper(); + LIB4NEURO_API ~ExprtkWrapper(); /** * @@ -45,42 +48,26 @@ public: * @param x4 * @return */ - double eval(double x1 = 0.0, double x2 = 0.0, double x3 = 0.0, double x4 = 0.0); + LIB4NEURO_API double eval(double x1 = 0.0, double x2 = 0.0, double x3 = 0.0, double x4 = 0.0); /** * * @param p * @return */ - double eval(std::vector<double> &p); + LIB4NEURO_API double eval(std::vector<double> &p); private: /** + * Private properties * + * They are hidden in .cpp file + * to isolate Exprtk dependency from header */ - expression_t *expression = nullptr; - - /** - * - */ - symbol_table_t *symbol_table = nullptr; - - /** - * - */ - parser_t * parser = nullptr; - - /* - * variables - */ - double x, y, z, t, f; - - /** - * referential expression string - */ - - std::string expression_str; + class ExprtkWrapperImpl; + std::unique_ptr<ExprtkWrapperImpl> p_impl; }; + #endif //LIB4NEURO_EXPRTKWRAPPER_H diff --git a/src/General/ExprtkWrapperSerialization.h b/src/General/ExprtkWrapperSerialization.h new file mode 100644 index 0000000000000000000000000000000000000000..9996d15bd7cab36989b2d2fa80c93d1644ff29c8 --- /dev/null +++ b/src/General/ExprtkWrapperSerialization.h @@ -0,0 +1,89 @@ +// +// Created by martin on 9/17/18. +// + +#ifndef LIB4NEURO_EXPRTKWRAPPERSERIALIZATION_H +#define LIB4NEURO_EXPRTKWRAPPERSERIALIZATION_H + +#include <boost/archive/text_oarchive.hpp> +#include <boost/archive/text_iarchive.hpp> +#include <boost/serialization/export.hpp> + +//TODO check different order of headers - possible bug +#include "ExprtkWrapper.h" +#include "exprtk.hpp" + +BOOST_CLASS_EXPORT_KEY(ExprtkWrapper); + +typedef exprtk::symbol_table<double> symbol_table_t; +typedef exprtk::expression<double> expression_t; +typedef exprtk::parser<double> parser_t; + +/** + * Class implementing the private properties + * of ExprtkWrapper class. + */ +class ExprtkWrapper :: ExprtkWrapperImpl { + +public: + + /** + * Struct used to access private properties from + * the serialization function + */ + struct access; + + /** + * + */ + expression_t *expression = nullptr; + + /** + * + */ + symbol_table_t *symbol_table = nullptr; + + /** + * + */ + parser_t * parser = nullptr; + + /** + * variables + */ + double x, y, z, t, f; + + /** + * referential expression string + */ + std::string expression_str; +}; + +struct ExprtkWrapper :: access { + template <class Archive> + static void serialize(Archive &ar, ExprtkWrapper& n, const unsigned int version) { + ar & n.p_impl->expression_str; + ar & n.p_impl->x & n.p_impl->y & n.p_impl->z & n.p_impl->t & n.p_impl->f; + } +}; + +namespace boost { + namespace serialization { + + /** + * Serialization function + * @tparam Archive Boost library template + * @param ar Boost parameter - filled automatically during serialization! + * @param n ExprtkWrapper instance + * @param version Boost parameter - filled automatically during serialization! + */ + template<class Archive> + void serialize(Archive & ar, ExprtkWrapper& n, const unsigned int version) + { + ExprtkWrapper::access::serialize(ar, n, version); + } + + } // namespace serialization +} // namespace boost + +#endif //LIB4NEURO_EXPRTKWRAPPERSERIALIZATION_H diff --git a/src/LearningMethods/ParticleSwarm.cpp b/src/LearningMethods/ParticleSwarm.cpp index 763932404ea155386244b962e30db4173006ad32..a7961e3b485e1b5f0784eb94423eb7fbc422fec8 100644 --- a/src/LearningMethods/ParticleSwarm.cpp +++ b/src/LearningMethods/ParticleSwarm.cpp @@ -5,7 +5,19 @@ * @date 2.7.18 - */ +#include <cstdlib> +#include <ctime> +#include <cmath> +#include <set> +#include <stdexcept> +#include <random> +#include <iterator> +#include <algorithm> #include <iostream> + +#include "../Network/NeuralNetwork.h" +#include "../DataSet/DataSet.h" + #include "ParticleSwarm.h" /** diff --git a/src/LearningMethods/ParticleSwarm.h b/src/LearningMethods/ParticleSwarm.h index 007ed5c3cc731f0ea01d26360c287580bf2b408c..f4c6d084b49ee25fb831c72d3dee1e6296e0cb51 100644 --- a/src/LearningMethods/ParticleSwarm.h +++ b/src/LearningMethods/ParticleSwarm.h @@ -8,17 +8,7 @@ #ifndef INC_4NEURO_PARTICLESWARM_H #define INC_4NEURO_PARTICLESWARM_H -#include <cstdlib> -#include <ctime> -#include <cmath> -#include <set> -#include <stdexcept> -#include <random> -#include <iterator> -#include <algorithm> - -#include "../Network/NeuralNetwork.h" -#include "../DataSet/DataSet.h" +#include "../settings.h" #include "../ErrorFunction/ErrorFunctions.h" #include "ILearningMethods.h" @@ -55,38 +45,38 @@ public: /** * */ - void print_coordinate(); + LIB4NEURO_API void print_coordinate(); /** * * @param f_dim */ - Particle( ErrorFunction *ef, std::vector<double> *domain_bounds ); - ~Particle( ); + LIB4NEURO_API Particle(ErrorFunction* ef, double *domain_bounds); + LIB4NEURO_API ~Particle( ); /** * * @return */ - std::vector<double>* get_coordinate(); + LIB4NEURO_API std::vector<double>* get_coordinate(); /** * * @return */ - double get_current_value(); + LIB4NEURO_API double get_current_value(); /** * * @return */ - double get_optimal_value(); + LIB4NEURO_API double get_optimal_value(); /** * * @param ref_coordinate */ - void get_optimal_coordinate(std::vector<double> &ref_coordinate); + LIB4NEURO_API void get_optimal_coordinate(std::vector<double> &ref_coordinate); /** * @@ -96,7 +86,7 @@ public: * @param glob_min_coord * @param penalty_coef */ - double change_coordinate(double w, double c1, double c2, std::vector<double> &glob_min_coord, std::vector<std::vector<double>> &global_min_vec, double penalty_coef=0.25); + LIB4NEURO_API double change_coordinate(double w, double c1, double c2, std::vector<double> &glob_min_coord, std::vector<std::vector<double>> &global_min_vec, double penalty_coef=0.25); }; @@ -147,13 +137,13 @@ protected: * @param val * @return */ - Particle* determine_optimal_coordinate_and_value(std::vector<double> &coord, double &val); + LIB4NEURO_API Particle* determine_optimal_coordinate_and_value(std::vector<double> &coord, double &val); /** * * @return */ - std::vector<double>* get_centroid_coordinates(); + LIB4NEURO_API std::vector<double>* get_centroid_coordinates(); /** * @@ -162,7 +152,7 @@ protected: * @param n * @return */ - double get_euclidean_distance(std::vector<double>* a, std::vector<double>* b); + LIB4NEURO_API double get_euclidean_distance(std::vector<double>* a, std::vector<double>* b); public: @@ -178,7 +168,7 @@ public: * @param iter_max */ //TODO make domain_bounds constant - ParticleSwarm( + LIB4NEURO_API ParticleSwarm( std::vector<double> *domain_bounds, double c1 = 1.711897, double c2 = 1.711897, @@ -193,7 +183,7 @@ public: /** * */ - ~ParticleSwarm( ); + LIB4NEURO_API ~ParticleSwarm( ); /** @@ -202,13 +192,13 @@ public: * @param epsilon * @param delta */ - void optimize( ErrorFunction &ef ) override; + LIB4NEURO_API void optimize( ErrorFunction &ef ) override; /** * * @return */ - std::vector<double>* get_parameters( ) override; + LIB4NEURO_API std::vector<double>* get_parameters( ) override; }; diff --git a/src/NetConnection/ConnectionFunctionGeneral.cpp b/src/NetConnection/ConnectionFunctionGeneral.cpp index a3f410327cfe5d00dfbd0a73e7ddd6b5b491b88c..8174f5abfde4dd6ba32afa974fc50e573725dec9 100644 --- a/src/NetConnection/ConnectionFunctionGeneral.cpp +++ b/src/NetConnection/ConnectionFunctionGeneral.cpp @@ -5,7 +5,11 @@ * @date 14.6.18 - */ -#include "ConnectionFunctionGeneral.h" +#include <boost/serialization/export.hpp> + +#include "ConnectionFunctionGeneralSerialization.h" + +BOOST_CLASS_EXPORT_IMPLEMENT(ConnectionFunctionGeneral); ConnectionFunctionGeneral::ConnectionFunctionGeneral() {} diff --git a/src/NetConnection/ConnectionFunctionGeneral.h b/src/NetConnection/ConnectionFunctionGeneral.h index 4612c980da79301950e39dc63562a95996f3adf4..bbe56e056e09591eb4a2ceef63cc58d81b40138b 100644 --- a/src/NetConnection/ConnectionFunctionGeneral.h +++ b/src/NetConnection/ConnectionFunctionGeneral.h @@ -8,21 +8,13 @@ #ifndef INC_4NEURO_CONNECTIONWEIGHT_H #define INC_4NEURO_CONNECTIONWEIGHT_H -#include <boost/archive/text_oarchive.hpp> -#include <boost/archive/text_iarchive.hpp> -#include <boost/serialization/export.hpp> -#include <boost/serialization/vector.hpp> +#include "../settings.h" +//#include "../ISerializable.h" + #include <functional> #include <vector> class ConnectionFunctionGeneral { -private: - friend class boost::serialization::access; - - template <class Archive> - void serialize(Archive & ar, const unsigned int version) { - ar & this->param_indices; - }; protected: @@ -33,37 +25,42 @@ protected: public: + /** + * Struct used to access private properties from + * the serialization function + */ + struct access; + /** * */ - ConnectionFunctionGeneral(); + LIB4NEURO_API ConnectionFunctionGeneral(); /** * * @param param_count * @param f */ - ConnectionFunctionGeneral(std::vector<size_t> ¶m_indices, std::string &function_string); + LIB4NEURO_API ConnectionFunctionGeneral(std::vector<size_t> ¶m_indices, std::string &function_string); /** * */ - virtual ~ConnectionFunctionGeneral( ); + LIB4NEURO_API virtual ~ConnectionFunctionGeneral( ); /** * * @return */ - virtual double eval( std::vector<double> ¶meter_space ); + LIB4NEURO_API virtual double eval( std::vector<double> ¶meter_space ); /** * Performs partial derivative of this transfer function according to all parameters. Adds the values multiplied * by alpha to the corresponding gradient vector */ - virtual void eval_partial_derivative( std::vector<double> ¶meter_space, std::vector<double> &weight_gradient, double alpha ); + LIB4NEURO_API virtual void eval_partial_derivative( std::vector<double> ¶meter_space, std::vector<double> &weight_gradient, double alpha ); }; - #endif //INC_4NEURO_CONNECTIONWEIGHT_H diff --git a/src/NetConnection/ConnectionFunctionGeneralSerialization.h b/src/NetConnection/ConnectionFunctionGeneralSerialization.h new file mode 100644 index 0000000000000000000000000000000000000000..f1eba16dd9d23726c4c59881eb9c0181761c1e33 --- /dev/null +++ b/src/NetConnection/ConnectionFunctionGeneralSerialization.h @@ -0,0 +1,47 @@ +// +// Created by martin on 9/17/18. +// + +#ifndef LIB4NEURO_CONNECTIONFUNCTIONGENERALSERIALIZATION_H +#define LIB4NEURO_CONNECTIONFUNCTIONGENERALSERIALIZATION_H + +#include <boost/archive/text_oarchive.hpp> +#include <boost/archive/text_iarchive.hpp> +#include <boost/serialization/vector.hpp> +#include <boost/serialization/export.hpp> + +#include "ConnectionFunctionGeneral.h" + +BOOST_CLASS_EXPORT_KEY(ConnectionFunctionGeneral); + +struct ConnectionFunctionGeneral :: access { + template <class Archive> + static void serialize(Archive &ar, ConnectionFunctionGeneral& c, const unsigned int version) { + ar & c.param_indices; + } +}; + +template void ConnectionFunctionGeneral::access::serialize<boost::archive::text_oarchive>(boost::archive::text_oarchive&, ConnectionFunctionGeneral&, const unsigned int); + + +namespace boost { + namespace serialization { + + /** + * Serialization function + * @tparam Archive Boost library template + * @param ar Boost parameter - filled automatically during serialization! + * @param n ConnectionFunctionGeneral instance + * @param version Boost parameter - filled automatically during serialization! + */ + template<class Archive> + void serialize(Archive & ar, ConnectionFunctionGeneral& c, const unsigned int version) + { + ConnectionFunctionGeneral::access::serialize(ar, c, version); + } + + + } // namespace serialization +} // namespace boost + +#endif //LIB4NEURO_CONNECTIONFUNCTIONGENERALSERIALIZATION_H diff --git a/src/NetConnection/ConnectionFunctionIdentity.cpp b/src/NetConnection/ConnectionFunctionIdentity.cpp index bd535cbf94af0e1b019abc5c5dee4592d9c67c43..5446bd5177bf09c9a07971adefcfa9d4fce6c533 100644 --- a/src/NetConnection/ConnectionFunctionIdentity.cpp +++ b/src/NetConnection/ConnectionFunctionIdentity.cpp @@ -5,7 +5,13 @@ * @date 14.6.18 - */ +#include <boost/serialization/export.hpp> + #include "ConnectionFunctionIdentity.h" +#include "ConnectionFunctionIdentitySerialization.h" +#include "ConnectionFunctionGeneralSerialization.h" + +BOOST_CLASS_EXPORT_IMPLEMENT(ConnectionFunctionIdentity); ConnectionFunctionIdentity::ConnectionFunctionIdentity( ) { // this->type = CONNECTION_TYPE::IDENTITY; diff --git a/src/NetConnection/ConnectionFunctionIdentity.h b/src/NetConnection/ConnectionFunctionIdentity.h index 68150e207ab351cd0c8b2765c7de1659c764f6a2..8a01ad51f8abbf8770cfc1a7bc612a8bf7e5513c 100644 --- a/src/NetConnection/ConnectionFunctionIdentity.h +++ b/src/NetConnection/ConnectionFunctionIdentity.h @@ -8,16 +8,17 @@ #ifndef INC_4NEURO_CONNECTIONWEIGHTIDENTITY_H #define INC_4NEURO_CONNECTIONWEIGHTIDENTITY_H +#include "../settings.h" #include "ConnectionFunctionGeneral.h" -class ConnectionFunctionGeneral; +//class ConnectionFunctionGeneral; /** * */ -class ConnectionFunctionIdentity:public ConnectionFunctionGeneral { - friend class boost::serialization::access; - friend class NeuralNetwork; +class ConnectionFunctionIdentity : public ConnectionFunctionGeneral { +// friend class boost::serialization::access; +// friend class NeuralNetwork; private: @@ -25,38 +26,40 @@ private: bool is_unitary = false; -protected: - template<class Archive> - void serialize(Archive & ar, const unsigned int version){ - ar & boost::serialization::base_object<ConnectionFunctionGeneral>(*this); - ar & this->param_idx; - ar & this->is_unitary; - }; +//protected: +// template<class Archive> +// void serialize(Archive & ar, const unsigned int version){ +// ar & boost::serialization::base_object<ConnectionFunctionGeneral>(*this); +// ar & this->param_idx; +// ar & this->is_unitary; +// }; public: + struct access; + /** * */ - ConnectionFunctionIdentity( ); + LIB4NEURO_API ConnectionFunctionIdentity( ); /** * */ - ConnectionFunctionIdentity( size_t pidx ); + LIB4NEURO_API ConnectionFunctionIdentity( size_t pidx ); /** * * @return */ - double eval( std::vector<double> ¶meter_space ) override; + LIB4NEURO_API double eval( std::vector<double> ¶meter_space ) override; /** * * @param weight_gradient * @param alpha */ - void eval_partial_derivative(std::vector<double> ¶meter_space, std::vector<double> &weight_gradient, double alpha) override; + LIB4NEURO_API void eval_partial_derivative(std::vector<double> ¶meter_space, std::vector<double> &weight_gradient, double alpha) override; }; diff --git a/src/NetConnection/ConnectionFunctionIdentitySerialization.h b/src/NetConnection/ConnectionFunctionIdentitySerialization.h new file mode 100644 index 0000000000000000000000000000000000000000..767f2be0349fb23c88c3ba22f5a9ae29ae570ea4 --- /dev/null +++ b/src/NetConnection/ConnectionFunctionIdentitySerialization.h @@ -0,0 +1,46 @@ +// +// Created by martin on 9/17/18. +// + +#ifndef LIB4NEURO_CONNECTIONFUNCTIONIDENTITYSERIALIZATION_H +#define LIB4NEURO_CONNECTIONFUNCTIONIDENTITYSERIALIZATION_H + +#include <boost/serialization/base_object.hpp> +#include <boost/archive/text_oarchive.hpp> +#include <boost/archive/text_iarchive.hpp> +#include <boost/serialization/export.hpp> + +#include "ConnectionFunctionIdentity.h" +#include "ConnectionFunctionGeneralSerialization.h" + +BOOST_CLASS_EXPORT_KEY(ConnectionFunctionIdentity); + +struct ConnectionFunctionIdentity :: access { + template <class Archive> + static void serialize(Archive &ar, ConnectionFunctionIdentity& c, const unsigned int version) { + ar & boost::serialization::base_object<ConnectionFunctionGeneral>(c); + ar & c.is_unitary; + ar & c.param_idx; + } +}; + +namespace boost { + namespace serialization { + + /** + * Serialization function + * @tparam Archive Boost library template + * @param ar Boost parameter - filled automatically during serialization! + * @param n ConnectionFunctionIdentity instance + * @param version Boost parameter - filled automatically during serialization! + */ + template<class Archive> + void serialize(Archive & ar, ConnectionFunctionIdentity& c, const unsigned int version) + { + ConnectionFunctionIdentity::access::serialize(ar, c, version); + } + + } // namespace serialization +} // namespace boost + +#endif //LIB4NEURO_CONNECTIONFUNCTIONIDENTITYSERIALIZATION_H diff --git a/src/Network/NeuralNetwork.cpp b/src/Network/NeuralNetwork.cpp index 027b4380a69b0c51b323461b18b4f2ff02b2bb80..30ac79479b85492a019fc1d7e456e60318252f91 100644 --- a/src/Network/NeuralNetwork.cpp +++ b/src/Network/NeuralNetwork.cpp @@ -6,15 +6,7 @@ */ #include "NeuralNetwork.h" - -BOOST_CLASS_EXPORT(NeuronBinary); -BOOST_CLASS_EXPORT(NeuronConstant); -BOOST_CLASS_EXPORT(NeuronLinear); -BOOST_CLASS_EXPORT(NeuronLogistic); -BOOST_CLASS_EXPORT(NeuronLogistic_d1); -BOOST_CLASS_EXPORT(NeuronLogistic_d2); -BOOST_CLASS_EXPORT(ConnectionFunctionGeneral); -BOOST_CLASS_EXPORT(ConnectionFunctionIdentity); +#include "NeuralNetworkSerialization.h" NeuralNetwork::NeuralNetwork() { this->neurons = new std::vector<Neuron*>(0); diff --git a/src/Network/NeuralNetwork.h b/src/Network/NeuralNetwork.h index 09aefbb3aada4de96bc3b31dec7a91523fba04a5..d2483b206dd3d88656110e823021f0b1bc665f5d 100644 --- a/src/Network/NeuralNetwork.h +++ b/src/Network/NeuralNetwork.h @@ -11,37 +11,24 @@ #ifndef INC_4NEURO_NEURALNETWORK_H #define INC_4NEURO_NEURALNETWORK_H - - #include <iostream> #include <vector> + #include <algorithm> #include <utility> #include <fstream> -#include <boost/random/mersenne_twister.hpp> -#include <boost/random/uniform_real_distribution.hpp> - -#include <boost/archive/text_oarchive.hpp> -#include <boost/archive/text_iarchive.hpp> -#include <boost/serialization/list.hpp> -#include <boost/serialization/string.hpp> -#include <boost/serialization/version.hpp> -#include <boost/serialization/split_member.hpp> -#include <boost/serialization/export.hpp> -#include <boost/serialization/vector.hpp> -#include <boost/serialization/utility.hpp> - +#include "../settings.h" #include "../Neuron/Neuron.h" #include "../Neuron/NeuronConstant.h" #include "../Neuron/NeuronBinary.h" #include "../Neuron/NeuronLinear.h" #include "../Neuron/NeuronLogistic.h" + #include "../NetConnection/ConnectionFunctionGeneral.h" #include "../NetConnection/ConnectionFunctionIdentity.h" - enum class BIAS_TYPE{NEXT_BIAS, NO_BIAS, EXISTING_BIAS}; enum class SIMPLE_CONNECTION_TYPE{NEXT_WEIGHT, UNITARY_WEIGHT, EXISTING_WEIGHT}; @@ -52,7 +39,6 @@ enum class SIMPLE_CONNECTION_TYPE{NEXT_WEIGHT, UNITARY_WEIGHT, EXISTING_WEIGHT}; */ class NeuralNetwork { private: - friend class boost::serialization::access; /** * @@ -158,41 +144,28 @@ private: */ void analyze_layer_structure( ); - template<class Archive> - void serialize(Archive & ar, const unsigned int version) { - ar & this->neurons; - ar & this->input_neuron_indices; - ar & this->output_neuron_indices; - ar & this->connection_list; - ar & this->neuron_biases; - ar & this-> neuron_bias_indices; - ar & this->neuron_potentials; - ar & this->connection_weights; - ar & this->inward_adjacency; - ar & this->outward_adjacency; - ar & this->neuron_layers_feedforward; - ar & this->neuron_layers_feedbackward; - ar & this->layers_analyzed; - ar & this->delete_weights; - ar & this->delete_biases; - }; - public: + /** + * Struct used to access private properties from + * the serialization function + */ + struct access; + /** * */ - explicit NeuralNetwork(); + LIB4NEURO_API explicit NeuralNetwork(); /** * */ - explicit NeuralNetwork(std::string filepath); + LIB4NEURO_API explicit NeuralNetwork(std::string filepath); /** * */ - virtual ~NeuralNetwork(); + LIB4NEURO_API virtual ~NeuralNetwork(); /** * If possible, returns a neural net with 'input_neuron_indices' neurons as inputs and 'output_neuron_indices' as @@ -202,20 +175,20 @@ public: * @param output_neuron_indices * @return */ - NeuralNetwork* get_subnet(std::vector<size_t> &input_neuron_indices, std::vector<size_t> &output_neuron_indices); + LIB4NEURO_API NeuralNetwork* get_subnet(std::vector<size_t> &input_neuron_indices, std::vector<size_t> &output_neuron_indices); /** * Replaces the values in @{this->connection_weights} and @{this->neuron_biases} by the provided values * @param parameters */ - virtual void copy_parameter_space(std::vector<double> *parameters); + LIB4NEURO_API virtual void copy_parameter_space(std::vector<double> *parameters); /** * Copies the pointers @{this->connection_weights} and @{this->neuron_biases} from the parental network, sets * flags to not delete the vectors in this object * @param parent_network */ - virtual void set_parameter_space_pointers( NeuralNetwork &parent_network ); + LIB4NEURO_API virtual void set_parameter_space_pointers( NeuralNetwork &parent_network ); /** * @@ -223,7 +196,7 @@ public: * @param output * @param custom_weights_and_biases */ - virtual void eval_single(std::vector<double> &input, std::vector<double> &output, std::vector<double> *custom_weights_and_biases = nullptr); + LIB4NEURO_API virtual void eval_single(std::vector<double> &input, std::vector<double> &output, std::vector<double> *custom_weights_and_biases = nullptr); @@ -232,14 +205,14 @@ public: * @param error_derivative * @param gradient */ - virtual void add_to_gradient_single( std::vector<double> &input, std::vector<double> &error_derivative, double error_scaling, std::vector<double> &gradient); + LIB4NEURO_API virtual void add_to_gradient_single( std::vector<double> &input, std::vector<double> &error_derivative, double error_scaling, std::vector<double> &gradient); /** * Adds a new neuron to the list of neurons. Also assigns a valid bias value to its activation function * @param[in] n * @return */ - size_t add_neuron(Neuron* n, BIAS_TYPE bt = BIAS_TYPE::NEXT_BIAS, size_t bias_idx = 0); + LIB4NEURO_API size_t add_neuron(Neuron* n, BIAS_TYPE bt = BIAS_TYPE::NEXT_BIAS, size_t bias_idx = 0); /** * @@ -247,7 +220,7 @@ public: * @param n2_idx * @return */ - size_t add_connection_simple(size_t n1_idx, size_t n2_idx, SIMPLE_CONNECTION_TYPE sct = SIMPLE_CONNECTION_TYPE::NEXT_WEIGHT, size_t weight_idx = 0 ); + LIB4NEURO_API size_t add_connection_simple(size_t n1_idx, size_t n2_idx, SIMPLE_CONNECTION_TYPE sct = SIMPLE_CONNECTION_TYPE::NEXT_WEIGHT, size_t weight_idx = 0 ); /** * Take the existing connection with index 'connection_idx' in 'parent_network' and adds it to the structure of this @@ -257,8 +230,7 @@ public: * @param connection_idx * @param parent_network */ - void add_existing_connection(size_t n1_idx, size_t n2_idx, size_t connection_idx, NeuralNetwork &parent_network ); - + LIB4NEURO_API void add_existing_connection(size_t n1_idx, size_t n2_idx, size_t connection_idx, NeuralNetwork &parent_network ); /** * @@ -268,88 +240,88 @@ public: /** * */ - void randomize_biases(); + LIB4NEURO_API void randomize_weights(); - /** - * - */ - void randomize_parameters(); + /** + * + */ + LIB4NEURO_API void randomize_biases(); /** * * @return */ - virtual size_t get_n_inputs(); + LIB4NEURO_API virtual size_t get_n_inputs(); /** * * @return */ - virtual size_t get_n_outputs(); + LIB4NEURO_API virtual size_t get_n_outputs(); /** * * @return */ - virtual size_t get_n_weights(); + LIB4NEURO_API virtual size_t get_n_weights(); /** * * @return */ - virtual size_t get_n_biases(); + LIB4NEURO_API virtual size_t get_n_biases(); /** * * @return */ - virtual int get_neuron_bias_index( size_t neuron_idx ); + LIB4NEURO_API virtual int get_neuron_bias_index( size_t neuron_idx ); /** * * @return */ - virtual size_t get_n_neurons(); + LIB4NEURO_API virtual size_t get_n_neurons(); /** * * @param input_neurons_indices */ - void specify_input_neurons(std::vector<size_t> &input_neurons_indices); + LIB4NEURO_API void specify_input_neurons(std::vector<size_t> &input_neurons_indices); /** * * @param output_neurons_indices */ - void specify_output_neurons(std::vector<size_t> &output_neurons_indices); + LIB4NEURO_API void specify_output_neurons(std::vector<size_t> &output_neurons_indices); /** * */ - void print_weights(); + LIB4NEURO_API void print_weights(); /** * */ - void print_stats(); + LIB4NEURO_API void print_stats(); /** * * @return */ - virtual std::vector<double>* get_parameter_ptr_weights(); + LIB4NEURO_API std::vector<double>* get_parameter_ptr_weights(); /** * * @return */ - virtual std::vector<double>* get_parameter_ptr_biases(); + LIB4NEURO_API std::vector<double>* get_parameter_ptr_biases(); /** * * @param filepath */ - void save_text(std::string filepath); + LIB4NEURO_API void save_text(std::string filepath); }; diff --git a/src/Network/NeuralNetworkSerialization.h b/src/Network/NeuralNetworkSerialization.h new file mode 100644 index 0000000000000000000000000000000000000000..301ab3810c80f356dc8b78c18912449294902723 --- /dev/null +++ b/src/Network/NeuralNetworkSerialization.h @@ -0,0 +1,67 @@ +// +// Created by martin on 9/17/18. +// + +#ifndef LIB4NEURO_NEURALNETWORKSERIALIZATION_H +#define LIB4NEURO_NEURALNETWORKSERIALIZATION_H + +#include <boost/random/mersenne_twister.hpp> +#include <boost/random/uniform_real_distribution.hpp> +#include <boost/archive/text_oarchive.hpp> +#include <boost/archive/text_iarchive.hpp> +#include <boost/serialization/list.hpp> +#include <boost/serialization/string.hpp> +#include <boost/serialization/export.hpp> +#include <boost/serialization/vector.hpp> +#include <boost/serialization/utility.hpp> + +#include "NeuralNetwork.h" +#include "Neuron/NeuronSerialization.h" +#include "Neuron/NeuronBinarySerialization.h" +#include "Neuron/NeuronConstantSerialization.h" +#include "Neuron/NeuronLinearSerialization.h" +#include "Neuron/NeuronLogisticSerialization.h" +#include "NetConnection/ConnectionFunctionGeneralSerialization.h" +#include "NetConnection/ConnectionFunctionIdentitySerialization.h" + +struct NeuralNetwork :: access { + template <class Archive> + static void serialize(Archive &ar, NeuralNetwork& nn, const unsigned int version) { + ar & nn.neurons; + ar & nn.input_neuron_indices; + ar & nn.output_neuron_indices; + ar & nn.connection_list; + ar & nn.neuron_biases; + ar & nn.neuron_bias_indices; + ar & nn.neuron_potentials; + ar & nn.connection_weights; + ar & nn.inward_adjacency; + ar & nn.outward_adjacency; + ar & nn.neuron_layers_feedforward; + ar & nn.neuron_layers_feedbackward; + ar & nn.layers_analyzed; + ar & nn.delete_weights; + ar & nn.delete_biases; + } +}; + +namespace boost { + namespace serialization { + + /** + * Serialization function + * @tparam Archive Boost library template + * @param ar Boost parameter - filled automatically during serialization! + * @param ds NeuralNetwork instance + * @param version Boost parameter - filled automatically during serialization! + */ + template<class Archive> + void serialize(Archive & ar, NeuralNetwork & nn, const unsigned int version) + { + NeuralNetwork::access::serialize(ar, nn, version); + } + + } // namespace serialization +} // namespace boost + +#endif //LIB4NEURO_NEURALNETWORKSERIALIZATION_H diff --git a/src/Network/NeuralNetworkSum.cpp b/src/Network/NeuralNetworkSum.cpp index b0cfc1ccec1eae545230da5ed0ced4873cba381f..8a9907adddb3a429d5c06c0e4fcae1e5c8b0614a 100644 --- a/src/Network/NeuralNetworkSum.cpp +++ b/src/Network/NeuralNetworkSum.cpp @@ -5,7 +5,13 @@ * @date 18.7.18 - */ +#include <boost/serialization/export.hpp> + #include "NeuralNetworkSum.h" +#include "NeuralNetworkSumSerialization.h" +#include "General/ExprtkWrapperSerialization.h" + +BOOST_CLASS_EXPORT_IMPLEMENT(NeuralNetworkSum); NeuralNetworkSum::NeuralNetworkSum(){ this->summand = nullptr; diff --git a/src/Network/NeuralNetworkSum.h b/src/Network/NeuralNetworkSum.h index 8ce7dcd6ecab44d62517c4cb09040e333a106405..c48056991093c78628b012dcf4c246b6212ac601 100644 --- a/src/Network/NeuralNetworkSum.h +++ b/src/Network/NeuralNetworkSum.h @@ -8,84 +8,78 @@ #ifndef INC_4NEURO_NEURALNETWORKSUM_H #define INC_4NEURO_NEURALNETWORKSUM_H - +#include "../settings.h" +#include "../General/ExprtkWrapper.h" #include "NeuralNetwork.h" -#include "../General/ExprtkWrapper.h" - class NeuralNetworkSum : public NeuralNetwork { private: - friend class boost::serialization::access; - std::vector<NeuralNetwork*> * summand; std::vector<ExprtkWrapper*> * summand_coefficient; - template <class Archive> - void serialize(Archive & ar, const unsigned int version) { - ar & boost::serialization::base_object<NeuralNetwork>(*this); - ar & this->summand; - ar & this->summand_coefficient; - }; public: - NeuralNetworkSum( ); - virtual ~NeuralNetworkSum( ); + /** + * Struct used to access private properties from + * the serialization function + */ + struct access; - void add_network( NeuralNetwork *net, std::string expression_string ); + LIB4NEURO_API NeuralNetworkSum( ); + LIB4NEURO_API virtual ~NeuralNetworkSum( ); - void eval_single(std::vector<double> &input, std::vector<double> &output, std::vector<double> *custom_weights_and_biases) override; + LIB4NEURO_API void add_network( NeuralNetwork *net, std::string expression_string ); /** * * @param error_derivative * @param gradient */ - void add_to_gradient_single( std::vector<double> &input, std::vector<double> &error_derivative, double error_scaling, std::vector<double> &gradient) override; + LIB4NEURO_API void add_to_gradient_single( std::vector<double> &input, std::vector<double> &error_derivative, double error_scaling, std::vector<double> &gradient) override; /** * * @return */ - size_t get_n_inputs() override; + LIB4NEURO_API virtual size_t get_n_inputs() override; /** * * @return */ - size_t get_n_outputs() override; + LIB4NEURO_API virtual size_t get_n_outputs() override; /** * * @return */ - size_t get_n_weights() override; + LIB4NEURO_API virtual size_t get_n_weights() override; /** * * @return */ - size_t get_n_biases() override; + LIB4NEURO_API virtual size_t get_n_biases() override; /** * * @return */ - size_t get_n_neurons() override; - + LIB4NEURO_API virtual size_t get_n_neurons() override; /** * * @return */ //TODO only works if all the networks share the same parameters - std::vector<double>* get_parameter_ptr_weights() override; + LIB4NEURO_API virtual std::vector<double>* get_parameter_ptr_weights() override; /** * * @return */ //TODO only works if all the networks share the same parameters - std::vector<double>* get_parameter_ptr_biases() override; + LIB4NEURO_API std::vector<double>* get_parameter_ptr_biases() override; }; diff --git a/src/Network/NeuralNetworkSumSerialization.h b/src/Network/NeuralNetworkSumSerialization.h new file mode 100644 index 0000000000000000000000000000000000000000..9b8aab0807107837194c7e6c14d5c51ef8a029e3 --- /dev/null +++ b/src/Network/NeuralNetworkSumSerialization.h @@ -0,0 +1,46 @@ +// +// Created by martin on 9/17/18. +// + +#ifndef LIB4NEURO_NEURALNETWORKSUMSERIALIZATION_H +#define LIB4NEURO_NEURALNETWORKSUMSERIALIZATION_H + +#include <boost/serialization/base_object.hpp> +#include <boost/serialization/export.hpp> +#include <boost/archive/text_oarchive.hpp> +#include <boost/archive/text_iarchive.hpp> + +#include "NeuralNetworkSum.h" +#include "NeuralNetworkSerialization.h" + +BOOST_CLASS_EXPORT_KEY(NeuralNetworkSum); + +struct NeuralNetworkSum :: access { + template <class Archive> + static void serialize(Archive &ar, NeuralNetworkSum& n, const unsigned int version) { + ar & boost::serialization::base_object<NeuralNetwork>(n); + ar & n.summand; + ar & n.summand_coefficient; + } +}; + +namespace boost { + namespace serialization { + + /** + * Serialization function + * @tparam Archive Boost library template + * @param ar Boost parameter - filled automatically during serialization! + * @param n NeuralNetworkSum instance + * @param version Boost parameter - filled automatically during serialization! + */ + template<class Archive> + void serialize(Archive & ar, NeuralNetworkSum& n, const unsigned int version) + { + NeuralNetworkSum::access::serialize(ar, n, version); + } + + } // namespace serialization +} // namespace boost + +#endif //LIB4NEURO_NEURALNETWORKSUMSERIALIZATION_H diff --git a/src/Neuron/Neuron.cpp b/src/Neuron/Neuron.cpp index 15664cd953bd38f298d22f194d554b0eff82086c..dc4c4a3844e9fc5c6703deabe17cbe993eb024ca 100644 --- a/src/Neuron/Neuron.cpp +++ b/src/Neuron/Neuron.cpp @@ -1,5 +1,7 @@ +#include "NeuronSerialization.h" + +BOOST_CLASS_EXPORT_IMPLEMENT(Neuron); -#include "Neuron.h" Neuron::~Neuron() { diff --git a/src/Neuron/Neuron.h b/src/Neuron/Neuron.h index 378d013d40b1a5cb4c21da0b6f9fee7afab4de43..f1b7d2cc99c7cf9d89d413948f8866a7b6206640 100644 --- a/src/Neuron/Neuron.h +++ b/src/Neuron/Neuron.h @@ -10,36 +10,34 @@ #ifndef NEURON_H_ #define NEURON_H_ - - -#include <boost/serialization/base_object.hpp> +#include "../settings.h" #include <vector> -class IDifferentiable; /** * Abstract class representing a general neuron */ class Neuron { -private: - friend class boost::serialization::access; - - template<class Archive> - void serialize(Archive & ar, const unsigned int version){}; public: + /** + * Struct used to access private properties from + * the serialization function + */ + struct access; + /** * Destructor of the Neuron object * this level deallocates the array 'activation_function_parameters' * also deallocates the OUTGOING connections */ - virtual ~Neuron(); + LIB4NEURO_API virtual ~Neuron(); /** * Performs the activation function and returns the result */ - virtual double activate( double x, double b ) = 0; + LIB4NEURO_API virtual double activate( double x, double b ) = 0; }; /* end of Neuron class */ diff --git a/src/Neuron/NeuronBinary.cpp b/src/Neuron/NeuronBinary.cpp index 48ada48fc2b562e90abccad7941a7ceee13db712..b53c9462c5f7bde13b3a3802195ee19a2f807ec4 100644 --- a/src/Neuron/NeuronBinary.cpp +++ b/src/Neuron/NeuronBinary.cpp @@ -2,7 +2,12 @@ // Created by fluffymoo on 11.6.18. // -#include "NeuronBinary.h" +#include <boost/serialization/export.hpp> + +#include "NeuronSerialization.h" +#include "NeuronBinarySerialization.h" + +BOOST_CLASS_EXPORT_IMPLEMENT(NeuronBinary); NeuronBinary::NeuronBinary( ) {} diff --git a/src/Neuron/NeuronBinary.h b/src/Neuron/NeuronBinary.h index 8cdb0afd3e03e9ce47d65033fbfe63e5d5e4984e..ae52d75aab5fb5bcbbbdef349b6c316fcb02f777 100644 --- a/src/Neuron/NeuronBinary.h +++ b/src/Neuron/NeuronBinary.h @@ -10,7 +10,7 @@ #ifndef INC_4NEURO_NEURONBINARY_H #define INC_4NEURO_NEURONBINARY_H - +//#include "../settings.h" #include "Neuron.h" @@ -18,27 +18,26 @@ * Binary neuron class - uses unit-step as the activation function */ class NeuronBinary:public Neuron { -private: - friend class boost::serialization::access; - - template<class Archive> - void serialize(Archive & ar, const unsigned int version){ - ar & boost::serialization::base_object<Neuron>(*this); - }; public: + /** + * Struct used to access private properties from + * the serialization function + */ + struct access; + /** * Default constructor for the binary Neuron * @param[in] threshold Denotes when the neuron is activated * When neuron potential exceeds 'threshold' value it becomes excited */ - explicit NeuronBinary( ); + LIB4NEURO_API explicit NeuronBinary( ); /** * Performs the activation function and stores the result into the 'state' property */ - double activate( double x, double b ) override; + LIB4NEURO_API double activate( double x, double b ) override; }; diff --git a/src/Neuron/NeuronBinarySerialization.h b/src/Neuron/NeuronBinarySerialization.h new file mode 100644 index 0000000000000000000000000000000000000000..e227c45d8c7c5e8c02c9366b43deda12d34e5c78 --- /dev/null +++ b/src/Neuron/NeuronBinarySerialization.h @@ -0,0 +1,45 @@ +// +// Created by martin on 9/17/18. +// + +#ifndef LIB4NEURO_NEURON_BINARY_SERIALIZATION_H +#define LIB4NEURO_NEURON_BINARY_SERIALIZATION_H + +#include <boost/serialization/base_object.hpp> +#include <boost/archive/text_oarchive.hpp> +#include <boost/archive/text_iarchive.hpp> +#include <boost/serialization/export.hpp> + +#include "NeuronSerialization.h" +#include "NeuronBinary.h" + +BOOST_CLASS_EXPORT_KEY(NeuronBinary); + +struct NeuronBinary :: access { + template <class Archive> + static void serialize(Archive &ar, NeuronBinary& n, const unsigned int version) { + ar & boost::serialization::base_object<Neuron>(n); + } +}; + +namespace boost { + namespace serialization { + + /** + * Serialization function + * @tparam Archive Boost library template + * @param ar Boost parameter - filled automatically during serialization! + * @param n NeuronBinary instance + * @param version Boost parameter - filled automatically during serialization! + */ + template<class Archive> + void serialize(Archive & ar, NeuronBinary& n, const unsigned int version) + { + NeuronBinary::access::serialize(ar, n, version); + } + + } // namespace serialization +} // namespace boost + + +#endif //LIB4NEURO_NEURON_BINARY_SERIALIZATION_H diff --git a/src/Neuron/NeuronConstant.cpp b/src/Neuron/NeuronConstant.cpp index 1b349c2f913dfe1ea3c09dcf5765fe28254cd555..bc04b60dfe2461494097de6cb8a4961eb0cd4e23 100644 --- a/src/Neuron/NeuronConstant.cpp +++ b/src/Neuron/NeuronConstant.cpp @@ -5,7 +5,14 @@ * @date 8.8.18 - */ -#include "NeuronConstant.h" +#include <boost/serialization/export.hpp> + +//#include "NeuronConstant.h" +//#include "NeuronSerialization.h" +#include "NeuronConstantSerialization.h" + + +BOOST_CLASS_EXPORT_IMPLEMENT(NeuronConstant); NeuronConstant::NeuronConstant( double c ) { this->p = c; @@ -26,4 +33,5 @@ double NeuronConstant::activation_function_eval_derivative( double x, double b ) Neuron* NeuronConstant::get_derivative() { NeuronConstant* output = new NeuronConstant( ); return output; -} \ No newline at end of file +} + diff --git a/src/Neuron/NeuronConstant.h b/src/Neuron/NeuronConstant.h index 0c648263f57e002a07e87c1c7668c465dc182557..92af947cbbb45d034c54c5279511e1d92f66bc11 100644 --- a/src/Neuron/NeuronConstant.h +++ b/src/Neuron/NeuronConstant.h @@ -11,33 +11,31 @@ #include "Neuron.h" +//#include "NeuronSerialization.h" class NeuronConstant: public NeuronDifferentiable { private: - friend class boost::serialization::access; - double p = 0.0; - template<class Archive> - void serialize(Archive & ar, const unsigned int version){ - ar & boost::serialization::base_object<Neuron>(*this); - - ar & this->p; - }; - public: + /** + * Struct used to access private properties from + * the serialization function + */ + struct access; + /** * Constructs the object of the Linear neuron with activation function * f(x) = c * @param[in] c Constant value */ - explicit NeuronConstant( double c = 0.0 ); + LIB4NEURO_API explicit NeuronConstant( double c = 0.0 ); /** * Evaluates and returns 'c' */ - double activate( double x, double b ) override; + LIB4NEURO_API double activate( double x, double b ) override; /** * Calculates the partial derivative of the activation function @@ -45,19 +43,19 @@ public: * @return Partial derivative of the activation function according to the * 'bias' parameter. Returns 0.0 */ - double activation_function_eval_derivative_bias( double x, double b ) override; + LIB4NEURO_API double activation_function_eval_derivative_bias( double x, double b ) override; /** * Calculates d/dx of (c) at point x * @return 0.0 */ - double activation_function_eval_derivative( double x, double b ) override; + LIB4NEURO_API double activation_function_eval_derivative( double x, double b ) override; /** * Returns a pointer to a Neuron with derivative as its activation function * @return */ - Neuron* get_derivative( ) override; + LIB4NEURO_API Neuron* get_derivative( ) override; }; #endif //INC_4NEURO_NEURONCONSTANT_H diff --git a/src/Neuron/NeuronConstantSerialization.h b/src/Neuron/NeuronConstantSerialization.h new file mode 100644 index 0000000000000000000000000000000000000000..2fd8ef406a8ac0ee6703c05accc3953c24d357d4 --- /dev/null +++ b/src/Neuron/NeuronConstantSerialization.h @@ -0,0 +1,47 @@ +// +// Created by martin on 9/17/18. +// + +#ifndef LIB4NEURO_NEURON_CONSTANT_SERIALIZATION_H +#define LIB4NEURO_NEURON_CONSTANT_SERIALIZATION_H + +#include <boost/serialization/base_object.hpp> +#include <boost/archive/text_oarchive.hpp> +#include <boost/archive/text_iarchive.hpp> +#include <boost/serialization/export.hpp> + +#include "NeuronConstant.h" +#include "NeuronSerialization.h" + +BOOST_CLASS_EXPORT_KEY(NeuronConstant); + +struct NeuronConstant :: access { + template <class Archive> + static void serialize(Archive &ar, NeuronConstant& n, const unsigned int version) { + ar & boost::serialization::base_object<Neuron>(n); + ar & n.p; + } +}; + +namespace boost { + namespace serialization { + + /** + * Serialization function + * @tparam Archive Boost library template + * @param ar Boost parameter - filled automatically during serialization! + * @param n NeuronConstant instance + * @param version Boost parameter - filled automatically during serialization! + */ + template<class Archive> + void serialize(Archive & ar, NeuronConstant& n, const unsigned int version) + { + NeuronConstant::access::serialize(ar, n, version); + } + + } // namespace serialization +} // namespace boost + + + +#endif //LIB4NEURO_NEURON_SERIALIZATION_H diff --git a/src/Neuron/NeuronLinear.cpp b/src/Neuron/NeuronLinear.cpp index afb73c6ac102d5b8e725cbceac2c3c38075cc887..395b7e08dcac3735c8b315eed6bc1e6c930b0089 100644 --- a/src/Neuron/NeuronLinear.cpp +++ b/src/Neuron/NeuronLinear.cpp @@ -2,8 +2,14 @@ // Created by fluffymoo on 11.6.18. // +#include <boost/serialization/export.hpp> + #include "NeuronLinear.h" +#include "NeuronConstant.h" +#include "NeuronSerialization.h" +#include "NeuronLinearSerialization.h" +BOOST_CLASS_EXPORT_IMPLEMENT(NeuronLinear); NeuronLinear::NeuronLinear( ) {} @@ -25,8 +31,3 @@ Neuron* NeuronLinear::get_derivative() { NeuronConstant* output = new NeuronConstant( 1.0 ); return output; } - -//template<class Archive> -//void NeuronLinear::serialize(Archive & ar, const unsigned int version) { -// ar & boost::serialization::base_object<Neuron>(*this); -//} diff --git a/src/Neuron/NeuronLinear.h b/src/Neuron/NeuronLinear.h index 4b2ef904a5ac874dcf95102d80b9f3aca2c46540..2ac50cce396d8523ef9ee85a02425ee7dd7c8332 100644 --- a/src/Neuron/NeuronLinear.h +++ b/src/Neuron/NeuronLinear.h @@ -11,36 +11,33 @@ #define INC_4NEURO_NEURONLINEAR_H #include "Neuron.h" -#include "NeuronConstant.h" -#include <boost/serialization/base_object.hpp> - +//#include "NeuronConstant.h" /** * Linear neuron class - uses activation function in the form f(x)=a*x + b, * 'x' being the neuron's potential */ class NeuronLinear:public NeuronDifferentiable { -private: - friend class boost::serialization::access; - - template<class Archive> - void serialize(Archive & ar, const unsigned int version){ - ar & boost::serialization::base_object<Neuron>(*this); - }; public: + /** + * Struct used to access private properties from + * the serialization function + */ + struct access; + /** * Constructs the object of the Linear neuron with activation function * f(x) = x + b * @param[in] b Bias */ - explicit NeuronLinear( ); + LIB4NEURO_API explicit NeuronLinear( ); /** * Evaluates 'x + b' and stores the result into the 'state' property */ - double activate( double x, double b ) override; + LIB4NEURO_API double activate( double x, double b ) override; /** * Calculates the partial derivative of the activation function @@ -48,19 +45,19 @@ public: * @return Partial derivative of the activation function according to the * 'bias' parameter. Returns 1.0 */ - double activation_function_eval_derivative_bias( double x, double b ) override; + LIB4NEURO_API double activation_function_eval_derivative_bias( double x, double b ) override; /** * Calculates d/dx of (x + b) at point x * @return 1.0 */ - double activation_function_eval_derivative( double x, double b ) override; + LIB4NEURO_API double activation_function_eval_derivative( double x, double b ) override; /** * Returns a pointer to a Neuron with derivative as its activation function * @return */ - Neuron* get_derivative( ) override; + LIB4NEURO_API Neuron* get_derivative( ) override; }; diff --git a/src/Neuron/NeuronLinearSerialization.h b/src/Neuron/NeuronLinearSerialization.h new file mode 100644 index 0000000000000000000000000000000000000000..fdbbff5c3ccb8554cdb3f27f2afb2b29971e943f --- /dev/null +++ b/src/Neuron/NeuronLinearSerialization.h @@ -0,0 +1,45 @@ +// +// Created by martin on 9/17/18. +// + +#ifndef LIB4NEURO_NEURONLINEARSERIALIZATION_H +#define LIB4NEURO_NEURONLINEARSERIALIZATION_H + +#include <boost/serialization/base_object.hpp> +#include <boost/archive/text_oarchive.hpp> +#include <boost/archive/text_iarchive.hpp> +#include <boost/serialization/export.hpp> + +#include "NeuronLinear.h" +#include "NeuronSerialization.h" + +BOOST_CLASS_EXPORT_KEY(NeuronLinear); + + +struct NeuronLinear :: access { + template <class Archive> + static void serialize(Archive &ar, NeuronLinear& n, const unsigned int version) { + ar & boost::serialization::base_object<Neuron>(n); + } +}; + +namespace boost { + namespace serialization { + + /** + * Serialization function + * @tparam Archive Boost library template + * @param ar Boost parameter - filled automatically during serialization! + * @param n NeuronLinear instance + * @param version Boost parameter - filled automatically during serialization! + */ + template<class Archive> + void serialize(Archive & ar, NeuronLinear& n, const unsigned int version) + { + NeuronLinear::access::serialize(ar, n, version); + } + + } // namespace serialization +} // namespace boost + +#endif //LIB4NEURO_NEURONLINEARSERIALIZATION_H diff --git a/src/Neuron/NeuronLogistic.cpp b/src/Neuron/NeuronLogistic.cpp index 6ca3f80006e07752dd6e85392f45941159b8c74d..4e52c629a17516d2a8865da3baeeffc482cdff24 100644 --- a/src/Neuron/NeuronLogistic.cpp +++ b/src/Neuron/NeuronLogistic.cpp @@ -2,8 +2,15 @@ // Created by fluffymoo on 11.6.18. // +#include <boost/serialization/export.hpp> #include "NeuronLogistic.h" +#include "NeuronSerialization.h" +#include "NeuronLogisticSerialization.h" + +BOOST_CLASS_EXPORT_IMPLEMENT(NeuronLogistic); +BOOST_CLASS_EXPORT_IMPLEMENT(NeuronLogistic_d1); +BOOST_CLASS_EXPORT_IMPLEMENT(NeuronLogistic_d2); NeuronLogistic_d2::NeuronLogistic_d2( ) {} diff --git a/src/Neuron/NeuronLogistic.h b/src/Neuron/NeuronLogistic.h index bd7361d7cf848e86334750ee563a9cf0115fa1f7..4b5f969bfbb5bf061e7740652be5ffd881296ffb 100644 --- a/src/Neuron/NeuronLogistic.h +++ b/src/Neuron/NeuronLogistic.h @@ -10,34 +10,32 @@ #ifndef INC_4NEURO_NEURONLOGISTIC_H #define INC_4NEURO_NEURONLOGISTIC_H - +#include "../settings.h" #include <cmath> -#include "Neuron.h" -#include "../constants.h" +#include "Neuron.h" class NeuronLogistic:public NeuronDifferentiable { - friend class boost::serialization::access; - -protected: - template<class Archive> - void serialize(Archive & ar, const unsigned int version){ - //TODO separate implementation to NeuronLogistic.cpp! - ar & boost::serialization::base_object<Neuron>(*this); - }; public: + + /** + * Struct used to access private properties from + * the serialization function + */ + struct access; + /** * Constructs the object of the Logistic neuron with activation function * f(x) = (1 + e^(-x + b))^(-1) */ - explicit NeuronLogistic( ); + LIB4NEURO_API explicit NeuronLogistic( ); /** * Evaluates '(1 + e^(-x + b))^(-1)' and stores the result into the 'state' property */ - virtual double activate( double x, double b ) override; + LIB4NEURO_API virtual double activate( double x, double b ) override; /** * Calculates the partial derivative of the activation function @@ -45,44 +43,42 @@ public: * @return Partial derivative of the activation function according to the * bias, returns: -e^(b - x)/(e^(b - x) + 1)^2 */ - virtual double activation_function_eval_derivative_bias( double x, double b ) override; + LIB4NEURO_API virtual double activation_function_eval_derivative_bias( double x, double b ) override; /** * Calculates d/dx of (1 + e^(-x + b))^(-1) * @return e^(b - x)/(e^(b - x) + 1)^2 */ - virtual double activation_function_eval_derivative( double x, double b ) override; + LIB4NEURO_API virtual double activation_function_eval_derivative( double x, double b ) override; /** * Returns a pointer to a Neuron with derivative as its activation function * @return */ - virtual NeuronLogistic* get_derivative( ) override; + LIB4NEURO_API virtual NeuronLogistic* get_derivative( ) override; }; class NeuronLogistic_d1:public NeuronLogistic { -private: - friend class boost::serialization::access; - - template<class Archive> - void serialize(Archive & ar, const unsigned int version){ - //TODO separate implementation to Neuronogistic_d1.cpp! - ar & boost::serialization::base_object<Neuron>(*this); - }; public: + /** + * Struct used to access private properties from + * the serialization function + */ + struct access; + /** * Constructs the object of the Logistic neuron with activation function * f(x) = e^(b - x)/(e^(b - x) + 1)^2 * @param[in] b Bias */ - explicit NeuronLogistic_d1( ); + LIB4NEURO_API explicit NeuronLogistic_d1( ); /** * Evaluates 'e^(b - x)/(e^(b - x) + 1)^2' and returns the result */ - virtual double activate( double x, double b ) override; + LIB4NEURO_API virtual double activate( double x, double b ) override; /** * Calculates the partial derivative of the activation function @@ -90,47 +86,42 @@ public: * @return Partial derivative of the activation function according to the * bias, returns: (e^(b + x) (e^x - e^b))/(e^b + e^x)^3 */ - virtual double activation_function_eval_derivative_bias( double x, double b ) override; + LIB4NEURO_API virtual double activation_function_eval_derivative_bias( double x, double b ) override; /** * Calculates d/dx of e^(b - x)*(1 + e^(b - x))^(-2) * @return (e^(b + x) (e^b - e^x))/(e^b + e^x)^3 */ - virtual double activation_function_eval_derivative( double x, double b ) override; + LIB4NEURO_API virtual double activation_function_eval_derivative( double x, double b ) override; /** * Returns a pointer to a Neuron with derivative as its activation function * @return */ - virtual NeuronLogistic* get_derivative( ) override; + LIB4NEURO_API virtual NeuronLogistic* get_derivative( ) override; }; - - - class NeuronLogistic_d2:public NeuronLogistic_d1 { -private: - friend class boost::serialization::access; - - template<class Archive> - void serialize(Archive & ar, const unsigned int version){ - //TODO separate implementation to NeuronLogistic_d1.cpp! - ar & boost::serialization::base_object<Neuron>(*this); - }; public: + /** + * Struct used to access private properties from + * the serialization function + */ + struct access; + /** * Constructs the object of the Logistic neuron with activation function * f(x) = (e^(b + x) (e^b - e^x))/(e^b + e^x)^3 */ - explicit NeuronLogistic_d2( ); + LIB4NEURO_API explicit NeuronLogistic_d2( ); /** * Evaluates '(e^(b + x) (e^b - e^x))/(e^b + e^x)^3' and returns the result */ - virtual double activate( double x, double b ) override; + LIB4NEURO_API virtual double activate( double x, double b ) override; /** * Calculates the partial derivative of the activation function @@ -138,19 +129,19 @@ public: * @return Partial derivative of the activation function according to the * bias, returns: -(e^(b + x) (-4 e^(b + x) + e^(2 b) + e^(2 x)))/(e^b + e^x)^4 */ - virtual double activation_function_eval_derivative_bias( double x, double b ) override; + LIB4NEURO_API virtual double activation_function_eval_derivative_bias( double x, double b ) override; /** * Calculates d/dx of (e^(b + x) (e^b - e^x))/(e^b + e^x)^3 * @return (e^(b + x) (-4 e^(b + x) + e^(2 b) + e^(2 x)))/(e^b + e^x)^4 */ - virtual double activation_function_eval_derivative( double x, double b ) override; + LIB4NEURO_API virtual double activation_function_eval_derivative( double x, double b ) override; /** * * @return */ - virtual NeuronLogistic* get_derivative( ) override; + LIB4NEURO_API virtual NeuronLogistic* get_derivative( ) override; }; diff --git a/src/Neuron/NeuronLogisticSerialization.h b/src/Neuron/NeuronLogisticSerialization.h new file mode 100644 index 0000000000000000000000000000000000000000..0ca37ce9afd31f9f7469c8e74a5738589858d8ec --- /dev/null +++ b/src/Neuron/NeuronLogisticSerialization.h @@ -0,0 +1,87 @@ +// +// Created by martin on 9/17/18. +// + +#ifndef LIB4NEURO_NEURONLOGISTICSERIALIZATION_H +#define LIB4NEURO_NEURONLOGISTICSERIALIZATION_H + +#include <boost/serialization/base_object.hpp> +#include <boost/archive/text_oarchive.hpp> +#include <boost/archive/text_iarchive.hpp> +#include <boost/serialization/export.hpp> + +#include "../constants.h" +#include "NeuronLogistic.h" +#include "NeuronSerialization.h" + +BOOST_CLASS_EXPORT_KEY(NeuronLogistic); +BOOST_CLASS_EXPORT_KEY(NeuronLogistic_d1); +BOOST_CLASS_EXPORT_KEY(NeuronLogistic_d2); + +struct NeuronLogistic :: access { + template <class Archive> + static void serialize(Archive &ar, NeuronLogistic& n, const unsigned int version) { + ar & boost::serialization::base_object<Neuron>(n); + } +}; + +struct NeuronLogistic_d1 :: access { + template <class Archive> + static void serialize(Archive &ar, NeuronLogistic_d1& n, const unsigned int version) { + ar & boost::serialization::base_object<NeuronLogistic>(n); + } +}; + +struct NeuronLogistic_d2 :: access { + template <class Archive> + static void serialize(Archive &ar, NeuronLogistic_d2& n, const unsigned int version) { + ar & boost::serialization::base_object<NeuronLogistic_d1>(n); + } +}; + +namespace boost { + namespace serialization { + + /** + * Serialization function + * @tparam Archive Boost library template + * @param ar Boost parameter - filled automatically during serialization! + * @param n NeuronLogistic instance + * @param version Boost parameter - filled automatically during serialization! + */ + template<class Archive> + void serialize(Archive & ar, NeuronLogistic& n, const unsigned int version) + { + NeuronLogistic::access::serialize(ar, n, version); + } + + /** + * Serialization function + * @tparam Archive Boost library template + * @param ar Boost parameter - filled automatically during serialization! + * @param n NeuronLogistic_d1 instance + * @param version Boost parameter - filled automatically during serialization! + */ + template<class Archive> + void serialize(Archive & ar, NeuronLogistic_d1& n, const unsigned int version) + { + NeuronLogistic_d1::access::serialize(ar, n, version); + } + + /** + * Serialization function + * @tparam Archive Boost library template + * @param ar Boost parameter - filled automatically during serialization! + * @param n NeuronLogistic_d2 instance + * @param version Boost parameter - filled automatically during serialization! + */ + template<class Archive> + void serialize(Archive & ar, NeuronLogistic_d2& n, const unsigned int version) + { + NeuronLogistic_d2::access::serialize(ar, n, version); + } + + } // namespace serialization +} // namespace boost + +#endif //LIB4NEURO_NEURONLOGISTICSERIALIZATION_H diff --git a/src/Neuron/NeuronSerialization.h b/src/Neuron/NeuronSerialization.h new file mode 100644 index 0000000000000000000000000000000000000000..13be0c148acf5358c02424922e61f7c68f00c429 --- /dev/null +++ b/src/Neuron/NeuronSerialization.h @@ -0,0 +1,43 @@ +// +// Created by martin on 9/17/18. +// + +#ifndef LIB4NEURO_NEURON_SERIALIZATION_H +#define LIB4NEURO_NEURON_SERIALIZATION_H + +#include <boost/archive/text_oarchive.hpp> +#include <boost/archive/text_iarchive.hpp> +#include <boost/serialization/assume_abstract.hpp> +#include <boost/serialization/export.hpp> + +#include "Neuron.h" + +BOOST_SERIALIZATION_ASSUME_ABSTRACT(Neuron); + +BOOST_CLASS_EXPORT_KEY(Neuron); + +struct Neuron :: access { + template <class Archive> + static void serialize(Archive &ar, Neuron& n, const unsigned int version) {} +}; + +namespace boost { + namespace serialization { + + /** + * Serialization function + * @tparam Archive Boost library template + * @param ar Boost parameter - filled automatically during serialization! + * @param n Neuron instance + * @param version Boost parameter - filled automatically during serialization! + */ + template<class Archive> + void serialize(Archive & ar, Neuron& n, const unsigned int version) + { + Neuron::access::serialize(ar, n, version); + } + + } // namespace serialization +} // namespace boost + +#endif //LIB4NEURO_NEURON_SERIALIZATION_H diff --git a/src/exceptions.h b/src/exceptions.h new file mode 100644 index 0000000000000000000000000000000000000000..0beaf7b4c0f70cf6b1d2b0dc322bce4ec61df1b3 --- /dev/null +++ b/src/exceptions.h @@ -0,0 +1,16 @@ +// +// Created by martin on 9/17/18. +// + +#ifndef LIB4NEURO_EXCEPTIONS_H +#define LIB4NEURO_EXCEPTIONS_H + +//TODO implement NotImplementedException according to C++17 +//class NotImplementedException : public std::logic_error { +//public: +// const char* what() { +// return "Function not yet implemented!"; +// } +//}; + +#endif //LIB4NEURO_EXCEPTIONS_H diff --git a/src/message.h b/src/message.h index 476e0b24e01c5b562bdac18017456bb6b68f6975..b04fccb24f4abdbdb320d66f0fc735e53e0bff0c 100644 --- a/src/message.h +++ b/src/message.h @@ -5,18 +5,9 @@ #ifndef PROJECT_MESSAGE_H #define PROJECT_MESSAGE_H -#include <iostream> +#include <cassert> -#define MSG_INFO(str) {\ - std::cout << "INFO: " << str << std::endl;\ -} - -#ifdef DEBUG -#define MSG_DEBUG(str) {\ - std::cout << "DEBUG: " << str << std::endl;\ -} -#else -#define MSG_DEBUG(str) -#endif +#define MSG_INFO(str) std::cout << "INFO: " << str << std::endl; +#define MSG_DEBUG(str) assert(std::cerr << "DEBUG:" << str << std::endl); #endif //PROJECT_MESSAGE_H diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index b3fe737e1d4e5cde3e5a13d0f534a1d4ab11249d..cd7d4ad4c8ab865dba0d047e6ead66b756e624bf 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -4,57 +4,70 @@ add_executable(linear_neuron_test NeuronLinear_test.cpp) target_link_libraries(linear_neuron_test lib4neuro boost_unit_test) +target_include_directories(linear_neuron_test PRIVATE ${Boost_INCLUDE_DIRS}) -#add_executable(constant_neuron_test NeuronConstant_test.cpp) -#target_link_libraries(constant_neuron_test lib4neuro boost_unit_test) +add_executable(constant_neuron_test NeuronConstant_test.cpp) +target_link_libraries(constant_neuron_test lib4neuro boost_unit_test) +target_include_directories(constant_neuron_test PRIVATE ${Boost_INCLUDE_DIRS}) -#add_executable(binary_neuron_test NeuronBinary_test.cpp) -#target_link_libraries(binary_neuron_test lib4neuro boost_unit_test) +add_executable(binary_neuron_test NeuronBinary_test.cpp) +target_link_libraries(binary_neuron_test lib4neuro boost_unit_test) +target_include_directories(binary_neuron_test PRIVATE ${Boost_INCLUDE_DIRS}) -#add_executable(logistic_neuron_test NeuronLogistic_test.cpp) -#target_link_libraries(logistic_neuron_test lib4neuro boost_unit_test) +add_executable(logistic_neuron_test NeuronLogistic_test.cpp) +target_link_libraries(logistic_neuron_test lib4neuro boost_unit_test) +target_include_directories(logistic_neuron_test PRIVATE ${Boost_INCLUDE_DIRS}) -#add_executable(connectionFunctionGeneral_test ConnectionFunctionGeneral_test.cpp) -#target_link_libraries(connectionFunctionGeneral_test lib4neuro boost_unit_test) +add_executable(connectionFunctionGeneral_test ConnectionFunctionGeneral_test.cpp) +target_link_libraries(connectionFunctionGeneral_test lib4neuro boost_unit_test) +target_include_directories(connectionFunctionGeneral_test PRIVATE ${Boost_INCLUDE_DIRS}) -#add_executable(neural_network_test NeuralNetwork_test.cpp) -#target_link_libraries(neural_network_test lib4neuro boost_unit_test) +add_executable(neural_network_test NeuralNetwork_test.cpp) +target_link_libraries(neural_network_test lib4neuro boost_unit_test) +target_include_directories(neural_network_test PRIVATE ${Boost_INCLUDE_DIRS}) -#add_executable(connection_Function_identity_test ConnectionFunctionIdentity_test.cpp) -#target_link_libraries(connection_Function_identity_test lib4neuro boost_unit_test) +add_executable(connection_Function_identity_test ConnectionFunctionIdentity_test.cpp) +target_link_libraries(connection_Function_identity_test lib4neuro boost_unit_test) +target_include_directories(connection_Function_identity_test PRIVATE ${Boost_INCLUDE_DIRS}) -#add_executable(dataset_test DataSet_test.cpp) -#target_link_libraries(dataset_test lib4neuro boost_unit_test) +add_executable(dataset_test DataSet_test.cpp) +target_link_libraries(dataset_test lib4neuro boost_unit_test) +target_include_directories(dataset_test PRIVATE ${Boost_INCLUDE_DIRS}) -#add_executable(errorfunction_test ErrorFunctions_test.cpp) -#target_link_libraries(errorfunction_test lib4neuro boost_unit_test) +add_executable(errorfunction_test ErrorFunctions_test.cpp) +target_link_libraries(errorfunction_test lib4neuro boost_unit_test) +target_include_directories(errorfunction_test PRIVATE ${Boost_INCLUDE_DIRS}) -#add_executable(particle_swarm_test ParticleSwarm_test.cpp) -#target_link_libraries(particle_swarm_test lib4neuro boost_unit_test) +add_executable(particle_swarm_test ParticleSwarm_test.cpp) +target_link_libraries(particle_swarm_test lib4neuro boost_unit_test) +target_include_directories(particle_swarm_test PRIVATE ${Boost_INCLUDE_DIRS}) -#add_executable(particle_test Particle_test.cpp) -#target_link_libraries(particle_test lib4neuro boost_unit_test) +add_executable(particle_test Particle_test.cpp) +target_link_libraries(particle_test lib4neuro boost_unit_test) +target_include_directories(particle_test PRIVATE ${Boost_INCLUDE_DIRS}) -#add_executable(NeuralNetworkSum_test NeuralNetworkSum_test.cpp) -#target_link_libraries(NeuralNetworkSum_test lib4neuro boost_unit_test) +add_executable(NeuralNetworkSum_test NeuralNetworkSum_test.cpp) +target_link_libraries(NeuralNetworkSum_test lib4neuro boost_unit_test) +target_include_directories(NeuralNetworkSum_test PRIVATE ${Boost_INCLUDE_DIRS}) -#add_executable(DESolver_test DESolver_test.cpp) -#target_link_libraries(DESolver_test lib4neuro boost_unit_test) +add_executable(DESolver_test DESolver_test.cpp) +target_link_libraries(DESolver_test lib4neuro boost_unit_test) +target_include_directories(DESolver_test PRIVATE ${Boost_INCLUDE_DIRS}) set_target_properties( linear_neuron_test - #constant_neuron_test - #binary_neuron_test - #logistic_neuron_test - #connectionFunctionGeneral_test - #connection_Function_identity_test - #neural_network_test - #dataset_test - #particle_swarm_test - #particle_test - #NeuralNetworkSum_test - #errorfunction_test - #DESolver_test + constant_neuron_test + binary_neuron_test + logistic_neuron_test + connectionFunctionGeneral_test + connection_Function_identity_test + neural_network_test + dataset_test + particle_swarm_test + particle_test + NeuralNetworkSum_test + errorfunction_test + DESolver_test PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib"