Skip to content

Commit

Permalink
Merge pull request #1 from NeuralNetworkVerification/master
Browse files Browse the repository at this point in the history
Merge from master
  • Loading branch information
guykatzz authored Jul 30, 2020
2 parents 45a9f8b + 792e8ed commit 8170038
Show file tree
Hide file tree
Showing 197 changed files with 12,017 additions and 5,639 deletions.
31 changes: 31 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Check if this file is valid by running in bash:
# curl -X POST --data-binary @.codecov.yml https://codecov.io/validate

comment: false

ignore:
- "**/__init__.py"
- "maraboupy/test"

coverage:
status:
# Make sure the total coverage decreased by at most 1%
project:
default:
target: auto
threshold: 1%
base: auto
paths:
- "src"
- "maraboupy"
# Make sure the new added code is at least 80% covered
patch:
default:
target: 80%
base: auto
paths:
- "src"
- "maraboupy"



2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ tools/boost_1_68_0
/tools/boost.unzipped
/tools/boost_1_68_0.tar.gz
/tools/pybind11-2.3.0
/tools/OpenBLAS-0.3.9/
/tools/OpenBLASv0.3.9.tar.gz
/cpp_interface_example/example.elf
/src/input_parsers/mps_example/mps.elf

Expand Down
64 changes: 58 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,34 @@ language: cpp
cache:
directories:
- tools/boost_1_68_0

- $HOME/.pip-cache
- /c/Python3

before_install:
- PY_CMD=python3
- if [ "$TRAVIS_OS_NAME" = "windows" ]; then PY_CMD=/c/Python3/python ; else PY_CMD=python3 ; fi
- if [ "$TRAVIS_OS_NAME" = "windows" ]; then powershell Start-Process -PassThru -Wait PowerShell -ArgumentList "'-Command Set-MpPreference -DisableArchiveScanning \$true'" ; fi
- if [ "$TRAVIS_OS_NAME" = "windows" ]; then powershell Start-Process -PassThru -Wait PowerShell -ArgumentList "'-Command Set-MpPreference -DisableBehaviorMonitoring \$true'" ; fi
- if [ "$TRAVIS_OS_NAME" = "windows" ]; then powershell Start-Process -PassThru -Wait PowerShell -ArgumentList "'-Command Set-MpPreference -DisableRealtimeMonitoring \$true'" ; fi

addons:
apt:
packages:
- python3
- python3-pip
- python3-setuptools

install:
- if [ "$TRAVIS_COMPILER" = "gcc" ]; then
wget https://github.com/linux-test-project/lcov/archive/v1.13.zip;
unzip v1.13.zip;
export PATH=$PATH:`pwd`/lcov-1.13/bin;
fi
- if [ "$TRAVIS_OS_NAME" = "windows" ]; then if [[ ! -d "C:\Python3" || ! -f "C:\Python3\python" ]]; then choco install python3 --version=3.5.4 --params "/InstallDir:C:\Python3"; fi fi
- $PY_CMD -m pip install --user --upgrade pip
- $PY_CMD -m pip install --user --upgrade setuptools
- $PY_CMD -m pip install --user wheel
- $PY_CMD -m pip install --user -r maraboupy/test_requirements.txt --cache-dir $HOME/.pip-cache --progress-bar off

matrix:
include:
- os: linux
Expand All @@ -19,31 +39,63 @@ matrix:
script:
- mkdir -p build
- cd build
- cmake .. -DRUN_UNIT_TEST=ON -DPYTHON_EXECUTABLE=$(which $PY_CMD)
- cmake .. -DRUN_UNIT_TEST=ON -DPYTHON_EXECUTABLE=$(which $PY_CMD) -DCMAKE_BUILD_TYPE=Debug -DCODE_COVERAGE=ON
- cmake --build . -j 2
- ctest -L system -j 2
- ctest -L regress[0-1] -j 2
- cd ..
- $PY_CMD -m pytest --cov=maraboupy maraboupy/test

- os: linux
dist: xenial
compiler: clang
script:
- mkdir - p build
- cd build
- cmake .. -DRUN_UNIT_TEST=ON -DPYTHON_EXECUTABLE=$(which $PY_CMD)
- cmake .. -DRUN_UNIT_TEST=ON -DPYTHON_EXECUTABLE=$(which $PY_CMD)
- cmake --build . -j 2
- ctest -L system -j 2
- ctest -L regress0 -j 2
- cd ..
- $PY_CMD -m pytest maraboupy/test

