Skip to content

equinor/everest-optimizers

Repository files navigation

everest-optimizers

The everest-optimizers repository aims to replace the carolina repository by implementing the two algorithms OPTPP_Q_NEWTON and CONMIN_MFD from Dakota. This removes the need of building Dakota through Carolina every time you need to use these two algorithms. Dakota is huge and quite cumbersome to build, so by replacing this dependency we can gain a lot of time.

Note

History starting from 14cb0a7ef00fa56c19f8a3956785b8c6bdbf2cbd and older were filtered to delete all files/folders under dakota-packages except OPTPP.

Getting Started

CONMIN

To call the CONMIN implementation, we go through the python interface that we have made. Both CONMIN and OPTPP should be called using the minimize() function.

Example:

result = minimize(
    fun=obj,
    x0=x0,
    method="conmin_mfd",
    bounds=bounds,
    constraints=constraints,
    options={"ITMAX": 100},
)

Installation

  1. (Optional) We recommend using a virtual enviroment. This can be created and activated by one of the following approaches:
  • Using uv:
uv venv
source .venv/bin/activate
  • Without uv:
python3 -m venv venv
source venv/bin/activate
  1. Install the project:
pip install .[test]

Alternative installation via Docker

Alternatively, you can use Docker to build and run the project with all dependencies:

# Build the Docker image
docker build -t everest-optimizers .

# Run the container to execute tests
docker run everest-optimizers

This approach automatically sets up all required dependencies and runs the tests in an isolated environment.

Tests

To run tests, execute one of the following commands:

  • Recommended:
pytest tests
  • All tests (this is not recommended as there are existing tests in Trilinos which are not working):
pytest
  • One specific test file:
pytest path/to/your_file.py
  • One specific test in a file:
pytest path/to/your_file.py::name_of_test

If you want to add print statements / see the print statements in the terminal, you should run with the -s:

pytest tests -s

Run pyoptpp tests with address sanitizer on

Configure pyoptpp with address sanitizer

cmake -Bbuild -S. -DDEBUG_MEMORY=1

Build

cmake --build build

Copy the module to the virtual environment. so file might have a slightly different name depending on OS/python version

cp build/src/OPTPP-python/_pyoptpp.cpython-313-x86_64-linux-gnu.so .venv/lib/python3.13/site-packages/everest_optimizers/pyoptpp/_pyoptpp.cpython-313-x86_64-linux-gnu.so

Run the OPTPP tests. The preload should point to your locally installed libasan.so.

LD_PRELOAD=/usr/lib64/libasan.so.8.0.0 pytest "tests/OPTPP" -svvv --cache-clear

Linting and Formatting

Python:

  • We use ruff for python linting. To install ruff, use:
pip install ruff
  • To run ruff, do the following commands:
ruff format .
ruff check --select ALL
  • To only run ruff on a select folder or file, do these commands (example):
ruff format src/
ruff check src/

ruff format src/everest_optimizers_utils/dummy_implementation.py
ruff check src/everest_optimizers_utils/dummy_implementation.py

C++:

  • We use clang-format for c++ formatting. Install clang-format like this:
sudo apt install clang-format
  • To format a c++ or c file (or header file), use
clang-format -i your_file.cpp
  • You can run the following command to format all files in your project!
find . -regex '.*\.\(cpp\|hpp\|cc\|c\|h\)' -exec clang-format -i {} +

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 8