...
 
Commits (87)
job:
# Windows 10 with Boost and Exprtk
# downloaded and compiled locally as
# submodules
win_visual_studio:
tags:
- Win
before_script:
- call VsDevCmd.bat
- cd build_scripts\windows
- call win_download_dependencies.bat
- cd ..\..
script:
- cd build_scripts\windows
- call win_VS_build_x64_debug.bat
- call win_run_tests.bat
- cd ..\..
# Latest Ubuntu with Boost and Exprtk
# in system directories
ubuntu_boost_system:
tags:
- centos7
......@@ -8,6 +29,32 @@ job:
- git clone https://github.com/ArashPartow/exprtk.git
- cp exprtk/exprtk.hpp /usr/include
- export TERM=xterm
- ./build-ci.sh
- cd build_scripts/linux
- ./linux_gcc_build_x64_debug.sh
- cd ../..
script:
- cd build_scripts/linux
- './linux_run_tests.sh'
- cd ../..
# Latest Ubuntu with Boost and Exprtk
# compiled locally as submodules
ubuntu_boost_local:
tags:
- centos7
image: martinbeseda/ubuntu-ci:latest
before_script:
- cd build_scripts/linux
- ./download_dependencies.sh
- cd ../..
script:
- cd build_scripts/linux
- ./linux_gcc_build_x64_debug.sh
- './linux_run_tests.sh'
- cd ../..
script: "./run_tests.sh"
Summary
(Summarize the bug encountered concisely)
(Summarize the task concisely)
Associated classes
(Classes, which need to be modified, if any)
/label ~bug ~reproduced ~needs-investigation
/label ~task
Summary
(Summarize the task concisely)
/label ~task ~todo
[submodule "external_dependencies/exprtk"]
path = external_dependencies/exprtk
url = https://github.com/ArashPartow/exprtk.git
[submodule "external_dependencies/boost"]
path = external_dependencies/boost
url = https://github.com/boostorg/boost.git
cmake_minimum_required(VERSION 3.0)
project(lib4neuro)
if(WIN32)
ADD_DEFINITIONS("-DBOOST_ALL_NO_LIB")
else()
ADD_DEFINITIONS("-DBOOST_TEST_DYN_LINK")
endif()
#cmake_policy(SET CMP0074 NEW)
#cmake_policy(SET CMP0060 NEW)
......@@ -34,9 +41,9 @@ endif (NOT CMAKE_BUILD_TYPE)
# Setting C++ compiler flags #
#--------------------------------#
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -mtune=native" )
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall" )
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
if( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel" )
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -xHost" )
endif()
......@@ -53,14 +60,17 @@ endif()
message("Looking for external libraries...")
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
# TODO Instead use better FIND BOOST !!!
set(Boost_USE_MULTITHREADED ON)
find_package(Boost REQUIRED COMPONENTS serialization random)
if(Boost_FOUND)
message("Boost INCLUDE DIR: ${Boost_INCLUDEDIR}")
message("Boost LIB DIR: ${Boost_LIBRARY_DIRS}")
include_directories(${Boost_INCLUDE_DIR} ${Boost_INCLUDEDIR} ${Boost_INCLUDE_DIRS})
link_directories(${Boost_LIBRARY_DIRS})
endif()
set(Boost_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external_dependencies/boost)
set(Boost_LIBRARY_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/external_dependencies/boost/stage/lib)
message("Boost INCLUDE DIR: ${Boost_INCLUDE_DIR}")
message("Boost LIB DIR: ${Boost_LIBRARY_DIRS}")
message("lib4neuro LIB DIR: ${LIB4NEURO_DIR}")
include_directories(${Boost_INCLUDE_DIR} ${Boost_INCLUDEDIR} ${Boost_INCLUDE_DIRS})
link_directories(${Boost_LIBRARY_DIRS} ${LIB4NEURO_DIR})
find_package(exprtk)
......@@ -86,8 +96,20 @@ set(SRC_DIR src)
set(PROJECT_BINARY_DIR build)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY bin)
#
# Dependencies for the lib4neuro library
#
if(WIN32)
set(LINK_DEP_LIB4NEURO libboost_serialization libboost_system libboost_random libboost_unit_test libexprtk)
else()
set(LINK_DEP_LIB4NEURO boost_serialization boost_system boost_random boost_unit_test exprtk)
endif()
include_directories(include ${SRC_DIR})
message(" Running CMake in: ${SRC_DIR} ${PROJECT_BINARY_DIR}")
add_subdirectory(${SRC_DIR} ${PROJECT_BINARY_DIR})
......@@ -237,6 +237,10 @@
cmake_policy(PUSH)
cmake_policy(SET CMP0057 NEW) # if IN_LIST
set(Boost_FIND_VERSION 0)
set(BOOST_LIBRARY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external_dependencies/boost/stage/lib)
set(BOOST_LIBRARYDIR ${CMAKE_CURRENT_SOURCE_DIR}/external_dependencies/boost/stage/lib)
#-------------------------------------------------------------------------------
# Before we go searching, check whether boost-cmake is available, unless the
# user specifically asked NOT to search for boost-cmake.
......@@ -1173,7 +1177,10 @@ _Boost_CHECK_SPELLING(Boost_LIBRARYDIR)
_Boost_CHECK_SPELLING(Boost_INCLUDEDIR)
# Collect environment variable inputs as hints. Do not consider changes.
foreach(v BOOSTROOT BOOST_ROOT BOOST_INCLUDEDIR BOOST_LIBRARYDIR)
message("HINTS")
foreach(v BOOSTROOT BOOST_ROOT BOOST_INCLUDEDIR BOOST_LIBRARYDIR ${CMAKE_CURRENT_SOURCE_DIR}/external_dependencies/boost/stage/lib)
message("${v}: ${${v}}")
set(_env $ENV{${v}})
if(_env)
file(TO_CMAKE_PATH "${_env}" _ENV_${v})
......@@ -1220,7 +1227,8 @@ if(_Boost_CHANGE_INCDIR AND NOT _Boost_INCLUDE_DIR_CHANGED)
endif()
if(NOT Boost_INCLUDE_DIR)
set(_boost_INCLUDE_SEARCH_DIRS "")
set(_boost_INCLUDE_SEARCH_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/external_dependencies/boost")
if(BOOST_INCLUDEDIR)
list(APPEND _boost_INCLUDE_SEARCH_DIRS ${BOOST_INCLUDEDIR})
elseif(_ENV_BOOST_INCLUDEDIR)
......@@ -1231,6 +1239,8 @@ if(NOT Boost_INCLUDE_DIR)
list(APPEND _boost_INCLUDE_SEARCH_DIRS ${BOOST_ROOT}/include ${BOOST_ROOT} ${BOOST_ROOT}/boost)
elseif( _ENV_BOOST_ROOT )
list(APPEND _boost_INCLUDE_SEARCH_DIRS ${_ENV_BOOST_ROOT}/include ${_ENV_BOOST_ROOT} ${_ENV_BOOST_ROOT}/boost)
else()
set(BOOST_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/external_dependencies/boost")
endif()
if( Boost_NO_SYSTEM_PATHS)
......@@ -1572,7 +1582,9 @@ foreach(c DEBUG RELEASE)
C:/boost/lib
C:/boost
/sw/local/lib
${CMAKE_CURRENT_SOURCE_DIR}/external_dependencies/boost/libs
)
message("_boost_LIBRARY_SEARCH_DIRS_${c}: ${_boost_LIBRARY_SEARCH_DIRS_${c}}")
endif()
endif()
endforeach()
......@@ -2060,6 +2072,11 @@ endif()
# Notification to end user about what was found
# ------------------------------------------------------------------------
message("MY BOOST_ROOT: ${BOOST_ROOT}")
message("MY Boost_INCLUDE_DIR: ${Boost_INCLUDE_DIR}")
message("MY Boost_LIBRARY_DIR_DEBUG: ${Boost_LIBRARY_DIR_DEBUG}")
message("MY Boost_LIBRARIES: ${Boost_LIBRARIES}")
set(Boost_LIBRARIES "")
if(Boost_FOUND)
if(NOT Boost_FIND_QUIETLY)
......@@ -2134,5 +2151,6 @@ list(SORT _Boost_COMPONENTS_SEARCHED)
set(_Boost_COMPONENTS_SEARCHED "${_Boost_COMPONENTS_SEARCHED}"
CACHE INTERNAL "Components requested for this build tree.")
# Restore project's policies
#Restore project's policies
cmake_policy(POP)
......@@ -23,6 +23,7 @@ FIND_PATH(
/usr/local
/usr
/opt/local
external_dependencies/exprtk
PATH_SUFFIXES
include
)
......
#!/bin/sh
#------------#------------------------------------------------------------
# Parameters #
#------------#
# Build type (Release/Debug)
BUILD_TYPE=Debug
# C++ compiler
CXX_COMPILER="g++-8"
if [ -z "$BUILD_TYPE" ] || [ -z "$CXX_COMPILER" ]; then
(>&2 echo "Set, please, both BUILD_TYPE and CXX_COMPILER variables in the 'build.sh' script.")
exit 2
fi
$(pwd)/clean.sh
cmake -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DCMAKE_CXX_COMPILER=${CXX_COMPILER} .
cmake --build . --config ${BUILD_TYPE} -- -j${N_CORES} && (tput setaf 2; echo "Build complete."; echo "For examples have a look at the folder build/bin/examples."; tput sgr 0; ) || (tput setaf 1; echo "Build finished with errors!"; tput sgr 0; exit 1;)
@echo off
title Build lib4neuro project
rem Build type (Release/Debug)
set BUILD_TYPE=Debug
rem C++ compiler
set CXX_COMPILER=cl
set C_COMPILER=cl
rem Makefile generator
rem For the complete list type "cmake --help"
rem Example: "MSYS Makefiles", "MinGW Makefiles", "NMake Makefiles"
set MAKEFILE_GENERATOR="Visual Studio 15 2017"
call clean.bat
cmake -G %MAKEFILE_GENERATOR% -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -DCMAKE_BUILD_TYPE=%BUILD_TYPE% -DCMAKE_CXX_COMPILER=%CXX_COMPILER% -DCMAKE_C_COMPILER=%C_COMPILER% -DBOOST_ROOT=%BOOST_ROOT% -DBOOST_LIBRARYDIR=%BOOST_LIBRARYDIR% -DBOOST_INCLUDEDIR=%BOOST_INCLUDEDIR% -DBoost_DEBUG:BOOL=ON .
cmake --build . --config %BUILD_TYPE% && (echo (Build complete.); echo (For examples have a look at the folder build/bin/examples.)) || (echo "Build finished with errors!")
#!/bin/sh
#------------#------------------------------------------------------------
# Parameters #
#------------#
# Build type (Release/Debug)
BUILD_TYPE=
# C++ compiler
CXX_COMPILER=
if [ -z "$BUILD_TYPE" ] || [ -z "$CXX_COMPILER" ]; then
(>&2 echo "Set, please, both BUILD_TYPE and CXX_COMPILER variables in the 'build.sh' script.")
exit 2
fi
$(pwd)/clean.sh
cmake -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DCMAKE_CXX_COMPILER=${CXX_COMPILER} .
cmake --build . --config ${BUILD_TYPE} -- -j${N_CORES} && (tput setaf 2; echo "Build complete."; echo "For examples have a look at the folder build/bin/examples."; tput sgr 0; ) || (tput setaf 1; echo "Build finished with errors!"; tput sgr 0; exit 1;)
#!/bin/sh
clear
RED='\033[0;31m'
CYAN='\033[0;36m'
YELLOW='\033[1;33m'
GREEN='\033[0;32m'
NC='\033[0m' # No Color
echo "Downloading '${CYAN}lib4neuro${NC}' project dependencies"
# Should we download BOOST? (yes/no)
DOWNLOAD_DEP=yes
if [ $DOWNLOAD_DEP = "yes" ]
then
echo "The required libraries will be downloaded from the official repositories into the directory '${YELLOW}external_dependencies${NC}'"
cd ../..
rm -r external_dependencies
git submodule init
git submodule update --remote
cd external_dependencies/boost
git submodule update --init
./bootstrap.sh
cd ../../build_scripts/linux
echo "${GREEN}External dependencies download \& bootstrapping finished${NC}"
fi
#!/bin/sh
cd ../..
rm -r build/examples
cd build_scripts/linux
\ No newline at end of file
#!/bin/bash
#!/bin/sh
cd ../..
rm -rf build
rm -rf Makefile
rm -rf docs/*
rm -f src/*TestRunner*
......@@ -8,4 +9,12 @@ rm -f src/*.o src/*.mod
rm -f src/funit.tmp src/*_fun.f90
rm -f CMakeCache.txt
rm -f cmake_install.cmake src/cmake_install.cmake
rm -rf CMakeFiles src/CMakeFiles src/examples/CMakeFiles src/tests/CMakeFiles
rm -rf CMakeFiles src/CMakeFiles src/examples/CMakeFiles src/tests/CMakeFiles build/CMakeFiles build/examples/CMakeFiles build/unit-tests/CMakeFiles
rm -f build/Makefile build/examples/Makefile build/unit-tests/Makefile build/cmake_install.cmake build/examples/cmake_install.cmake build/unit-tests/cmake_install.cmake
mv build/examples/bin/* build/examples
mv build/unit-tests/bin/* build/unit-tests
rm -rf build/examples/bin build/unit-tests/bin
cd build_scripts/linux
\ No newline at end of file
#!/bin/sh
cd ../..
rm -r build/lib
cd build_scripts/linux
\ No newline at end of file
#!/bin/sh
cd ../..
rm -rf build/unit-tests
cd build_scripts/linux
\ No newline at end of file
#!/bin/sh
clear
# Should we rebuild BOOST? (yes/no)
REBUILD_BOOST=yes
# Should we build the examples? (yes/no)
BUILD_EXAMPLES=yes
# Should we build the unit-tests? (yes/no)
BUILD_TESTS=yes
# Should we build the lib4neuro library? (yes)
BUILD_LIB=yes
# C++ compiler
CXX_COMPILER="g++"
C_COMPILER="gcc"
#**********************DO NOT CHANGE BEYOND THIS LINE****************************************
RED='\033[0;31m'
CYAN='\033[0;36m'
YELLOW='\033[1;33m'
GREEN='\033[0;32m'
WHITE='\033[1;37m'
NC='\033[0m' # No Color
echo "Building the '${CYAN}lib4neuro${NC}' project for ${WHITE}Debug${NC}"
BUILD_SOMETHING=no
BUILD_SOMETHING_LIB=no
if [ $BUILD_LIB = "yes" ]
then
echo "${CYAN}lib4neuro${NC} build type: ${WHITE}Debug${NC}"
echo "${CYAN}lib4neuro${NC} build architecture: ${WHITE}x64${NC}"
echo "${CYAN}lib4neuro${NC} will be built in '${YELLOW}build/lib/${NC}'"
BUILD_SOMETHING=yes
BUILD_SOMETHING_LIB=yes
fi
if [ $BUILD_TESTS = "yes" ]
then
echo "${CYAN}lib4neuro${NC} unit tests will be built in '${YELLOW}build/unit-tests${NC}'"
BUILD_SOMETHING=yes
BUILD_SOMETHING_LIB=yes
fi
if [ $BUILD_EXAMPLES = "yes" ]
then
echo "${CYAN}lib4neuro${NC} examples will be built in '${YELLOW}build/examples${NC}'"
BUILD_SOMETHING=yes
BUILD_SOMETHING_LIB=yes
fi
if [ $REBUILD_BOOST = "yes" ]
then
echo "The required '${CYAN}BOOST${NC}' library will be recompiled in the directory '${YELLOW}external_dependencies/boost${NC}'"
BUILD_SOMETHING=yes
BUILD_SOMETHING_LIB=yes
fi
# Boost rebuild
if [ $REBUILD_BOOST = "yes" ]
then
clear
echo "Rebuilding '${CYAN}BOOST${NC}' for ${WHITE}Debug${NC}"
cd ../..
rm -r external_dependencies/boost/stage
rm -r external_dependencies/boost/bin.v2
cd external_dependencies/boost
./b2 --layout=system variant=debug link=shared address-model=64 --with-system --with-serialization --with-random
# ./b2 --layout=system variant=debug link=shared address-model=64 --with-system --with-serialization --with-random
cd ../../build_scripts/linux
fi
if [ $BUILD_SOMETHING_LIB = "yes" ]
then
if [ $BUILD_LIB = "yes" ]
then
./linux_clean_lib.sh
fi
if [ $BUILD_EXAMPLES = "yes" ]
then
./linux_clean_examples.sh
fi
if [ $BUILD_TESTS = "yes" ]
then
./linux_clean_tests.sh
fi
clear
echo "Building the '${CYAN}lib4neuro${NC}' project for ${WHITE}Debug${NC} (preparing makefiles)"
cd ../..
cmake -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_COMPILER=${CXX_COMPILER} -DCMAKE_C_COMPILER=${C_COMPILER} -DBOOST_ROOT=${BOOST_ROOT} -DBOOST_LIBRARYDIR=${BOOST_LIBRARYDIR} -DBOOST_INCLUDEDIR=${BOOST_INCLUDEDIR} -DBUILD_TESTS=${BUILD_TESTS} -DBUILD_EXAMPLES=${BUILD_EXAMPLES} -DBUILD_LIB=${BUILD_LIB} -DLIB4NEURO_DIR=${PWD}/build/lib .
echo "Building the '${CYAN}lib4neuro${NC}' project for ${WHITE}Debug${NC} (building)"
( cmake --build . --config Debug -- -j${N_CORES} 2> build.log ) && ( echo "${GREEN}Build complete${NC}." ) || ( echo "${RED}Build finished with errors${NC}!"; exit 1; )
cd build_scripts/linux
./linux_clean_garbage.sh
fi
#!/bin/bash
#!/bin/sh
cd ../..
##############
# UNIT TESTS #
##############
for f in build/bin/unit-tests/*_test; do
for f in build/unit-tests/*_test; do
${f} || exit -1
done
cd build_scripts/linux
\ No newline at end of file
@echo off
title Building the 'lib4neuro' project for Debug
cls
set "REBUILD_BOOST="
set "BUILD_EXAMPLES="
set "BUILD_TESTS="
set "BUILD_LIB="
set "BUILD_SOMETHING="
set "BUILD_SOMETHING_LIB="
rem call VsDevCmd.bat
rem Should we rebuild BOOST? (yes/no)
set REBUILD_BOOST=yes
rem Should we build the examples? (yes/no)
set BUILD_EXAMPLES=yes
rem Should we build the unit-tests? (yes/no)
set BUILD_TESTS=yes
rem Should we build the lib4neuro library? (yes)
set BUILD_LIB=yes
rem **********************DO NOT CHANGE BEYOND THIS LINE****************************************
set BUILD_SOMETHING=no
set BUILD_SOMETHING_LIB=no
IF "%BUILD_LIB%"=="yes" (
echo Lib4neuro build type: Debug
echo Lib4neuro build architecture: x64
echo Lib4neuro will be built in 'build\lib\'
set BUILD_SOMETHING=yes
set BUILD_SOMETHING_LIB=yes
)
IF "%BUILD_TESTS%"=="yes" (
echo Lib4neuro unit tests will be built in 'build\unit-tests'
set BUILD_SOMETHING=yes
set BUILD_SOMETHING_LIB=yes
)
IF "%BUILD_EXAMPLES%"=="yes" (
echo Lib4neuro examples will be built in 'build\examples'
set BUILD_SOMETHING=yes
set BUILD_SOMETHING_LIB=yes
)
IF "%REBUILD_BOOST%"=="yes" (
echo The required BOOST library will be recompiled in the directory 'external_dependencies\boost'
set BUILD_SOMETHING=yes
)
IF "%BUILD_SOMETHING%"=="yes" (
rem pause
)
rem Boost rebuild
IF "%REBUILD_BOOST%"=="yes" (
title Rebuilding 'BOOST' for Debug
cd ..\..
rmdir /s /q external_dependencies\boost\stage 2>NUL
rmdir /s /q external_dependencies\boost\bin.v2 2>NUL
cd external_dependencies\boost
.\b2 --layout=system variant=debug link=static address-model=64 --with-system --with-serialization --with-random
cd ..\..\build_scripts\windows
)
IF "%BUILD_SOMETHING_LIB%"=="yes" (
IF "%BUILD_LIB%"=="yes" (
call win_clean_lib.bat
)
IF "%BUILD_EXAMPLES%"=="yes" (
call win_clean_examples.bat
)
IF "%BUILD_TESTS%"=="yes" (
call win_clean_tests.bat
)
title Building the 'lib4neuro' project for Debug (preparing makefiles)
rem C++ compiler (Requires Visual Studio 2017)
set CXX_COMPILER=cl
set C_COMPILER=cl
set MAKEFILE_GENERATOR="Visual Studio 15 2017 Win64"
cd ..\..
cmake -G "Visual Studio 15 2017 Win64" -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_COMPILER=%CXX_COMPILER% -DCMAKE_C_COMPILER=%C_COMPILER% -DBOOST_ROOT=%BOOST_ROOT% -DBOOST_LIBRARYDIR=%BOOST_LIBRARYDIR% -DBOOST_INCLUDEDIR=%BOOST_INCLUDEDIR% -DBUILD_TESTS=%BUILD_TESTS% -DBUILD_EXAMPLES=%BUILD_EXAMPLES% -DBUILD_LIB=%BUILD_LIB% -DLIB4NEURO_DIR=build\lib .
title Building the 'lib4neuro' project for Debug (building)
(cmake --build . --config Debug > build.log) && (echo "Build complete.") || (echo "Build finished with errors!")
cd build_scripts\windows
IF "%BUILD_LIB%"=="yes" (
cd ..\..
rem Moving LIB files around to have a neater structure
xcopy /y build\bin\Debug\lib4neuro.dll build\lib 2>NUL
xcopy /y build\lib\Debug\lib4neuro.lib build\lib 2>NUL
rmdir /s /q "build\lib\Debug" 2> NUL
rmdir /s /q "build\libboost_unit_test.dir" 2> NUL
cd build_scripts\windows
)
IF "%BUILD_EXAMPLES%"=="yes" (
cd ..\..
rem Moving EXAMPLE files around to have a neater structure
mkdir build\tmp
xcopy /y build\examples\bin\Debug\*.exe build\tmp 2>NUL
rmdir /s /q "build\examples" 2> NUL
move build\tmp build\examples
xcopy /y build\lib\*.dll build\examples 2>NUL
cd build_scripts\windows
)
IF "%BUILD_TESTS%"=="yes" (
cd ..\..
rem Moving EXAMPLE files around to have a neater structure
mkdir build\tmp
xcopy /y build\unit-tests\bin\Debug\*.exe build\tmp 2>NUL
rmdir /s /q "build\unit-tests" 2> NUL
move build\tmp build\unit-tests
xcopy /y build\lib\*.dll build\unit-tests 2>NUL
cd build_scripts\windows
)
call win_clean_garbage.bat
)
@echo off
title Building the 'lib4neuro' project for Release
cls
set "REBUILD_BOOST="
set "BUILD_EXAMPLES="
set "BUILD_TESTS="
set "BUILD_LIB="
set "BUILD_SOMETHING="
set "BUILD_SOMETHING_LIB="
rem call VsDevCmd.bat
rem Should we rebuild BOOST? (yes/no)
set REBUILD_BOOST=yes
rem Should we build the examples? (yes/no)
set BUILD_EXAMPLES=yes
rem Should we build the unit-tests? (yes/no)
set BUILD_TESTS=yes
rem Should we build the lib4neuro library? (yes)
set BUILD_LIB=yes
rem **********************DO NOT CHANGE BEYOND THIS LINE****************************************
set BUILD_SOMETHING=no
set BUILD_SOMETHING_LIB=no
IF "%BUILD_LIB%"=="yes" (
echo Lib4neuro build type: Release
echo Lib4neuro build architecture: x64
echo Lib4neuro will be built in 'build\lib\'
set BUILD_SOMETHING=yes
set BUILD_SOMETHING_LIB=yes
)
IF "%BUILD_TESTS%"=="yes" (
echo Lib4neuro unit tests will be built in 'build\unit-tests'
set BUILD_SOMETHING=yes
set BUILD_SOMETHING_LIB=yes
)
IF "%BUILD_EXAMPLES%"=="yes" (
echo Lib4neuro examples will be built in 'build\examples'
set BUILD_SOMETHING=yes
set BUILD_SOMETHING_LIB=yes
)
IF "%REBUILD_BOOST%"=="yes" (
echo The required BOOST library will be recompiled in the directory 'external_dependencies\boost'
set BUILD_SOMETHING=yes
)
IF "%BUILD_SOMETHING%"=="yes" (
rem pause
)
rem Boost rebuild
IF "%REBUILD_BOOST%"=="yes" (
title Rebuilding 'BOOST' for Release
cd ..\..
rmdir /s /q external_dependencies\boost\stage 2>NUL
rmdir /s /q external_dependencies\boost\bin.v2 2>NUL
cd external_dependencies\boost
.\b2 --layout=system variant=release link=static address-model=64 --with-system --with-serialization --with-random
cd ..\..\build_scripts\windows
)
IF "%BUILD_SOMETHING_LIB%"=="yes" (
IF "%BUILD_LIB%"=="yes" (
call win_clean_lib.bat
)
IF "%BUILD_EXAMPLES%"=="yes" (
call win_clean_examples.bat
)
IF "%BUILD_TESTS%"=="yes" (
call win_clean_tests.bat
)
title Building the 'lib4neuro' project for Release (preparing makefiles)
rem C++ compiler (Requires Visual Studio 2017)
set CXX_COMPILER=cl
set C_COMPILER=cl
set MAKEFILE_GENERATOR="Visual Studio 15 2017 Win64"
cd ..\..
cmake -G "Visual Studio 15 2017 Win64" -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=%CXX_COMPILER% -DCMAKE_C_COMPILER=%C_COMPILER% -DBOOST_ROOT=%BOOST_ROOT% -DBOOST_LIBRARYDIR=%BOOST_LIBRARYDIR% -DBOOST_INCLUDEDIR=%BOOST_INCLUDEDIR% -DBUILD_TESTS=%BUILD_TESTS% -DBUILD_EXAMPLES=%BUILD_EXAMPLES% -DBUILD_LIB=%BUILD_LIB% -DLIB4NEURO_DIR=build\lib .
title Building the 'lib4neuro' project for Release (building)
(cmake --build . --config Release > build.log) && (echo "Build complete.") || (echo "Build finished with errors!")
cd build_scripts\windows
IF "%BUILD_LIB%"=="yes" (
cd ..\..
rem Moving LIB files around to have a neater structure
xcopy /y build\bin\Release\lib4neuro.dll build\lib 2>NUL
xcopy /y build\lib\Release\lib4neuro.lib build\lib 2>NUL
rmdir /s /q "build\lib\Release" 2> NUL
cd build_scripts\windows
)
IF "%BUILD_EXAMPLES%"=="yes" (
cd ..\..
rem Moving EXAMPLE files around to have a neater structure
mkdir build\tmp
xcopy /y build\examples\bin\Release\*.exe build\tmp 2>NUL
rmdir /s /q "build\examples" 2> NUL
move build\tmp build\examples
xcopy /y build\lib\*.dll build\examples 2>NUL
cd build_scripts\windows
)
IF "%BUILD_TESTS%"=="yes" (
cd ..\..
rem Moving EXAMPLE files around to have a neater structure
mkdir build\tmp
xcopy /y build\unit-tests\bin\Release\*.exe build\tmp 2>NUL
rmdir /s /q "build\unit-tests" 2> NUL
move build\tmp build\unit-tests
xcopy /y build\lib\*.dll build\unit-tests 2>NUL
cd build_scripts\windows
)
call win_clean_garbage.bat
)
@echo off
title Cleaning up 'examples'
cd ..\..
rmdir /s /q "build\examples" 2>NUL
cd build_scripts\windows
\ No newline at end of file
@echo off
title Cleaning up after the party!
cd ..\..
rem Deleting unnecessary files
rmdir /s /q Debug 2>NUL
rmdir /s /q Release 2>NUL
rmdir /s /q Win32 2>NUL
rmdir /s /q x64 2>NUL
del "ALL_BUILD.vcxproj.user" 2>NUL
del "Makefile" 2>NUL
del /s /q "docs\*" 2>NUL
del "src/*TestRunner*" 2>NUL
del "src/*.o src\*.mod" 2>NUL
del "src\funit.tmp" 2>NUL
del "src\*_fun.f90" 2>NUL
del CMakeCache.txt 2>NUL
del "cmake_install.cmake" 2>NUL
del "src\cmake_install.cmake" 2>NUL
del /s /q CMakeFiles 2>NUL
del "*.vcxproj" 2>NUL
del "*.vcxproj.filters" 2>NUL
del "*.sln" 2>NUL
rmdir /s /q "CMakeFiles" 2>NUL
rmdir /s /q "src\CMakeFiles" 2>NUL
rmdir /s /q "src\examples\CMakeFiles" 2>NUL
rmdir /s /q "src\tests\CMakeFiles" 2>NUL
rmdir /s /q "build\CMakeFiles" 2>NUL
rmdir /s /q "build\lib4neuro.dir" 2>NUL
rmdir /s /q "build\libexprtk.dir" 2>NUL
rmdir /s /q "build\bin" 2>NUL
del /q "build\*vcxproj*" 2>NUL
del /q "build\*cmake*" 2>NUL
cd build_scripts\windows
\ No newline at end of file
@echo off
title Cleaning up 'lib4neuro'
cd ..\..
rmdir /s /q "build\lib" 2>NUL
rmdir /s /q "build\bin\Debug" 2>NUL
rmdir /s /q "build\bin\Release" 2>NUL
rmdir /s /q "build\libboost_unit_test.dir" 2>NUL
cd build_scripts\windows
\ No newline at end of file
@echo off
title Cleaning up 'unit-tests'
cd ..\..
rmdir /s /q "build\unit-tests" 2>NUL
cd build_scripts\windows
\ No newline at end of file
@echo off
title Downloading 'lib4neuro' project dependencies
cls
set "DOWNLOAD_DEP="
rem call VsDevCmd.bat
rem Should we download BOOST? (yes/no)
set DOWNLOAD_DEP=yes
IF "%DOWNLOAD_DEP%"=="yes" (
echo The required libraries will be downloaded from the official repositories into the directory 'external_dependencies'
rem pause
)
rem Dependencies download
IF "%DOWNLOAD_DEP%"=="yes" (
cd ..\..
rmdir /s /q "external_dependencies" 2>NUL
git submodule init
git submodule update --remote
cd external_dependencies\boost
rem Submodules containing headers included in lib4neuro directly, but not required by serialization, system nor random
rem set BOOST_DEPENDENCIES_LIB4NEURO=libs/algorithm libs/range libs/concept_check libs/test libs/timer libs/exception
rem Submodules required by linked libraries serialization, system or random
rem set BOOST_DEPENDENCIES=libs/bind libs/container_hash libs/type_index libs/function libs/array libs/optional libs/integer libs/utility libs/move libs/detail libs/throw_exception tools/build libs/config libs/assert libs/predef libs/io libs/spirit libs/smart_ptr libs/static_assert libs/type_traits libs/mpl libs/core libs/preprocessor libs/iterator libs/winapi
rem Submodules required by lib4neuro
rem set BOOST_REQUIRED_LIBS=libs/serialization libs/system libs/random
rem echo Running 'submodule update --init %BOOST_DEPENDENCIES_LIB4NEURO% %BOOST_DEPENDENCIES% %BOOST_REQUIRED_LIBS%'
rem git submodule update --init libs/algorithm libs/exception libs/range libs/concept_check libs/test libs/timer libs/bind libs/container_hash libs/type_index libs/function libs/array libs/optional libs/integer libs/utility libs/move libs/detail libs/throw_exception tools/build libs/config libs/assert libs/predef libs/io libs/spirit libs/smart_ptr libs/static_assert libs/type_traits libs/mpl libs/core libs/preprocessor libs/iterator libs/winapi libs/serialization libs/system libs/random
git submodule update --init
call bootstrap.bat
cd ..\..\build_scripts\windows
)
@echo off
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
cd ..\..\build_scripts\windows
\ No newline at end of file
@echo off
rmdir /s /q build 2>NUL
del Makefile 2>NUL
del /s /q "docs/*" 2>NUL
del "src/*TestRunner*" 2>NUL
del "src/*.o src/*.mod" 2>NUL
del src/funit.tmp 2>NUL
del "src/*_fun.f90" 2>NUL
del CMakeCache.txt 2>NUL
del cmake_install.cmake 2>NUL
del src/cmake_install.cmake 2>NUL
del /s /q CMakeFiles 2>NUL
del "*.vcxproj" 2>NUL
del "*.vcxproj.filters" 2>NUL
del "*.sln" 2>NUL
rmdir /s /q CMakeFiles 2>NUL
rmdir /s /q src/CMakeFiles 2>NUL
rmdir /s /q src/examples/CMakeFiles 2>NUL
rmdir /s /q src/tests/CMakeFiles 2>NUL
Subproject commit 24fcd694127f1d548f90f718faa13ddfb426149b
Subproject commit 9a8474e7a259fa5348658a651cd19af216749674
add_subdirectory(tests bin/unit-tests)
add_subdirectory(examples bin/examples)
add_library(4neuro SHARED
Neuron/Neuron.cpp
Neuron/NeuronBinary.cpp
Neuron/NeuronConstant.cpp
Neuron/NeuronLinear.cpp
Neuron/NeuronLogistic.cpp
Network/NeuralNetwork.cpp
Network/NeuralNetworkSum.cpp
NetConnection/ConnectionFunctionGeneral.cpp
NetConnection/ConnectionFunctionIdentity.cpp
LearningMethods/ParticleSwarm.cpp
DataSet/DataSet.cpp
ErrorFunction/ErrorFunctions.cpp
Solvers/DESolver.cpp
LearningMethods/ILearningMethods.h)
if ("${BUILD_TESTS}" STREQUAL "yes")
add_subdirectory(tests unit-tests)
endif ()
if ("${BUILD_EXAMPLES}" STREQUAL "yes")
add_subdirectory(examples examples)
endif ()
add_library(boost_unit_test SHARED boost_test_lib_dummy.cpp)
add_library(exprtk SHARED exprtk.cpp)
if ("${BUILD_LIB}" STREQUAL "yes")
add_library(lib4neuro SHARED
Neuron/Neuron.cpp
Neuron/NeuronBinary.cpp
Neuron/NeuronConstant.cpp
Neuron/NeuronLinear.cpp
Neuron/NeuronLogistic.cpp
Network/NeuralNetwork.cpp
Network/NeuralNetworkSum.cpp
NetConnection/ConnectionFunctionGeneral.cpp
NetConnection/ConnectionFunctionIdentity.cpp
LearningMethods/ParticleSwarm.cpp
DataSet/DataSet.cpp
ErrorFunction/ErrorFunctions.cpp
Solvers/DESolver.cpp
LearningMethods/ILearningMethods.h
)
if(WIN32)
add_library(libboost_unit_test STATIC boost_test_lib_dummy.cpp)
add_library(libexprtk STATIC exprtk.cpp)
target_link_libraries(lib4neuro ${LINK_DEP_LIB4NEURO})
else()
add_library(boost_unit_test SHARED boost_test_lib_dummy.cpp)
add_library(exprtk SHARED exprtk.cpp)
target_link_libraries(lib4neuro ${LINK_DEP_LIB4NEURO})
endif()
endif ()
target_link_libraries(4neuro ${Boost_LIBRARIES} boost_unit_test exprtk)
......@@ -18,7 +18,7 @@
#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
......@@ -92,13 +92,13 @@ public:
* 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 +114,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 +123,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 +170,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 +184,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
......@@ -5,6 +5,8 @@
#ifndef INC_4NEURO_ERRORFUNCTION_H
#define INC_4NEURO_ERRORFUNCTION_H
#include "../settings.h"
#include "../Network/NeuralNetwork.h"
#include "../DataSet/DataSet.h"
......@@ -26,7 +28,7 @@ public:
*
* @return
*/
virtual size_t get_dimension();
LIB4NEURO_API virtual size_t get_dimension();
protected:
......@@ -44,14 +46,14 @@ public:
* @param net
* @param ds
*/
MSE(NeuralNetwork* net, DataSet* ds);
LIB4NEURO_API MSE(NeuralNetwork* net, DataSet* ds);
/**
*
* @param weights
* @return
*/
virtual double eval(std::vector<double>* weights = nullptr);
LIB4NEURO_API virtual double eval(std::vector<double>* weights = nullptr);
private:
......@@ -64,31 +66,31 @@ public:
/**
*
*/
ErrorSum();
LIB4NEURO_API ErrorSum();
/**
*
*/
~ErrorSum();
LIB4NEURO_API ~ErrorSum();
/**
*
* @param weights
* @return
*/
virtual double eval(std::vector<double>* weights = nullptr);
LIB4NEURO_API virtual double eval(std::vector<double>* weights = nullptr);
/**
*
* @param F
*/
void add_error_function(ErrorFunction *F, double alpha = 1.0);
LIB4NEURO_API void add_error_function(ErrorFunction *F, double alpha = 1.0);
/**
*
* @return
*/
size_t get_dimension() override;
LIB4NEURO_API size_t get_dimension() override;
private:
std::vector<ErrorFunction*>* summand;
......
......@@ -8,6 +8,8 @@
#ifndef INC_4NEURO_PARTICLESWARM_H
#define INC_4NEURO_PARTICLESWARM_H
#include "../settings.h"
#include <cstdlib>
#include <ctime>
#include <cmath>
......@@ -54,38 +56,38 @@ public:
/**
*
*/
void print_coordinate();
LIB4NEURO_API void print_coordinate();
/**
*
* @param f_dim
*/
Particle(ErrorFunction* ef, 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);
/**
*
......@@ -95,7 +97,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);
};
......@@ -140,13 +142,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();
/**
*
......@@ -155,7 +157,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:
......@@ -171,12 +173,12 @@ public:
* @param iter_max
*/
//TODO make domain_bounds constant
ParticleSwarm( ErrorFunction* ef, std::vector<double> *domain_bounds, double c1 = 1.711897, double c2 = 1.711897, double w = 0.711897, size_t n_particles = 50, size_t iter_max = 1000 );
LIB4NEURO_API ParticleSwarm( ErrorFunction* ef, std::vector<double> *domain_bounds, double c1 = 1.711897, double c2 = 1.711897, double w = 0.711897, size_t n_particles = 50, size_t iter_max = 1000 );
/**
*
*/
~ParticleSwarm( );
LIB4NEURO_API ~ParticleSwarm( );
/**
......@@ -185,13 +187,13 @@ public:
* @param epsilon
* @param delta
*/
void optimize( double gamma, double epsilon, double delta=0.7 );
LIB4NEURO_API void optimize( double gamma, double epsilon, double delta=0.7 );
/**
*
* @return
*/
std::vector<double>* get_solution();
LIB4NEURO_API std::vector<double>* get_solution();
};
......
......@@ -8,6 +8,8 @@
#ifndef INC_4NEURO_CONNECTIONWEIGHT_H
#define INC_4NEURO_CONNECTIONWEIGHT_H
#include "../settings.h"
#include <boost/archive/text_oarchive.hpp>
#include <boost/archive/text_iarchive.hpp>
#include <boost/serialization/export.hpp>
......@@ -36,32 +38,32 @@ public:
/**
*
*/
ConnectionFunctionGeneral();
LIB4NEURO_API ConnectionFunctionGeneral();
/**
*
* @param param_count
* @param f
*/
ConnectionFunctionGeneral(std::vector<size_t> &param_indices, std::string &function_string);
LIB4NEURO_API ConnectionFunctionGeneral(std::vector<size_t> &param_indices, std::string &function_string);
/**
*
*/
virtual ~ConnectionFunctionGeneral( );
LIB4NEURO_API virtual ~ConnectionFunctionGeneral( );
/**
*
* @return
*/
virtual double eval( std::vector<double> &parameter_space );
LIB4NEURO_API virtual double eval( std::vector<double> &parameter_space );