Skip to content

Commit

Permalink
Merge pull request #4 from sandialabs/dev
Browse files Browse the repository at this point in the history
Preparing for 1.1 release
  • Loading branch information
whart222 authored Oct 7, 2022
2 parents 23de021 + 99608f2 commit f96752d
Show file tree
Hide file tree
Showing 2,153 changed files with 36,663 additions and 35,379 deletions.
18 changes: 18 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
BasedOnStyle: Google
AlignTrailingComments: 'true'
AllowAllParametersOfDeclarationOnNextLine: 'false'
AlwaysBreakTemplateDeclarations: 'Yes'
BreakBeforeBraces: Stroustrup
ColumnLimit: 100
ConstructorInitializerAllOnOneLineOrOnePerLine: 'true'
IncludeBlocks: Regroup
IndentPPDirectives: AfterHash
IndentWidth: 4
BreakBeforeBinaryOperators: All
BreakBeforeTernaryOperators: 'true'
IncludeCategories:
- Regex: '.*'
- Priority: 1
SortIncludes: Never
...
33 changes: 21 additions & 12 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ name: Linux Build and Tests
on:
workflow_dispatch:
push:
branches: [ main, dev ]
branches: [ main, dev, public ]
pull_request:
branches: [ main, dev ]
branches: [ main, dev, public ]

jobs:

Expand All @@ -18,7 +18,7 @@ jobs:
run: |
mkdir build
cd build
cmake ../lib/coek
cmake -Dinstall_all_tpls=OFF -Dwith_python=OFF ..
- name: build
run: |
cd build
Expand All @@ -33,35 +33,44 @@ jobs:
run: |
mkdir build
cd build
cmake -Dbuild_all=ON -Dwith_tests=ON ../lib/coek
cmake -Dwith_python=OFF -Dwith_tests=ON ..
- name: build
run: |
cd build
make tpls
make install_tpls
make
- name: test
run: |
cd build
make test
pycoek_pybind11:
coek-build-and-test-with-pycoek:
runs-on: ubuntu-latest
needs: coek-build-and-test-with-tpls
#needs: coek-build-and-test-with-tpls
defaults:
run:
shell: bash -l {0}
steps:
- uses: actions/checkout@v2
- uses: conda-incubator/setup-miniconda@v2
with:
activate-environment: test
python-version: 3.8
auto-activate-base: false
- name: run cmake
run: |
conda activate test
conda install -y pytest pyutilib
mkdir build
cd build
cmake -Dbuild_all=ON ../lib/coek
cmake -Dwith_tests=ON ..
- name: build
run: |
cd build
make tpls
make install_tpls
make
- name: build pycoek_pybind11
- name: test
run: |
cd build
cmake -Dwith_pybind11=ON ../lib/coek
make
make test
175 changes: 175 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
cmake_minimum_required(VERSION 3.12)
project(CoekProject)

set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake;${CMAKE_MODULE_PATH})

#
# GLOBAL INCLUDES
#
find_package(Python COMPONENTS Interpreter Development)
include(Clang-Format)
include(Black-Format)
include(GNUInstallDirs)
include(CheckCXXCompilerFlag)
include(CMakePackageConfigHelpers)

#
# Change the default install directory for the sub-builds, as we will
# seldom have access to nor want to install to /usr/local. This can be
# overridden from the command line via cmake -DCMAKE_INSTALL_PREFIX=...
#
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install"
CACHE PATH
"Top level directory for installation"
FORCE
)
endif()

set(INCLUDE_INSTALL_DIR "include/" CACHE STRING "Where to install headers relative to prefix")
set(LIBRARY_INSTALL_DIR "lib/" CACHE STRING "Where to install libraries relative to prefix")


##################### TPL Configuration #####################
#
# Installation options for TPLs define default values of configuration options.
#
message("")
add_subdirectory(tpl)

add_custom_target(install_tpls
DEPENDS _install_tpls
COMMAND ${CMAKE_COMMAND} -Dwith_pybind11=ON -Dwith_catch2=ON -Dwith_fmtlib=ON -Dwith_cppad=ON -Dwith_rapidjson=ON ${PROJECT_SOURCE_DIR}
)
add_custom_target(install_tpl
DEPENDS _install_tpls
COMMAND ${CMAKE_COMMAND} -Dwith_pybind11=ON -Dwith_catch2=ON -Dwith_fmtlib=ON -Dwith_cppad=ON -Dwith_rapidjson=ON ${PROJECT_SOURCE_DIR}
)

##################### Options #####################

option(build_shared_libs "Build a shared library" ON)

# Build options
option(with_debug "Debug build" OFF)
option(with_verbose "Verbose build" OFF)
option(with_gcov "Add code coverage using gcov" OFF)
option(with_gprof "Profile build" OFF)
option(with_caliper "Use the Caliper library" OFF)
# Monorepo configuration
option(with_tests "Build tests" OFF)
option(with_docs "Build documentation" OFF)
option(with_python "Build/Install Python libs" ${Python_FOUND})

message("Initial Configuration Options")
# Options defined here
message("-- with_debug: ${with_debug}")
message("-- with_verbose: ${with_verbose}")
message("-- with_gcov: ${with_gcov}")
message("-- with_gprof: ${with_gprof}")
message("-- with_caliper: ${with_caliper}")
message("-- with_tests: ${with_tests}")
message("-- with_docs: ${with_docs}")
message("-- with_python: ${with_python}")
# Options defined in tpl
message("-- with_catch2: ${with_catch2}")
message("-- with_cppad: ${with_cppad}")
message("-- with_pybind11: ${with_pybind11}")
message("-- with_cppyy: ${with_cppyy}")
message("-- with_rapidjson: ${with_rapidjson}")
message("-- with_fmtlib: ${with_fmtlib}")

