-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from sandialabs/dev
Preparing for 1.2.0 release
- Loading branch information
Showing
171 changed files
with
16,783 additions
and
9,867 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,4 @@ _build | |
/out/build | ||
__pycache__ | ||
*egg-info | ||
*.gcov |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
stages: | ||
- pre-check | ||
- build | ||
- test | ||
- process | ||
|
||
variables: | ||
ARTIFACTS_DIR: $ARTIFACTS_DIR | ||
|
||
temporary: | ||
stage: pre-check | ||
script: | ||
- echo $CI_COMMIT_BRANCH | ||
|
||
compile: | ||
stage: build | ||
script: | ||
- pwd | ||
- which python | ||
- mkdir build | ||
- cd build | ||
- cmake | ||
-Dwith_pybind11=ON | ||
-Dwith_cppad=ON | ||
-Dwith_tests=ON | ||
-Dwith_python=ON | ||
-Dwith_gurobi=ON | ||
-DGUROBI_LIBRARY=$GUROBI_LIBRARY/libgurobi95.so | ||
-DGUROBI_INCLUDE_DIRS=$GUROBI_INCLUDE_DIRS | ||
-DGUROBI_CXX_LIBRARY=$GUROBI_LIBRARY/libgurobi_g++5.2.a | ||
-DPYTHON_EXECUTABLE=$PYTHON_EXECUTABLE | ||
-Dwith_compact=OFF | ||
-Dwith_docs=OFF .. | ||
- make install_tpls | ||
- make install | ||
artifacts: | ||
paths: | ||
- build | ||
expire_in: 1 hour | ||
|
||
unit-tests: | ||
stage: test | ||
script: | ||
- pwd | ||
- cd build | ||
- ls | ||
- make test | ||
allow_failure: true | ||
|
||
performance-tests: | ||
stage: test | ||
script: | ||
- cd build | ||
- make coek_solve0 | ||
- make coek_writer | ||
- make gurobi_solve0 | ||
- make gurobi_writer | ||
- cd ../test/aml_comparisons/ | ||
- mkdir build | ||
- cd build | ||
- ../scripts/run bench_coek 3 | ||
- ../scripts/collect | ||
- ../scripts/dog solve0 | ||
- ../scripts/dog writer | ||
- python ../scripts/to_csv.py --dirname ${ARTIFACTS_DIR}${CI_COMMIT_BRANCH} | ||
- python ../scripts/compare.py --artifact_dir=$ARTIFACTS_DIR --branch_name=$CI_COMMIT_BRANCH | ||
artifacts: | ||
expose_as: 'performance-trend' | ||
paths: | ||
- test/aml_comparisons/build/solve0_trend.html | ||
- test/aml_comparisons/build/writer_trend.html | ||
expire_in: 4 weeks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# | ||
# CoekProject application packages | ||
# | ||
|
||
message("") | ||
message("Configuring app/demos build") | ||
add_subdirectory(demos) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
cmake_minimum_required(VERSION 3.12) | ||
PROJECT(demos) | ||
|
||
# | ||
# For now, let's just assume we have C++17 | ||
# | ||
set(CMAKE_CXX_STANDARD 17) | ||
|
||
MESSAGE("-- With Gurobi Solver: ${with_gurobi}") | ||
if(with_gurobi) | ||
find_package(GUROBI) | ||
list(APPEND solver_flags "-DWITH_GUROBI") | ||
endif() | ||
|
||
|
||
include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/..) | ||
|
||
# demo1 | ||
add_executable(demo1 demo1.cpp) | ||
TARGET_LINK_LIBRARIES(demo1 PRIVATE coek::coek) | ||
if (${with_gprof}) | ||
target_compile_options(demo1 PUBLIC "-pg") | ||
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pg") | ||
endif() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# demos | ||
|
||
Demonstrations that illustrate Coek capabilities. | ||
|
||
* demo1: Creates a model for the knapsack problem that is optimized. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
#include <iostream> | ||
#include <string> | ||
#include <vector> | ||
#include <functional> | ||
#include <random> | ||
#include <coek/coek.hpp> | ||
|
||
|
||
coek::Model knapsack(size_t N) | ||
{ | ||
N *= 1000; | ||
double W = N / 10.0; | ||
|
||
std::mt19937 rng(10000); | ||
std::uniform_real_distribution<double> distribution(0, 1); | ||
auto uniform = std::bind(distribution, rng); | ||
|
||
std::vector<double> v(N); | ||
std::vector<double> w(N); | ||
for (size_t n : coek::range(N)) { | ||
v[n] = uniform(); | ||
w[n] = uniform(); | ||
} | ||
|
||
auto model = coek::Model(); | ||
|
||
auto x = coek::variable(N).bounds(0, 1).value(0); | ||
model.add(x); | ||
|
||
// obj | ||
auto obj = coek::expression(); | ||
for (size_t n : coek::range(N)) obj += v[n] * x(n); | ||
model.add_objective(obj); | ||
|
||
// con | ||
auto con = coek::expression(); | ||
for (size_t n : coek::range(N)) con += w[n] * x(n); | ||
model.add(con <= W); | ||
|
||
return model; | ||
} | ||
|
||
|
||
int main(int argc, char* argv[]) | ||
{ | ||
if (argc != 3) { | ||
std::cout << "demo1 <solver> <N>" << std::endl; | ||
return 1; | ||
} | ||
|
||
std::string solver_name = argv[1]; | ||
size_t N = std::stoul(argv[2]); | ||
|
||
auto model = knapsack(N); | ||
|
||
if (solver_name == "gurobi") { | ||
coek::Solver solver; | ||
solver.initialize(solver_name); | ||
if (not solver.available()) { | ||
std::cout << "ERROR - solver '" << solver_name << "' is not available" << std::endl; | ||
std::cout << "MESSAGE - " << solver.error_message() << std::endl; | ||
return 2; | ||
} | ||
//solver.set_option("OutputFlag", debug); | ||
//solver.set_option("TimeLimit", 0.0); | ||
|
||
solver.solve(model); | ||
} | ||
else if (solver_name == "ipopt") { | ||
coek::NLPModel nlpmodel(model, "cppad"); | ||
coek::NLPSolver solver; | ||
solver.initialize(solver_name); | ||
if (not solver.available()) { | ||
std::cout << "ERROR - solver '" << solver_name << "' is not available" << std::endl; | ||
std::cout << "MESSAGE - " << solver.error_message() << std::endl; | ||
return 2; | ||
} | ||
//solver.set_option("max_iter", 1); | ||
//solver.set_option("print_level", 1); | ||
|
||
solver.solve(nlpmodel); | ||
} | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.