- os: windows
script:
- choco install python3 --params "/InstallDir:C:\Python3"
- mkdir -p build
- cd build
- cmake .. -DRUN_UNIT_TEST=ON -DPYTHON_EXECUTABLE=/c/Python3/python -G"Visual Studio 15 2017 Win64"
- cmake .. -DRUN_UNIT_TEST=ON -DPYTHON_EXECUTABLE=$(which $PY_CMD) -G"Visual Studio 15 2017 Win64"
- cmake --build . --config Release
- ctest -L system -j 2
- ctest -L regress0 -j 2 # does not work ...
- cd ..
- cp maraboupy/Release/* maraboupy
- $PY_CMD -m pytest maraboupy/test

after_success:
- if [ "$TRAVIS_COMPILER" = "gcc" ]; then
codecov;
lcov --capture --directory . --output-file coverage.info;
lcov --remove coverage.info '/usr/*' '*/tools/*' '*.cc' '*/tests/*' '*Test_*.h' --output-file coverage.info;
lcov --list coverage.info;
bash <(curl -s https://codecov.io/bash) -f coverage.info || echo "Codecov did not collect coverage reports";
fi

before_deploy:
- if [ "$TRAVIS_COMPILER" = "gcc" ]; then
pip install --user -r maraboupy/docs/requirements.txt --progress-bar off;
export PYTHONPATH=$PYTHONPATH:`pwd`;
make -C maraboupy/docs html;
touch maraboupy/docs/_build/html/.nojekyll;
fi

deploy:
provider: pages
skip_cleanup: true
github_token: "$GITHUB_PAGES_DEPLOY_TOKEN"
local_dir: maraboupy/docs/_build/html
on:
branch: master
condition: $TRAVIS_COMPILER = gcc

notifications:
email:
Expand Down
79 changes: 79 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ option(RUN_UNIT_TEST "run unit tests on build" ON)
option(RUN_REGRESS_TEST "run regression tests on build" OFF)
option(RUN_SYSTEM_TEST "run system tests on build" OFF)
option(RUN_MEMORY_TEST "run cxxtest testing with ASAN ON" ON)
option(RUN_PYTHON_TEST "run python API tests if building with python" OFF)
option(ENABLE_GUROBI "Enable use the Gurobi optimizer" OFF)
option(ENABLE_OPENBLAS "Do symbolic bound tighting using blas" ON) # Not available on windows
option(CODE_COVERAGE "add code coverage" OFF) # Available only in debug mode

set(DEFAULT_PYTHON_VERSION "3" CACHE STRING "Default Python version 2/3")
set(PYTHON_VERSIONS_SUPPORTED 2 3)
Expand All @@ -33,9 +37,11 @@ set(REGRESS_DIR "${PROJECT_SOURCE_DIR}/regress")
set(ENGINE_DIR "${SRC_DIR}/engine")
set(PYBIND11_DIR "${TOOLS_DIR}/pybind11-2.3.0")
set(BOOST_DIR "${TOOLS_DIR}/boost_1_68_0")
set(OPENBLAS_DIR "${TOOLS_DIR}/OpenBLAS-0.3.9")
set(COMMON_DIR "${SRC_DIR}/common")
set(BASIS_DIR "${SRC_DIR}/basis_factorization")

set(OPENBLAS_LIB openblas)

set(BIN_DIR "${CMAKE_BINARY_DIR}/bin")

Expand Down Expand Up @@ -64,6 +70,28 @@ if(CTEST_NTHREADS EQUAL 0)
set(CTEST_NTHREADS 1)
endif()

# --------------- set build type ----------------------------
set(BUILD_TYPES Release Debug MinSizeRel RelWithDebInfo)

# Set the default build type to Production
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE
Release CACHE STRING "Options are: Release Debug MinSizeRel RelWithDebInfo" FORCE)
# Provide drop down menu options in cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS ${BUILD_TYPES})
endif()
message(STATUS "Building ${CMAKE_BUILD_TYPE} build")


#-------------------------set code coverage----------------------------------#
# Allow coverage only in debug mode only in gcc
if(CODE_COVERAGE AND CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND CMAKE_BUILD_TYPE MATCHES Debug)
message(STATUS "Building with code coverage")
set(COVERAGE_COMPILER_FLAGS "-g -O0 --coverage" CACHE INTERNAL "")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COVERAGE_COMPILER_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage")
endif()


# We build a static library that is the core of the project, the link it to the
# API's (executable and python at the moment)
Expand Down Expand Up @@ -151,6 +179,40 @@ endif()
set(LIBS_INCLUDES ${Boost_INCLUDE_DIRS})
set(LIBS ${Boost_LIBRARIES})

if (${ENABLE_GUROBI})
message(STATUS "Using Gurobi for LP relaxation for bound tightening")
if (NOT DEFINED GUROBI_DIR)
set(GUROBI_DIR $ENV{GUROBI_HOME})
endif()
add_compile_definitions(ENABLE_GUROBI)

set(GUROBI_LIB1 "gurobi_c++")
set(GUROBI_LIB2 "gurobi90")

add_library(${GUROBI_LIB1} SHARED IMPORTED)
set_target_properties(${GUROBI_LIB1} PROPERTIES IMPORTED_LOCATION ${GUROBI_DIR}/lib/libgurobi_c++.a)
list(APPEND LIBS ${GUROBI_LIB1})
target_include_directories(${GUROBI_LIB1} INTERFACE ${GUROBI_DIR}/include/)

add_library(${GUROBI_LIB2} SHARED IMPORTED)
set_target_properties(${GUROBI_LIB2} PROPERTIES IMPORTED_LOCATION ${GUROBI_DIR}/lib/libgurobi90.so)
list(APPEND LIBS ${GUROBI_LIB2})
target_include_directories(${GUROBI_LIB2} INTERFACE ${GUROBI_DIR}/include/)
endif()

if (${ENABLE_OPENBLAS} AND NOT MSVC)
message(STATUS "using openblas for matrix multiplication")
add_compile_definitions(ENABLE_OPENBLAS)
#OpenBLAS
if(NOT EXISTS "${OPENBLAS_DIR}/installed/lib/libopenblas.a")
execute_process(COMMAND ${TOOLS_DIR}/download_openBLAS.sh)
endif()

add_library(${OPENBLAS_LIB} SHARED IMPORTED)
set_target_properties(${OPENBLAS_LIB} PROPERTIES IMPORTED_LOCATION ${OPENBLAS_DIR}/installed/lib/libopenblas.a)
list(APPEND LIBS ${OPENBLAS_LIB})
target_include_directories(${OPENBLAS_LIB} INTERFACE ${OPENBLAS_DIR}/installed/include)
endif()

# pthread
set(THREADS_PREFER_PTHREAD_FLAG ON)
Expand Down Expand Up @@ -268,6 +330,22 @@ if (NOT ${TESTS_TO_RUN} STREQUAL "")
)
endif()

if (${BUILD_PYTHON} AND ${RUN_PYTHON_TEST})
if (MSVC)
add_custom_command(
TARGET build-tests
POST_BUILD
COMMAND cp ${PYTHON_API_DIR}/Release/* ${PYTHON_API_DIR}
)
endif()

add_custom_command(
TARGET build-tests
POST_BUILD
COMMAND ${PYTHON_EXECUTABLE} -m pytest ${PYTHON_API_DIR}/test
)
endif()

# Add the input parsers
add_custom_target(build_input_parsers)
add_dependencies(build_input_parsers ${MPS_PARSER} ${ACAS_PARSER}
Expand Down Expand Up @@ -296,3 +374,4 @@ set(MARABOU_VERSION 1.0.+)
add_definitions("-DGIT_COMMIT_HASH=\"${GIT_COMMIT_HASH}\"")
add_definitions("-DGIT_BRANCH=\"${GIT_BRANCH}\"")
add_definitions("-DMARABOU_VERSION=\"${MARABOU_VERSION}\"")

19 changes: 16 additions & 3 deletions COPYING
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ affiliations. All rights reserved.

The source code of Marabou is open and available to study, to modify, and to
redistribute original or modified versions; distribution is under the terms of
the modified BSD license (reproduced below). Marabou links against Boost which
is separately licensed under the Boost Software License.
the modified BSD license (reproduced below). Marabou links against multiple
third-party libraries, see details below.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
Expand Down Expand Up @@ -34,4 +34,17 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

----------------------------------------------------------------------
-------------------------------------------------------------------------------
Third-Party Software
-------------------------------------------------------------------------------

The Marabou source code includes third-party software which has its own copyright
and licensing terms, as described below.

Marabou links (by default) against the following libraries:
Boost Boost Software License (https://www.boost.org)
OpenBlas BSD license (https://www.openblas.net)

Marabou can also be linked (however, by default it is not) against the following libraries:
Gurobi (https://www.gurobi.com)

Loading

0 comments on commit 8170038

Please sign in to comment.