##################### Checks for compiler #####################

message("Revised Configuration Options")
if(with_compact)
CHECK_CXX_COMPILER_FLAG("-std=c++17" COMPILER_SUPPORTS_CXX17)
set(CMAKE_CXX_STANDARD 17)

if(COMPILER_SUPPORTS_CXX17)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
else()
# TODO: Verify these minimum requirements
message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++17 support. Please use a different C++ compiler.")
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.1)
message(FATAL_ERROR "CLANG version must be at least 3.1!")
endif()
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7)
message(FATAL_ERROR "GCC version must be at least 4.7!")
endif()
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 12.0)
message(FATAL_ERROR "ICC version must be at least 12.0!")
endif()
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 12.0)
message(FATAL_ERROR "MSVC version must be at least 12.0!")
endif()
endif()
endif()
MESSAGE("-- C++ version: C++17")
elseif(NOT "${CMAKE_CXX_STANDARD}")
CHECK_CXX_COMPILER_FLAG("-std=c++17" COMPILER_SUPPORTS_CXX17)
set(CMAKE_CXX_STANDARD 17)
MESSAGE("-- C++ version: C++17")
else()
MESSAGE("-- C++ version: C++${CMAKE_CXX_STANDARD}")
endif()

if (with_gcov)
if (CMAKE_CXX_COMPILER_ID MATCHES GNU)
else()
set(with_gcov OFF)
endif()
endif()
MESSAGE("-- With gcov: ${with_gcov}")
if (with_tests)
find_package(gcovr)
if (gcovr_FOUND)
MESSAGE("-- With gcovr: ON")
else()
MESSAGE("-- With gcovr: OFF")
endif()
endif()

message("-- With debug: ${with_debug}")
message("-- With gprof: ${with_gprof}")
message("-- With staticlib: ${with_staticlib}")

if(${with_gcov})
set(CMAKE_BUILD_TYPE debug)
endif()

if(${with_verbose})
set(CMAKE_VERBOSE_MAKEFILE ON)
endif()
if(${with_debug})
set(CMAKE_BUILD_TYPE debug)
if (MSVC)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /Wall /DDEBUG /permissive-")
else()
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -DDEBUG")
endif()
else()
if (MSVC)
set(CMAKE_CXX_FLAGS_RELEASE "/permissive-")
endif()
endif()

if(${with_tests})
#include(CTest)
add_custom_target(test DEPENDS test_lib)
endif()


##################### Monorepo Subpackages #####################

message("")

message("Configuring Monorepo Packages")
add_subdirectory(lib)
add_subdirectory(test)

message("")
84 changes: 78 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,96 @@ contains the C++ Coek library, along with related C++ and Python libraries
that support fast interfaces to large, complex optimization applications.
Although the existing APIs for Coek and other libraries are stable,
these capabilities are expected to evolve significantly in response to
targetted experiments that demonstrate new strategies
for performant optimization modeling.
targetted experiments that demonstrate new strategies for performant
optimization modeling.


## Libraries

**Coek**: A fast C++ library that supports the definition of expressions used to formulate and solve optimization problems.

* [README](lib/coek/README.md)
* [Online Documentation](http://coek.readthedocs.org/en/latest/)

**Poek**: A performant Python library that supports the definition of expressions used to formulate and solve optimization problems.
**pycoek**: A library of Python bindings for Coek.

* [README](lib/poek/README.md)
**Poek**: A performant Python library that supports the definition of expressions used to formulate and solve optimization problems.


## Test Utilities

**aml_comparisons**: Performance tests for Coek, Poek and related optimization modeling environmants.
**aml_comparisons**: Performance tests for Coek, Poek and related optimization modeling environments.

* [README](test/aml_comparisons/README.md)


## Installation

### Simple Build

The Coek Project uses CMake to manage configuration of the build:

* mkdir build
* cd build
* cmake ..

The default installation directory is set to **build/install**.
Coek relies on a variety of third-party libraries, and CMake is setup to
automatically download, install and configure the use of these libraries:

* make install\_tpls

Third-party packages are installed in the installation directory.
This uses a CMAKE superbuild process that requires multiple executions
of the **make** command.

The default build logic for Coek is executed using `make`:

* make

By default, this does the following:

1. Build the Coek library.
* If third-party libraries are automatically installed, this includes support for automatic differentiation using CppAD.
1. Build and install pycoek extensions.
* If third-party libraries are automatically installed, this includes support for pybind11 extensions.
1. Install the Poek library in `editable` mode.
1. Build the aml\_comparisons performance testing utilities.

### Build with Tests

* mkdir build
* cd build
* cmake -Dwith\_tests=ON ..
* make intall_tpls
* make
* make test # Test all libraries
* make test_coek # Test the Coek library
* make test_poek # Test the Poek library

### Download and build TPLs with curl insecure flags

* mkdir build
* cd build
* cmake -Dinsecure\_downloads=ON ..
* make install_tpls
* make

### Build with Gurobi

* mkdir build
* cd build
* cmake -Dwith\_gurobi=ON ..
* make install_tpls
* make

### Reformat code

* mkdir build
* cd build
* cmake ..
* make install_tpls
* make format-cpp-check # Show C++ files that would be reformatted with clang-format
* make format-cpp # Reformat C++ files with clang-format
* make format-py-check # Show Python files that would be reformatted with black
* make format-py # Reformat Python files with black

Loading

0 comments on commit f96752d

Please sign in to comment.