Skip to content

Commit

Permalink
Merge pull request #17 from sandialabs/dev
Browse files Browse the repository at this point in the history
Preparing for 1.2.0 release
  • Loading branch information
whart222 authored Jan 5, 2023
2 parents 251ae9c + a567b38 commit 4e3052d
Show file tree
Hide file tree
Showing 171 changed files with 16,783 additions and 9,867 deletions.
43 changes: 6 additions & 37 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ name: Linux Build and Tests
on:
workflow_dispatch:
push:
branches: [ main, dev, public ]
branches: [ main, dev, public, private ]
pull_request:
branches: [ main, dev, public ]
branches: [ main, dev, public, private ]

jobs:

coek-simple-build:
runs-on: ubuntu-latest
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: run cmake
run: |
mkdir build
Expand All @@ -28,12 +28,12 @@ jobs:
runs-on: ubuntu-latest
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: run cmake
run: |
mkdir build
cd build
cmake -Dwith_python=OFF -Dwith_tests=ON ..
cmake -Dwith_python=OFF -Dwith_tests=ON -Dwith_debug=ON ..
- name: build
run: |
cd build
Expand All @@ -42,35 +42,4 @@ jobs:
- name: test
run: |
cd build
make test
coek-build-and-test-with-pycoek:
runs-on: ubuntu-latest
#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 -Dwith_tests=ON ..
- name: build
run: |
cd build
make install_tpls
make
- name: test
run: |
cd build
make test
make test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ _build
/out/build
__pycache__
*egg-info
*.gcov
72 changes: 72 additions & 0 deletions .gitlab-ci.yml
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
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -175,5 +175,6 @@ message("")
message("Configuring Monorepo Packages")
add_subdirectory(lib)
add_subdirectory(test)
add_subdirectory(app)

message("")
17 changes: 17 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,23 @@
Here we list changes of Coek. More detailed information about incremental changes can be found in the
[commit history](https://github.com/sandialabs/coek/commits).

## 1.2

* Added the SubExpression object, which is used to denote
* Revised the mutable_values() and find_vars_and_params() functions to avoid re-evaluating SubExpression objects.
* Added the evaluate_expr() function, which avoids re-evaluating SubExpression objects.
* Fixed errors in the ipopt interface; constraint bounds were not being propigated properly.
* Tests added to confirm a fix in CppAD for expressions of the form 0/f(x).
* Fix bugs with walkers, to ensure that PlusTerm objects are only iterated over their prefix
* Fixing bug in symbolic differentation. Avoid double-counting when computing the in-degree.
* Simplified the operators in the core COEK API classes.
* Adding operators to avoid Variable->Expression coercion, which could happen frequently in practice.
* Reworked sequence operators and extended this functionality to include the incides() function.
* Major edits to use std::shared_ptr rather than explicit reference counting in Coek.
* Added explicit management of variable naming as simple/lazy/eager.
* Performance improvements via RVO.
* Adding graphs to facilitate tracking of performance changes.

## 1.1.1

* Revised build logic documentation.
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,20 @@ optimization modeling.
* [Online Documentation](http://poek.readthedocs.org/en/latest/)
[![Documentation Status](https://readthedocs.org/projects/poek/badge/?version=latest)](http://poek.readthedocs.org/en/latest/)

**pyomo_coek**: Pyomo hybrids that leverage Coek to accelerate common operations.


## Test Utilities

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

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

## Applications

**demos**: Demonstrations that illustrate Coek capabilities.

* [README](app/demos/README.md)

## Installation

Expand Down
7 changes: 7 additions & 0 deletions app/CMakeLists.txt
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)
25 changes: 25 additions & 0 deletions app/demos/CMakeLists.txt
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()

6 changes: 6 additions & 0 deletions app/demos/README.md
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.

85 changes: 85 additions & 0 deletions app/demos/demo1.cpp
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;
}
12 changes: 11 additions & 1 deletion lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,17 @@ else()
message("Ignoring lib/poek")
endif()

message("")
if(${with_python})
message("Configuring lib/pyomo_coek install")
add_custom_target(pip_install_pyomo_coek ALL
COMMAND ${Python_EXECUTABLE} -m pip install -e ${CMAKE_CURRENT_SOURCE_DIR}/pyomo_coek
)
add_dependencies(pip_install_pyomo_coek pip_install_poek)
else()
message("Ignoring lib/pyomo_coek")
endif()

#
# Lib test targets
#
Expand All @@ -88,4 +99,3 @@ endif()
if(${with_docs})
add_custom_target(doc_lib DEPENDS ${lib_doc_targets})
endif()

7 changes: 5 additions & 2 deletions lib/coek/coek/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ SET(sources
ast/visitor_symdiff.cpp
ast/visitor_mutable_values.cpp
ast/visitor_variables.cpp
ast/visitor_eval.cpp
ast/varray.cpp
api/constants.cpp
api/expression.cpp
Expand All @@ -40,7 +41,8 @@ if (CMAKE_CXX_STANDARD GREATER_EQUAL 14)
api/parameter_array.cpp
api/variable_assoc_array.cpp
api/variable_array.cpp
api/component_map.cpp
api/constraint_map.cpp
api/subexpression_map.cpp
)
endif()

Expand Down Expand Up @@ -227,7 +229,8 @@ install(FILES
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/coek/util
)
install(FILES
api/component_map.hpp
api/constraint_map.hpp
api/subexpression_map.hpp
api/constants.hpp
api/constraint.hpp
api/expression.hpp
Expand Down
Loading

0 comments on commit 4e3052d

Please sign in to comment.