├── src ├── _Internals │ ├── hsl_ma86z.hpp │ └── hsl_mc69z.hpp ├── LinAlg │ ├── hiopMatrixSparseTripletStorage.cpp │ ├── ReSolve │ │ ├── CMakeLists.txt │ │ ├── MatrixCsr.hpp │ │ └── KrylovSolverKernels.h │ ├── hiopVectorRajaOmp.cpp │ ├── csr_iajaaa.md │ ├── hiopMatrixMDS.cpp │ ├── load_kkt_mat.m │ ├── hiopVectorIntRajaOmp.cpp │ ├── hiopMatrixDenseRajaOmp.cpp │ ├── hiopVectorIntRajaHip.cpp │ ├── hiopVectorIntRajaCuda.cpp │ ├── hiopMatrixDenseRajaHip.cpp │ └── hiopMatrixDenseRajaCuda.cpp ├── Drivers │ ├── IpoptAdapter │ │ ├── CMakeLists.txt │ │ ├── IpoptAdapter_driver.cpp │ │ ├── IpoptAdapterDriverPriDecEx1.cpp │ │ └── IpoptAdapterDriverPriDecEx2.cpp │ ├── hiopbbpy │ │ ├── yopt_20iter_1000run.npy │ │ ├── EvaluationManagerCI.py │ │ └── BODriverEX.py │ ├── CMakeLists.txt │ ├── PriDec │ │ ├── CMakeLists.txt │ │ ├── NlpPriDecEx3SparseDriver.cpp │ │ └── NlpPriDecEx2UserBasecase.hpp │ ├── Dense │ │ ├── NlpDenseConsEx4Driver.cpp │ │ └── CMakeLists.txt │ ├── MDS │ │ ├── hpc_benchmark.cpp │ │ ├── hpc_multisolves.cpp │ │ └── CMakeLists.txt │ └── Sparse │ │ ├── NlpSparseEx4.hpp │ │ ├── NlpSparseEx1.hpp │ │ └── NlpSparseEx3.hpp ├── hiopbbpy │ ├── __init__.py │ ├── surrogate_modeling │ │ ├── __init__.py │ │ ├── krg.py │ │ └── gp.py │ ├── utils │ │ └── __init__.py │ ├── problems │ │ ├── __init__.py │ │ ├── LpNormProblem.py │ │ └── BraninProblem.py │ └── opt │ │ ├── __init__.py │ │ └── optproblem.py ├── ExecBackends │ └── CMakeLists.txt ├── Interface │ ├── CMakeLists.txt │ ├── hiop_types.h │ ├── hiop_defs.hpp.in │ ├── hiopVersion.hpp │ └── README.md ├── CMakeLists.txt ├── Optimization │ ├── CMakeLists.txt │ └── hiopFilter.cpp └── Utils │ ├── CMakeLists.txt │ ├── hiopCppStdUtils.hpp │ ├── hiopMPI.hpp │ ├── hiopKronReduction.cpp │ ├── MathKernelsHost.hpp │ └── RajaUmpireUtils.hpp ├── doc ├── hiop_examples.pdf ├── hiop_implpaper.pdf ├── hiop_usermanual.pdf ├── pridec_implpaper.pdf ├── README.md └── src │ └── hiop.bib ├── SUPPORT.md ├── .gitmodules ├── pyproject.toml ├── .gitignore ├── cmake ├── FindHiopGINKGO.cmake ├── FindValgrind.cmake ├── FindHiopPARDISO.cmake ├── FindHiopCudaLibraries.cmake ├── FindHiopSTRUMPACK.cmake ├── FindHiopMagma.cmake ├── HiOpDoxygenConfig.cmake ├── FindHiopMETIS.cmake ├── FindKLU.cmake ├── FindHiopCOINHSL.cmake ├── FindUMFPACK.cmake ├── HiOpCheckGitSubmodules.cmake ├── FindHiopHipLibraries.cmake └── HiOpConfig.cmake.in ├── scripts ├── findIdleDLNodes.pl ├── clang-hip.cmake ├── defaultBuild.sh ├── inclineVariables.sh ├── gcc-cpu.cmake ├── gcc-cuda.cmake ├── platforms │ ├── lassen │ │ └── spack.yaml │ ├── newell │ │ └── spack.yaml │ ├── marianas │ │ └── spack.yaml │ └── summit │ │ └── spack.yaml ├── summitVariables.sh └── quartzVariables.sh ├── .github ├── push_mirror.yml └── workflows │ ├── test.yml │ └── test_hiopbbpy.yml ├── setup.py ├── tests ├── testMDS1CompareIterations.awk ├── CMakeLists.txt └── LinAlg │ ├── vectorTestsIntSeq.hpp │ └── vectorTestsIntRaja.hpp ├── .gitlab └── ornl-ci.yml ├── LICENSE ├── COPYRIGHT ├── README_summit.md └── BUILD.sh /src/_Internals/hsl_ma86z.hpp: -------------------------------------------------------------------------------- 1 | #define HSL_MA86Z_HEADER_NOT_CPP_READY 1 2 | -------------------------------------------------------------------------------- /src/_Internals/hsl_mc69z.hpp: -------------------------------------------------------------------------------- 1 | #define HSL_MC69Z_HEADER_NOT_CPP_READY 1 2 | -------------------------------------------------------------------------------- /doc/hiop_examples.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/llnl/hiop/HEAD/doc/hiop_examples.pdf -------------------------------------------------------------------------------- /doc/hiop_implpaper.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/llnl/hiop/HEAD/doc/hiop_implpaper.pdf -------------------------------------------------------------------------------- /doc/hiop_usermanual.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/llnl/hiop/HEAD/doc/hiop_usermanual.pdf -------------------------------------------------------------------------------- /doc/pridec_implpaper.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/llnl/hiop/HEAD/doc/pridec_implpaper.pdf -------------------------------------------------------------------------------- /src/LinAlg/hiopMatrixSparseTripletStorage.cpp: -------------------------------------------------------------------------------- 1 | #include "hiopMatrixSparseTripletStorage.hpp" 2 | -------------------------------------------------------------------------------- /SUPPORT.md: -------------------------------------------------------------------------------- 1 | [Please open issues on HiOp's GitHub page for support.](https://github.com/LLNL/hiop/issues) 2 | -------------------------------------------------------------------------------- /src/Drivers/IpoptAdapter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | install( 2 | FILES IpoptAdapter.hpp 3 | DESTINATION include 4 | ) -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "tpl/eigen"] 2 | path = tpl/eigen 3 | url = https://gitlab.com/libeigen/eigen.git 4 | 5 | -------------------------------------------------------------------------------- /src/hiopbbpy/__init__.py: -------------------------------------------------------------------------------- 1 | __all__ = [ 2 | "problems", 3 | "surrogate_modeling", 4 | "opt", 5 | "utils"] 6 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = ["setuptools", "wheel", "numpy", "smt"] 3 | build-backend = "setuptools.build_meta" 4 | -------------------------------------------------------------------------------- /src/Drivers/hiopbbpy/yopt_20iter_1000run.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/llnl/hiop/HEAD/src/Drivers/hiopbbpy/yopt_20iter_1000run.npy -------------------------------------------------------------------------------- /src/hiopbbpy/surrogate_modeling/__init__.py: -------------------------------------------------------------------------------- 1 | from .gp import GaussianProcess 2 | from .krg import smtKRG 3 | __all__ = [ 4 | "GaussianProcess" 5 | "smtKRG" 6 | ] 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore files that are generated from the repository sources 2 | build 3 | build_* 4 | .vscode 5 | .DS_Store 6 | _dist-default-build 7 | _dist-DEBUG 8 | *hiopbbpy.egg-info 9 | *__pycache__ 10 | -------------------------------------------------------------------------------- /src/hiopbbpy/utils/__init__.py: -------------------------------------------------------------------------------- 1 | from .evaluation_manager import (EvaluationManager, is_running_with_mpi) 2 | from .util import Evaluator, MPIEvaluator 3 | 4 | __all__ = [ 5 | "util" 6 | "evaluation_manager" 7 | ] 8 | -------------------------------------------------------------------------------- /src/Drivers/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Create examples and tests 2 | add_subdirectory(Dense) 3 | if(HIOP_SPARSE) 4 | add_subdirectory(Sparse) 5 | endif() 6 | add_subdirectory(MDS) 7 | add_subdirectory(PriDec) 8 | add_subdirectory(IpoptAdapter) 9 | -------------------------------------------------------------------------------- /src/hiopbbpy/problems/__init__.py: -------------------------------------------------------------------------------- 1 | from .problem import Problem 2 | from .BraninProblem import BraninProblem 3 | from .LpNormProblem import LpNormProblem 4 | 5 | __all__ = [ 6 | "Problem" 7 | "BraninProblem" 8 | "LpNormProblem" 9 | ] 10 | 11 | -------------------------------------------------------------------------------- /cmake/FindHiopGINKGO.cmake: -------------------------------------------------------------------------------- 1 | 2 | #[[ 3 | 4 | Exports target `GINKGO` 5 | 6 | Users may set the following variables: 7 | 8 | - HIOP_GINKGO_DIR 9 | 10 | ]] 11 | 12 | find_package(Ginkgo CONFIG 13 | PATHS ${GINKGO_DIR} ${HIOP_GINKGO_DIR} 14 | REQUIRED) 15 | 16 | -------------------------------------------------------------------------------- /src/hiopbbpy/opt/__init__.py: -------------------------------------------------------------------------------- 1 | from .boalgorithm import (BOAlgorithmBase, BOAlgorithm) 2 | from .acquisition import (acquisition, LCBacquisition, EIacquisition) 3 | from .optproblem import (IpoptProb) 4 | 5 | __all__ = [ 6 | "BOAlgorithmBase" 7 | "BOAlgorithm" 8 | "acquisition" 9 | "LCBacquisition" 10 | "EIacquisition" 11 | "IpoptProb" 12 | ] 13 | -------------------------------------------------------------------------------- /src/ExecBackends/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Set headers to be installed as part of the hiop interface 2 | set(hiopExecBackends_INTERFACE_HEADERS 3 | ExecSpace.hpp 4 | ExecPoliciesRajaCudaImpl.hpp 5 | ExecPoliciesRajaHipImpl.hpp 6 | ExecPoliciesRajaOmpImpl.hpp 7 | MemBackendCppImpl.hpp 8 | MemBackendCudaImpl.hpp 9 | MemBackendHipImpl.hpp 10 | MemBackendUmpireImpl.hpp 11 | ) 12 | 13 | install(FILES ${hiopExecBackends_INTERFACE_HEADERS} DESTINATION include) 14 | -------------------------------------------------------------------------------- /scripts/findIdleDLNodes.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | 3 | use warnings; 4 | use strict; 5 | use feature 'say'; 6 | 7 | # All DL partitions 8 | my @partitions = grep /^dl/, `sinfo`; 9 | 10 | # Idle nodes 11 | my @idle_parts = grep /idle/, @partitions; 12 | 13 | if (scalar @idle_parts eq 0) { 14 | # No idle dl parititons... Just choose the shared one. 15 | print "dl_shared"; 16 | } else { 17 | my @parts = split / /, $idle_parts[0]; 18 | print $parts[0]; 19 | } 20 | -------------------------------------------------------------------------------- /doc/README.md: -------------------------------------------------------------------------------- 1 | # HiOp Documentation 2 | 3 | HiOp's [user manual](hiop_usermanual.pdf) provides instructions on how to obtain and build HiOp and a description of 4 | its interface, user options, and use as an optimization library. Guidelines on how is best to use 5 | the solver for parallel computations are also provided. 6 | 7 | The mathematical approach, computational techniques, and parallelization strategies can be found in the 8 | journal publications listed in the root [readme](../README.md) file. -------------------------------------------------------------------------------- /src/Interface/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if(HIOP_BUILD_SHARED) 2 | set(hiopInterface_SRC 3 | hiopInterfacePrimalDecomp.cpp 4 | chiopInterface.cpp 5 | hiopFortranInterface.c 6 | ) 7 | else() 8 | set(hiopInterface_SRC 9 | hiopInterfacePrimalDecomp.cpp 10 | ) 11 | endif() 12 | 13 | set(hiopInterface_INTERFACE_HEADERS 14 | chiopInterface.hpp 15 | hiopInterface.h 16 | hiopInterface.hpp 17 | hiopInterfacePrimalDecomp.hpp 18 | hiopVersion.hpp 19 | hiop_types.h 20 | hiopFortranInterface.h 21 | ) 22 | 23 | install( 24 | FILES ${hiopInterface_INTERFACE_HEADERS} 25 | DESTINATION include 26 | ) 27 | 28 | add_library(hiopInterface OBJECT ${hiopInterface_SRC}) 29 | -------------------------------------------------------------------------------- /src/hiopbbpy/problems/LpNormProblem.py: -------------------------------------------------------------------------------- 1 | """ 2 | Implementation of the LPNorm problem class f(x) = || x ||_p 3 | 4 | Authors: Tucker Hartland 5 | Nai-Yuan Chiang 6 | """ 7 | import numpy as np 8 | from hiopbbpy.problems.problem import Problem 9 | 10 | class LpNormProblem(Problem): 11 | def __init__(self, ndim, xlimits, p=2.0, constraints=[]): 12 | name = "LpNormProblem" 13 | super().__init__(ndim, xlimits, name=name, constraints=constraints) 14 | self.p = p 15 | 16 | def _evaluate(self, x): 17 | ne, nx = x.shape 18 | assert nx == self.ndim 19 | y = np.atleast_2d(np.linalg.norm(x, ord=self.p, axis=1)).T 20 | return y 21 | -------------------------------------------------------------------------------- /scripts/clang-hip.cmake: -------------------------------------------------------------------------------- 1 | #[[ 2 | 3 | Default CMake cache for building in CI on AMDGPU platforms 4 | 5 | #]] 6 | set(HIOP_BUILD_SHARED OFF CACHE BOOL "") 7 | set(HIOP_BUILD_STATIC ON CACHE BOOL "") 8 | set(ENABLE_TESTS ON CACHE BOOL "") 9 | set(HIOP_USE_MPI ON CACHE BOOL "") 10 | set(HIOP_USE_RAJA ON CACHE BOOL "") 11 | set(HIOP_USE_UMPIRE ON CACHE BOOL "") 12 | set(HIOP_USE_GPU ON CACHE BOOL "") 13 | set(HIOP_USE_CUDA OFF CACHE BOOL "") 14 | set(HIOP_USE_HIP ON CACHE BOOL "") 15 | set(HIOP_SPARSE OFF CACHE BOOL "") 16 | set(HIOP_DEEPCHECKS ON CACHE BOOL "") 17 | set(AMDGPU_TARGETS "gfx908" CACHE STRING "") 18 | set(GPU_TARGETS "gfx908" CACHE STRING "") 19 | set(CMAKE_HIP_ARCHITECTURES "gfx908" CACHE STRING "") 20 | -------------------------------------------------------------------------------- /src/LinAlg/ReSolve/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Build ReSolve library 2 | 3 | set(ReSolve_SRC 4 | #hiopLinSolverSparseReSolve.cpp 5 | RefactorizationSolver.cpp 6 | MatrixCsr.cpp 7 | IterativeRefinement.cpp 8 | KrylovSolverKernels.cu 9 | ) 10 | set(ReSolve_HEADERS 11 | RefactorizationSolver.hpp 12 | MatrixCsr.hpp 13 | IterativeRefinement.hpp 14 | ) 15 | 16 | set_source_files_properties(${ReSolve_SRC} PROPERTIES LANGUAGE CUDA) 17 | 18 | add_library(ReSolve STATIC ${ReSolve_SRC}) 19 | target_include_directories(ReSolve INTERFACE $) 20 | # Eventually, we will: 21 | # find_package(ReSolve REQUIRED) 22 | # target_link_libraries(hiop_tpl INTERFACE ReSolve) 23 | target_link_libraries(ReSolve PRIVATE KLU hiop_cuda) 24 | -------------------------------------------------------------------------------- /src/Interface/hiop_types.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * This header defines a couple of types used by HiOp. 4 | * 5 | * This header is shared by both C and C++ interfaces of HiOp and this is 6 | * the only place where these types should/need to be modified. 7 | */ 8 | 9 | // 10 | // int types 11 | // 12 | typedef int hiop_index_type; 13 | typedef int hiop_size_type; 14 | #ifdef HIOP_USE_MPI 15 | #include "mpi.h" 16 | // MPI_Datatype corresponding to the above types should be specified below 17 | #define MPI_HIOP_INDEX_TYPE MPI_INT 18 | #define MPI_HIOP_SIZE_TYPE MPI_INT 19 | #endif 20 | 21 | // 22 | // Same types as above but in C++ 23 | // 24 | #ifdef __cplusplus 25 | namespace hiop 26 | { 27 | using index_type = hiop_index_type; 28 | using size_type = hiop_size_type; 29 | } 30 | #endif 31 | -------------------------------------------------------------------------------- /scripts/defaultBuild.sh: -------------------------------------------------------------------------------- 1 | # Attempts to build with all options enabled. This is the default build for 2 | # continuous integration 3 | 4 | defaultBuild() 5 | { 6 | if [[ "$BUILD" == "1" ]]; then 7 | if [[ -f $BUILDDIR/CMakeCache.txt ]]; then 8 | rm -f $BUILDDIR/CMakeCache.txt || exit 1 9 | fi 10 | mkdir -p $BUILDDIR || exit 1 11 | echo 12 | echo Build step 13 | echo 14 | local SRCDIR=$PWD 15 | pushd $BUILDDIR || exit 1 16 | eval "cmake -C $SRCDIR/scripts/$CMAKE_CACHE_SCRIPT $EXTRA_CMAKE_ARGS .." || exit 1 17 | $MAKE_CMD || exit 1 18 | popd 19 | fi 20 | 21 | if [[ "$TEST" == "1" ]]; then 22 | echo 23 | echo Testing step 24 | echo 25 | 26 | pushd $BUILDDIR || exit 1 27 | $CTEST_CMD || exit 1 28 | popd 29 | fi 30 | } 31 | -------------------------------------------------------------------------------- /src/Interface/hiop_defs.hpp.in: -------------------------------------------------------------------------------- 1 | #cmakedefine HIOP_USE_GPU 2 | #cmakedefine HIOP_USE_CUDA 3 | #cmakedefine HIOP_USE_HIP 4 | #cmakedefine HIOP_USE_MPI 5 | #cmakedefine HIOP_USE_MAGMA 6 | #cmakedefine HIOP_USE_RAJA 7 | #cmakedefine HIOP_USE_EIGEN 8 | #cmakedefine HIOP_DEEPCHECKS 9 | #cmakedefine HIOP_SPARSE 10 | #cmakedefine HIOP_USE_COINHSL 11 | #cmakedefine HIOP_USE_STRUMPACK 12 | #cmakedefine HIOP_USE_PARDISO 13 | #cmakedefine HIOP_USE_RESOLVE 14 | #cmakedefine HIOP_USE_GINKGO 15 | #cmakedefine HIOP_USE_AXOM 16 | #define HIOP_VERSION "@PROJECT_VERSION@" 17 | #define HIOP_VERSION_MAJOR @PROJECT_VERSION_MAJOR@ 18 | #define HIOP_VERSION_MINOR @PROJECT_VERSION_MINOR@ 19 | #define HIOP_VERSION_PATCH @PROJECT_VERSION_PATCH@ 20 | 21 | /// Date of build with the format "%Y-%m-%d" 22 | #define HIOP_RELEASE_DATE "@HIOP_RELEASE_DATE@" 23 | 24 | #include "hiop_types.h" 25 | -------------------------------------------------------------------------------- /cmake/FindValgrind.cmake: -------------------------------------------------------------------------------- 1 | #[[ 2 | 3 | If enabled, looks for `valgrind` executable and enables select tests to run 4 | with valgrind. 5 | 6 | Users may set the following variables: 7 | 8 | - HIOP_VALGRIND_EXE 9 | 10 | ]] 11 | 12 | set(HIOP_VALGRIND_EXE "" CACHE PATH "Path to valgrind executable for memcheck tests.") 13 | 14 | if(HIOP_WITH_VALGRIND_TESTS) 15 | find_program(VALGRIND 16 | NAMES "valgrind" 17 | HINTS ${HIOP_VALGRIND_EXE} 18 | ) 19 | if(NOT VALGRIND) 20 | message(STATUS "HIOP_WITH_VALGRIND_TESTS is enabled, but valgrind could " 21 | "not be found. Disabling valgrind tests.") 22 | set(HIOP_WITH_VALGRIND_TESTS OFF) 23 | else(NOT VALGRIND) 24 | set(HIOP_VALGRIND_CMD "${VALGRIND} --error-exitcode=1" 25 | CACHE STRING 26 | "Command used to invoke valgrind by HiOp test suite" 27 | ) 28 | message(STATUS "Found valgrind: ${VALGRIND}") 29 | endif(NOT VALGRIND) 30 | endif(HIOP_WITH_VALGRIND_TESTS) 31 | -------------------------------------------------------------------------------- /cmake/FindHiopPARDISO.cmake: -------------------------------------------------------------------------------- 1 | 2 | #[[ 3 | 4 | Exports target `STRUMPACK` 5 | 6 | Users may set the following variables: 7 | 8 | - HIOP_PARDISO_DIR 9 | 10 | ]] 11 | 12 | find_library(PARDISO_LIBRARY 13 | NAMES 14 | pardiso 15 | PATHS 16 | ${PARDISO_DIR} $ENV{PARDISO_DIR} ${HIOP_PARDISO_DIR} 17 | ENV LD_LIBRARY_PATH ENV DYLD_LIBRARY_PATH 18 | PATH_SUFFIXES 19 | lib64 lib) 20 | 21 | if(PARDISO_LIBRARY) 22 | get_filename_component(PARDISO_LIBRARY_DIR ${PARDISO_LIBRARY} DIRECTORY) 23 | endif() 24 | 25 | if(PARDISO_LIBRARY) 26 | message(STATUS "Found PARDISO library: ${PARDISO_LIBRARY}") 27 | add_library(PARDISO INTERFACE) 28 | target_link_libraries(PARDISO INTERFACE ${PARDISO_LIBRARY}) 29 | message(STATUS "Found PARDISO library: ${PARDISO_LIBRARY}") 30 | install(TARGETS PARDISO EXPORT hiop-targets) 31 | else() 32 | message(STATUS "PARDISO was not found.") 33 | endif() 34 | 35 | set(METIS_LIBRARY CACHE PATH "Path to PARDISO library") 36 | 37 | 38 | -------------------------------------------------------------------------------- /.github/push_mirror.yml: -------------------------------------------------------------------------------- 1 | #name: Push Mirror 2 | 3 | #on: [push, delete] 4 | 5 | #jobs: 6 | # PNNL_GitLab: 7 | # runs-on: ubuntu-22.04 8 | # steps: 9 | # - uses: actions/checkout@v1 10 | # - uses: spyoungtech/mirror-action@master 11 | # with: 12 | # REMOTE: ${{ secrets.GIT_REPO_URL }} 13 | # GIT_USERNAME: ${{ secrets.GIT_USER }} 14 | # GIT_PASSWORD: ${{ secrets.GIT_PASSWORD }} 15 | # GIT_PUSH_ARGS: --push-option=ci.skip --tags --force --prune 16 | # - uses: nelonoel/branch-name@v1.0.1 17 | # - name: Trigger Pipeline 18 | # run: | 19 | # response=$(curl -X POST -F token=${{ secrets.PNNL_PIPELINE_TRIGGER_TOKEN }} -F ref=${BRANCH_NAME} https://gitlab.pnnl.gov/api/v4/projects/769/trigger/pipeline) 20 | # exit_code=$? 21 | # sudo apt install jq 22 | # pipeline_id=$(echo $response | jq '.id' | sed 's/"//g') 23 | # echo "PIPELINE_ID=${pipeline_id}" >> $GITHUB_ENV 24 | # exit $exit_code 25 | -------------------------------------------------------------------------------- /scripts/inclineVariables.sh: -------------------------------------------------------------------------------- 1 | # NOTE: The following is required when running from Gitlab CI via slurm job 2 | source /etc/profile.d/modules.sh 3 | module use -a /usr/share/Modules/modulefiles 4 | module use -a /share/apps/modules/tools 5 | module use -a /share/apps/modules/compilers 6 | module use -a /share/apps/modules/mpi 7 | module use -a /etc/modulefiles 8 | 9 | module load rocm/4.5.1 10 | module load umpire/6.0.0 11 | module load raja/0.14.0 12 | module load gcc/8.4.0 13 | module load openblas/0.3.18 14 | module load cmake/3.19.6 15 | module load magma/2.6.1 16 | 17 | export LD_LIBRARY_PATH=/share/apps/openmpi/4.1.1/gcc/8.1.0/lib 18 | export PATH=/share/apps/openmpi/4.1.1/gcc/8.1.0/bin:$PATH 19 | 20 | # For some reason, OS libstdc++ keeps being found before GCC 8.4.0, so we have 21 | # to force this link directory. GCC 4.8.5 is far too old... 22 | export EXTRA_CMAKE_ARGS="-DHIOP_EXTRA_LINK_FLAGS=-L/share/apps/gcc/8.4.0/lib64;-Wl,-rpath,/share/apps/gcc/8.4.0/lib64" 23 | export CMAKE_CACHE_SCRIPT=clang-hip.cmake 24 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | ''' 2 | This is the setup file for installing HiOpBBpy 3 | 4 | Authors: Tucker Hartland 5 | Nai-Yuan Chiang 6 | ''' 7 | 8 | import sys 9 | import os 10 | import numpy as np 11 | from setuptools import setup, find_packages 12 | 13 | 14 | install_requires = ["smt"] 15 | 16 | if os.getenv("ADD_CYIPOPT", "0") == "1": 17 | install_requires.append("cyipopt") 18 | 19 | metadata = dict( 20 | name="hiopbbpy", 21 | version="1.2.0", 22 | description="HiOp black box optimization (HiOpBBpy)", 23 | author="Tucker hartland et al.", 24 | author_email="hartland1@llnl.gov", 25 | license="BSD-3", 26 | packages=find_packages(where="src"), 27 | package_dir={"": "src"}, 28 | install_requires=install_requires, 29 | python_requires=">=3.9", 30 | zip_safe=False, 31 | url="https://github.com/LLNL/hiop", 32 | download_url="https://github.com/LLNL/hiop", 33 | ) 34 | 35 | setup(**metadata) 36 | -------------------------------------------------------------------------------- /cmake/FindHiopCudaLibraries.cmake: -------------------------------------------------------------------------------- 1 | 2 | #[[ 3 | 4 | Exports target `hiop_cuda` which finds all cuda libraries needed by hiop. 5 | 6 | ]] 7 | 8 | add_library(hiop_cuda INTERFACE) 9 | 10 | find_package(CUDAToolkit REQUIRED) 11 | 12 | if(HIOP_BUILD_SHARED) 13 | target_link_libraries(hiop_cuda INTERFACE 14 | CUDA::cusolver 15 | CUDA::cusparse 16 | CUDA::cudart 17 | CUDA::cublasLt 18 | CUDA::curand 19 | ) 20 | endif() 21 | if(HIOP_BUILD_STATIC) 22 | target_link_libraries(hiop_cuda INTERFACE 23 | CUDA::cusolver_static 24 | CUDA::cusparse_static 25 | CUDA::cudart_static 26 | CUDA::cublasLt_static 27 | CUDA::curand_static 28 | CUDA::culibos 29 | ) 30 | endif() 31 | 32 | install(TARGETS hiop_cuda EXPORT hiop-targets) 33 | 34 | message(STATUS "HiOp support for GPUs is on") 35 | message(STATUS "CUDA include directories: ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}") 36 | get_target_property(cuda_libraries hiop_cuda INTERFACE_LINK_LIBRARIES) 37 | message(STATUS "CUDA linked libraries: ${cuda_libraries}") 38 | 39 | -------------------------------------------------------------------------------- /scripts/gcc-cpu.cmake: -------------------------------------------------------------------------------- 1 | #[[ 2 | 3 | Default CMake cache for building in CI without MPI and GPU 4 | 5 | #]] 6 | message(STATUS "Enabling both shared and static libraries") 7 | set(HIOP_BUILD_SHARED ON CACHE BOOL "") 8 | set(HIOP_BUILD_STATIC ON CACHE BOOL "") 9 | 10 | set(ENABLE_TESTS ON CACHE BOOL "") 11 | 12 | message(STATUS "Disabling MPI, RAJA, Umpire, Kron Reduction, and CUDA") 13 | set(HIOP_USE_MPI OFF CACHE BOOL "") 14 | set(HIOP_USE_RAJA OFF CACHE BOOL "") 15 | set(HIOP_USE_UMPIRE OFF CACHE BOOL "") 16 | set(HIOP_WITH_KRON_REDUCTION OFF CACHE BOOL "") 17 | set(HIOP_USE_GPU OFF CACHE BOOL "") 18 | set(HIOP_USE_CUDA OFF CACHE BOOL "") 19 | set(HIOP_USE_GINKGO OFF CACHE BOOL "") 20 | 21 | message(STATUS "Enabling HiOp's Sparse Interface") 22 | set(HIOP_SPARSE ON CACHE BOOL "") 23 | 24 | message(STATUS "Enabling HiOp's deepchecking") 25 | set(HIOP_DEEPCHECKS ON CACHE BOOL "") 26 | 27 | message(STATUS "Setting default cuda architecture to 60") 28 | set(CMAKE_CUDA_ARCHITECTURES 60 CACHE STRING "") 29 | 30 | message(STATUS "Done preloading CMake cache with values for continuous integration") 31 | -------------------------------------------------------------------------------- /tests/testMDS1CompareIterations.awk: -------------------------------------------------------------------------------- 1 | #!/usr/bin/awk -f 2 | function abs(v) {return v < 0 ? -v : v} 3 | BEGIN { 4 | columns[0]="iter" 5 | columns[1]="objective" 6 | columns[2]="inf_pr" 7 | columns[3]="inf_du" 8 | columns[4]="lg(mu)" 9 | columns[5]="alpha_du" 10 | columns[6]="alpha_pr" 11 | columns[7]="linesrch" 12 | fail=0 13 | tol=0.00001 14 | } 15 | { 16 | len=split($0, data, " ") 17 | if(len!=15) { 18 | printf "Got incorrect number of fields (%d)\n", len 19 | exit(1) 20 | } 21 | for(i=2;i<8;i++) { 22 | j=i + 7 23 | if(abs((data[i] + 0)-(data[j] + 0)) > tol) { 24 | printf "Found difference on iteration %d in field %s:\n", data[0], columns[i] 25 | printf "1: %-20f 2: %-20f\n", data[i], data[j] 26 | fail++ 27 | } 28 | } 29 | if(data[8]!=data[15]) { 30 | printf "Found difference on iteration %d in field %s:\n", data[0], columns[7] 31 | printf "1: %-20s 2: %-20s\n", data[8], data[15] 32 | fail++ 33 | } 34 | } 35 | END { 36 | if (fail) { 37 | print "Found failures." 38 | exit(1) 39 | } 40 | print "Example outputs matched!" 41 | } 42 | -------------------------------------------------------------------------------- /src/LinAlg/hiopVectorRajaOmp.cpp: -------------------------------------------------------------------------------- 1 | #include "hiopVectorRaja.hpp" 2 | 3 | #include "MemBackendUmpireImpl.hpp" 4 | #include "ExecPoliciesRajaOmpImpl.hpp" 5 | 6 | namespace hiop 7 | { 8 | using hiop_raja_exec = ExecRajaPoliciesBackend::hiop_raja_exec; 9 | using hiop_raja_reduce = ExecRajaPoliciesBackend::hiop_raja_reduce; 10 | } // namespace hiop 11 | 12 | #include "hiopVectorRajaImpl.hpp" 13 | #include "MathKernelsHost.hpp" 14 | 15 | namespace hiop 16 | { 17 | 18 | template<> 19 | void hiopVectorRaja::set_to_random_uniform(double minv, double maxv) 20 | { 21 | hiop::host::array_random_uniform_kernel(n_local_, data_dev_, minv, maxv); 22 | } 23 | 24 | template<> 25 | void hiopVectorRaja::set_to_random_uniform(double minv, double maxv) 26 | { 27 | hiop::host::array_random_uniform_kernel(n_local_, data_dev_, minv, maxv); 28 | } 29 | 30 | // 31 | // Explicit instantiations: force compilation 32 | // 33 | template class hiopVectorRaja; 34 | template class hiopVectorRaja; 35 | } // namespace hiop 36 | -------------------------------------------------------------------------------- /scripts/gcc-cuda.cmake: -------------------------------------------------------------------------------- 1 | #[[ 2 | 3 | Default CMake cache for building in CI with most options enabled and a sane 4 | default value for CUDA architectures. 5 | 6 | #]] 7 | message(STATUS "Enabling both shared and static libraries") 8 | set(HIOP_BUILD_SHARED OFF CACHE BOOL "") 9 | set(HIOP_BUILD_STATIC ON CACHE BOOL "") 10 | 11 | set(ENABLE_TESTS ON CACHE BOOL "") 12 | 13 | message(STATUS "Enabling MPI, RAJA, Umpire, Kron Reduction, and CUDA") 14 | set(HIOP_USE_MPI ON CACHE BOOL "") 15 | set(HIOP_USE_RAJA ON CACHE BOOL "") 16 | set(HIOP_USE_UMPIRE ON CACHE BOOL "") 17 | set(HIOP_WITH_KRON_REDUCTION ON CACHE BOOL "") 18 | set(HIOP_USE_GPU ON CACHE BOOL "") 19 | set(HIOP_USE_CUDA ON CACHE BOOL "") 20 | set(HIOP_USE_GINKGO ON CACHE BOOL "") 21 | 22 | message(STATUS "Enabling HiOp's Sparse Interface") 23 | set(HIOP_SPARSE ON CACHE BOOL "") 24 | 25 | message(STATUS "Enabling HiOp's deepchecking") 26 | set(HIOP_DEEPCHECKS ON CACHE BOOL "") 27 | 28 | set(CMAKE_CUDA_ARCHITECTURES 60 70 75 80 CACHE STRING "") 29 | message(STATUS "Setting default cuda architecture to ${CMAKE_CUDA_ARCHITECTURES}") 30 | 31 | message(STATUS "Done preloading CMake cache with values for continuous integration") 32 | -------------------------------------------------------------------------------- /cmake/FindHiopSTRUMPACK.cmake: -------------------------------------------------------------------------------- 1 | 2 | #[[ 3 | 4 | Exports target `STRUMPACK` 5 | 6 | Users may set the following variables: 7 | 8 | - HIOP_STRUMPACK_DIR 9 | - HIOP_SCALAPACK_DIR 10 | 11 | ]] 12 | 13 | find_package(STRUMPACK CONFIG 14 | PATHS ${STRUMPACK_DIR} ${HIOP_STRUMPACK_DIR} 15 | REQUIRED) 16 | 17 | find_library(SCALAPACK_LIBRARY 18 | NAMES 19 | scalapack 20 | PATHS 21 | ${SCALAPACK_DIR} $ENV{SCALAPACK_DIR} ${HIOP_SCALAPACK_DIR} 22 | ENV LD_LIBRARY_PATH ENV DYLD_LIBRARY_PATH 23 | PATH_SUFFIXES 24 | lib64 lib) 25 | 26 | if(STRUMPACK_LIBRARIES) 27 | message(STATUS "Found STRUMPACK library: ${STRUMPACK_LIBRARIES}") 28 | add_library(STRUMPACK INTERFACE) 29 | target_link_libraries(STRUMPACK INTERFACE STRUMPACK::strumpack) 30 | install(TARGETS STRUMPACK EXPORT hiop-targets) 31 | 32 | # ignore SCALAPACK not_found: it may be that strumpack was built without MPI/SCALAPCK 33 | if(SCALAPACK_LIBRARY) 34 | target_link_libraries(STRUMPACK INTERFACE ${SCALAPACK_LIBRARY}) 35 | message(STATUS "Found SCALAPACK library: ${SCALAPACK_LIBRARY}") 36 | endif(SCALAPACK_LIBRARY) 37 | else() 38 | message(STATUS "STRUMPACK was not found.") 39 | endif() 40 | 41 | -------------------------------------------------------------------------------- /cmake/FindHiopMagma.cmake: -------------------------------------------------------------------------------- 1 | 2 | #[[ 3 | 4 | Exports target `Magma`. 5 | 6 | Users may set the following variables: 7 | 8 | - HIOP_MAGMA_DIR 9 | 10 | ]] 11 | 12 | find_library(MAGMA_LIBRARY 13 | NAMES 14 | magma 15 | PATHS 16 | ${MAGMA_DIR} $ENV{MAGMA_DIR} ${HIOP_MAGMA_DIR} 17 | ENV LD_LIBRARY_PATH ENV DYLD_LIBRARY_PATH 18 | PATH_SUFFIXES 19 | lib64 lib) 20 | 21 | if(MAGMA_LIBRARY) 22 | get_filename_component(MAGMA_LIBRARY_DIR ${MAGMA_LIBRARY} DIRECTORY) 23 | endif() 24 | 25 | find_path(MAGMA_INCLUDE_DIR 26 | NAMES 27 | magma_v2.h 28 | PATHS 29 | ${MAGMA_DIR} $ENV{MAGMA_DIR} ${HIOP_MAGMA_DIR} ${MAGMA_LIBRARY_DIR}/.. 30 | PATH_SUFFIXES 31 | include) 32 | 33 | if(MAGMA_LIBRARY) 34 | add_library(Magma INTERFACE) 35 | target_link_libraries(Magma INTERFACE ${MAGMA_LIBRARY}) 36 | target_include_directories(Magma INTERFACE ${MAGMA_INCLUDE_DIR}) 37 | message(STATUS "Found Magma include: ${MAGMA_INCLUDE_DIR}") 38 | message(STATUS "Found Magma library: ${MAGMA_LIBRARY}") 39 | install(TARGETS Magma EXPORT hiop-targets) 40 | else() 41 | message(STATUS "Magma was not found.") 42 | endif() 43 | 44 | set(MAGMA_INCLUDE_DIR CACHE PATH "Path to magma.h") 45 | set(MAGMA_LIBRARY CACHE PATH "Path to magma library") 46 | -------------------------------------------------------------------------------- /cmake/HiOpDoxygenConfig.cmake: -------------------------------------------------------------------------------- 1 | find_package(Doxygen) 2 | 3 | set(HIOP_DOXYGEN_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/doxygen 4 | CACHE PATH "Absolute path to output directory of ExaGO documentation.") 5 | 6 | if(NOT EXISTS ${HIOP_DOXYGEN_OUTPUT_DIRECTORY}) 7 | file(MAKE_DIRECTORY ${HIOP_DOXYGEN_OUTPUT_DIRECTORY}) 8 | endif() 9 | 10 | if(NOT DOXYGEN_FOUND) 11 | message(STATUS "Could not find doxygen package... Docs will not be created.") 12 | else() 13 | message(STATUS "Configuring Doxygen documentation") 14 | 15 | # Some values and paths will be configured using ExaGO cmake variables 16 | configure_file( 17 | ${PROJECT_SOURCE_DIR}/doc/doxygen/Doxyfile.in 18 | ${PROJECT_BINARY_DIR}/Doxyfile 19 | ) 20 | 21 | add_custom_target( 22 | doc 23 | COMMAND doxygen ${PROJECT_BINARY_DIR}/Doxyfile 24 | COMMENT "Generate documentation" 25 | ) 26 | 27 | add_custom_target( 28 | install_doc 29 | COMMAND ${CMAKE_COMMAND} -E copy_directory 30 | ${PROJECT_BINARY_DIR}/doxygen/html 31 | ${CMAKE_INSTALL_PREFIX}/doc/html 32 | COMMAND ${CMAKE_COMMAND} -E copy_directory 33 | ${PROJECT_BINARY_DIR}/doxygen/latex 34 | ${CMAKE_INSTALL_PREFIX}/doc/latex 35 | COMMENT "Install documentation" 36 | ) 37 | endif() 38 | -------------------------------------------------------------------------------- /cmake/FindHiopMETIS.cmake: -------------------------------------------------------------------------------- 1 | 2 | #[[ 3 | 4 | Exports target `METIS` 5 | 6 | Users may set the following variables: 7 | 8 | - HIOP_METIS_DIR 9 | 10 | ]] 11 | 12 | find_library(METIS_LIBRARY 13 | NAMES 14 | metis 15 | PATHS 16 | ${METIS_DIR} $ENV{METIS_DIR} ${HIOP_METIS_DIR} 17 | ENV LD_LIBRARY_PATH ENV DYLD_LIBRARY_PATH 18 | PATH_SUFFIXES 19 | lib64 lib) 20 | 21 | if(METIS_LIBRARY) 22 | get_filename_component(METIS_LIBRARY_DIR ${METIS_LIBRARY} DIRECTORY) 23 | endif() 24 | 25 | find_path(METIS_INCLUDE_DIR 26 | NAMES 27 | metis.h 28 | PATHS 29 | ${METIS_DIR} $ENV{METIS_DIR} ${HIOP_METIS_DIR} ${METIS_LIBRARY_DIR}/.. 30 | PATH_SUFFIXES 31 | include) 32 | 33 | if(METIS_LIBRARY) 34 | message(STATUS "Found metis include: ${METIS_INCLUDE_DIR}") 35 | message(STATUS "Found metis library: ${METIS_LIBRARY}") 36 | add_library(METIS INTERFACE) 37 | target_link_libraries(METIS INTERFACE ${METIS_LIBRARY}) 38 | target_include_directories(METIS INTERFACE ${METIS_INCLUDE_DIR}) 39 | message(STATUS "Found METIS library: ${METIS_LIBRARY}") 40 | install(TARGETS METIS EXPORT hiop-targets) 41 | else() 42 | message(STATUS "METIS was not found.") 43 | endif() 44 | 45 | set(METIS_INCLUDE_DIR CACHE PATH "Path to metis.h") 46 | set(METIS_LIBRARY CACHE PATH "Path to metis library") 47 | 48 | -------------------------------------------------------------------------------- /.gitlab/ornl-ci.yml: -------------------------------------------------------------------------------- 1 | stages: 2 | - build 3 | - test 4 | 5 | variables: 6 | GIT_SUBMODULE_STRATEGY: recursive 7 | 8 | # Environment variables shared between scripts for all ORNL CI stages 9 | .ornl_environment: 10 | variables: 11 | SCHEDULER_PARAMETERS: "-P CSC359 -nnodes 1 -W 30" 12 | WORKDIR: /gpfs/wolf/proj-shared/csc359/ci/${CI_PIPELINE_ID} 13 | 14 | .ornl_test: 15 | stage: test 16 | variables: 17 | GIT_STRATEGY: none 18 | extends: .ornl_environment 19 | script: 20 | - | 21 | set -xv 22 | cd "$WORKDIR" 23 | MY_CLUSTER="ascent" ./BUILD.sh --test-only 24 | res=$? 25 | exit $res 26 | after_script: 27 | - | 28 | cd "$WORKDIR/.." 29 | rm -rf "$WORKDIR" 30 | 31 | .ornl_build: 32 | stage: build 33 | extends: .ornl_environment 34 | script: 35 | - | 36 | # Don't clean up this working directory - we need some of these files for 37 | # testing 38 | set -xv 39 | mkdir -p "$WORKDIR" 40 | cp -R ./* "$WORKDIR" 41 | cd "$WORKDIR" 42 | MY_CLUSTER="ascent" ./BUILD.sh --build-only || exit 1 43 | 44 | build_on_login_node: 45 | extends: .ornl_build 46 | tags: 47 | - nobatch 48 | 49 | test_on_compute_node: 50 | extends: .ornl_test 51 | needs: ['build_on_login_node'] 52 | tags: 53 | - batch 54 | -------------------------------------------------------------------------------- /src/LinAlg/ReSolve/MatrixCsr.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace ReSolve 4 | { 5 | 6 | class MatrixCsr 7 | { 8 | public: 9 | MatrixCsr(); 10 | ~MatrixCsr(); 11 | void allocate_size(int n); 12 | void allocate_nnz(int nnz); 13 | void clear_data(); 14 | 15 | int* get_irows() { return irows_; } 16 | 17 | const int* get_irows() const { return irows_; } 18 | 19 | int* get_jcols() { return jcols_; } 20 | 21 | double* get_vals() { return vals_; } 22 | 23 | int* get_irows_host() { return irows_host_; } 24 | 25 | int* get_jcols_host() { return jcols_host_; } 26 | 27 | double* get_vals_host() { return vals_host_; } 28 | 29 | void update_from_host_mirror(); 30 | void copy_to_host_mirror(); 31 | 32 | private: 33 | int n_{0}; 34 | int nnz_{0}; 35 | 36 | int* irows_{nullptr}; 37 | int* jcols_{nullptr}; 38 | double* vals_{nullptr}; 39 | 40 | int* irows_host_{nullptr}; 41 | int* jcols_host_{nullptr}; 42 | double* vals_host_{nullptr}; 43 | 44 | /** 45 | * @brief Check for CUDA errors. 46 | * 47 | * @tparam T - type of the result 48 | * @param result - result value 49 | * @param file - file name where the error occured 50 | * @param line - line at which the error occured 51 | */ 52 | template 53 | void resolveCheckCudaError(T result, const char* const file, int const line); 54 | }; 55 | 56 | } // namespace ReSolve 57 | -------------------------------------------------------------------------------- /src/hiopbbpy/problems/BraninProblem.py: -------------------------------------------------------------------------------- 1 | """ 2 | Implementation of the Branin problem 3 | 4 | min f(x_1, x_2) = \left( x_2 - \frac{5.1}{4\pi^2} x_1^2 + \frac{5}{\pi} x_1 - 6 \right)^2 + 10 \left(1 - \frac{1}{8\pi}\right) \cos(x_1) + 10. 5 | s.t x_1 \in [-5, 10], \quad x_2 \in [0, 15]. 6 | 7 | It has three global minima at: 8 | (x_1, x_2) = (-\pi, 12.275) 9 | (\pi, 2.275) 10 | (9.42478, 2.475) 11 | and the optimal objective 0.3979 12 | 13 | Authors: Tucker Hartland 14 | Nai-Yuan Chiang 15 | """ 16 | import numpy as np 17 | from .problem import Problem 18 | from numpy.random import uniform 19 | 20 | # define the Branin problem class 21 | class BraninProblem(Problem): 22 | def __init__(self, constraints=[]): 23 | ndim = 2 24 | xlimits = np.array([[-5.0, 10], [0.0, 15]]) 25 | name = 'Branin' 26 | super().__init__(ndim, xlimits, name=name, constraints=constraints) 27 | 28 | def _evaluate(self, x: np.ndarray) -> np.ndarray: 29 | ne, nx = x.shape 30 | assert nx == self.ndim 31 | 32 | y = np.zeros((ne, 1), complex) 33 | b = 5.1 / (4.0 * (np.pi) ** 2) 34 | c = 5.0 / np.pi 35 | r = 6.0 36 | s = 10.0 37 | t = 1.0 / (8.0 * np.pi) 38 | 39 | arg1 = (x[:,1] - b * x[:,0]**2 + c * x[:,0] - r) 40 | y[:,0] = arg1**2 + s * (1 - t) * np.cos(x[:,0]) + s 41 | 42 | return y 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /cmake/FindKLU.cmake: -------------------------------------------------------------------------------- 1 | 2 | #[[ 3 | 4 | Looks for `klu` library and header directory. 5 | 6 | Exports target `KLU` which links to umfpack.(so|a) 7 | and add include directories where klu.h was found. 8 | 9 | Users may set the following variables: 10 | 11 | - HIOP_KLU_DIR 12 | 13 | ]] 14 | 15 | 16 | find_library(KLU_LIBRARY 17 | NAMES 18 | klu 19 | PATHS 20 | ${KLU_DIR} $ENV{KLU_DIR} ${HIOP_KLU_DIR} 21 | ENV LD_LIBRARY_PATH ENV DYLD_LIBRARY_PATH 22 | PATH_SUFFIXES 23 | lib64 lib) 24 | 25 | if(KLU_LIBRARY) 26 | get_filename_component(KLU_LIBRARY_DIR ${KLU_LIBRARY} DIRECTORY) 27 | endif() 28 | 29 | find_path(KLU_INCLUDE_DIR 30 | NAMES 31 | klu.h 32 | PATHS 33 | ${KLU_DIR} $ENV{KLU_DIR} ${HIOP_KLU_DIR} ${KLU_LIBRARY_DIR}/.. 34 | PATH_SUFFIXES 35 | include 36 | include/suitesparse 37 | include/klu) 38 | 39 | if(KLU_LIBRARY) 40 | message(STATUS "Found klu include: ${KLU_INCLUDE_DIR}") 41 | message(STATUS "Found klu library: ${KLU_LIBRARY}") 42 | add_library(KLU INTERFACE) 43 | target_link_libraries(KLU INTERFACE ${KLU_LIBRARY}) 44 | target_include_directories(KLU INTERFACE ${KLU_INCLUDE_DIR}) 45 | get_filename_component(KLU_LIB_DIR ${KLU_LIBRARY} DIRECTORY) 46 | set(CMAKE_INSTALL_RPATH "${KLU_LIB_DIR}") 47 | install(TARGETS KLU EXPORT hiop-targets) 48 | else() 49 | message(STATUS "KLU was not found.") 50 | endif() 51 | 52 | set(KLU_INCLUDE_DIR CACHE PATH "Path to klu.h") 53 | set(KLU_LIBRARY CACHE PATH "Path to klu library") 54 | 55 | -------------------------------------------------------------------------------- /cmake/FindHiopCOINHSL.cmake: -------------------------------------------------------------------------------- 1 | 2 | #[[ 3 | 4 | Exports target `COINHSL` 5 | 6 | Users may set the following variables: 7 | 8 | - HIOP_COINHSL_DIR 9 | 10 | ]] 11 | 12 | find_library(COINHSL_LIBRARY 13 | NAMES 14 | coinhsl 15 | PATHS 16 | ${COINHSL_DIR} $ENV{COINHSL_DIR} ${HIOP_COINHSL_DIR} 17 | ENV LD_LIBRARY_PATH ENV DYLD_LIBRARY_PATH 18 | PATH_SUFFIXES 19 | lib64 lib) 20 | 21 | if(COINHSL_LIBRARY) 22 | get_filename_component(COINHSL_LIBRARY_DIR ${COINHSL_LIBRARY} DIRECTORY) 23 | endif() 24 | 25 | find_path(COINHSL_INCLUDE_DIR 26 | NAMES 27 | CoinHslConfig.h 28 | PATHS 29 | ${COINHSL_DIR} $ENV{COINHSL_DIR} ${HIOP_COINHSL_DIR} ${COINHSL_LIBRARY_DIR}/.. 30 | PATH_SUFFIXES 31 | include/coin/ThirdParty 32 | include/coinor 33 | include/coin-or 34 | include/coin-or/hsl 35 | include) 36 | 37 | if(COINHSL_LIBRARY) 38 | message(STATUS "Found coinhsl include: ${COINHSL_INCLUDE_DIR}") 39 | message(STATUS "Found coinhsl library: ${COINHSL_LIBRARY}") 40 | add_library(COINHSL INTERFACE) 41 | target_link_libraries(COINHSL INTERFACE ${COINHSL_LIBRARY} ${CMAKE_DL_LIBS}) 42 | target_include_directories(COINHSL INTERFACE ${COINHSL_INCLUDE_DIR}) 43 | message(STATUS "Found COINHSL library: ${COINHSL_LIBRARY}") 44 | install(TARGETS COINHSL EXPORT hiop-targets) 45 | else() 46 | message(STATUS "COINHSL was not found.") 47 | endif() 48 | 49 | set(COINHSL_INCLUDE_DIR CACHE PATH "Path to coinhsl.h") 50 | set(COINHSL_LIBRARY CACHE PATH "Path to coinhsl library") 51 | -------------------------------------------------------------------------------- /doc/src/hiop.bib: -------------------------------------------------------------------------------- 1 | @Article{ipopt_impl, 2 | author="W{\"a}chter, Andreas 3 | and Biegler, Lorenz T.", 4 | title="On the implementation of an interior-point filter line-search algorithm for large-scale nonlinear programming", 5 | journal="Mathematical Programming", 6 | year="2006", 7 | volume="106", 8 | number="1", 9 | pages="25--57", 10 | abstract="We present a primal-dual interior-point algorithm with a filter line-search method for nonlinear programming. Local and global convergence properties of this method were analyzed in previous work. Here we provide a comprehensive description of the algorithm, including the feasibility restoration phase for the filter method, second-order corrections, and inertia correction of the KKT matrix. Heuristics are also considered that allow faster performance. This method has been implemented in the IPOPT code, which we demonstrate in a detailed numerical study based on 954 problems from the CUTEr test set. An evaluation is made of several line-search options, and a comparison is provided with two state-of-the-art interior-point codes for nonlinear programming.", 11 | issn="1436-4646" 12 | } 13 | 14 | @article{petra2019memory, 15 | title={A memory-distributed quasi-{N}ewton solver for nonlinear programming problems with a small number of general constraints}, 16 | author={Petra, Cosmin G}, 17 | journal={Journal of Parallel and Distributed Computing}, 18 | volume={133}, 19 | pages={337--348}, 20 | year={2019}, 21 | publisher={Elsevier} 22 | } 23 | 24 | -------------------------------------------------------------------------------- /src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(Interface) 2 | add_subdirectory(ExecBackends) 3 | add_subdirectory(Optimization) 4 | add_subdirectory(LinAlg) 5 | add_subdirectory(Utils) 6 | 7 | # Interface headers not already picked up by another subdirectory 8 | set(hiop_INTERFACE_HEADERS 9 | ${PROJECT_BINARY_DIR}/hiop_defs.hpp 10 | ${PROJECT_BINARY_DIR}/FortranCInterface.hpp 11 | ) 12 | 13 | install( 14 | FILES ${hiop_INTERFACE_HEADERS} 15 | DESTINATION include 16 | ) 17 | 18 | # Create shared and static libraries from sources defined in subdirectories 19 | foreach(libtype shared static) 20 | string(TOUPPER ${libtype} libtype_upper) 21 | if(${HIOP_BUILD_${libtype_upper}}) 22 | add_library(hiop_${libtype} 23 | ${libtype_upper} 24 | $ 25 | $ 26 | $ 27 | $ 28 | $<$:$> 29 | ) 30 | target_link_libraries(hiop_${libtype} PUBLIC hiop_tpl) 31 | target_include_directories(hiop_${libtype} PUBLIC 32 | $ 33 | $) 34 | set_target_properties(hiop_${libtype} PROPERTIES OUTPUT_NAME hiop) 35 | install(TARGETS hiop_${libtype} DESTINATION lib EXPORT hiop-targets) 36 | endif() 37 | endforeach() 38 | 39 | # Create default library pointed to by HiOp::HiOp 40 | add_library(HiOp::HiOp ALIAS ${hiop_default_library_name}) 41 | 42 | 43 | -------------------------------------------------------------------------------- /src/Optimization/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(hiopOptimization_SRC 2 | hiopNlpFormulation.cpp 3 | hiopFactAcceptor.cpp 4 | hiopIterate.cpp 5 | hiopResidual.cpp 6 | hiopFilter.cpp 7 | hiopAlgFilterIPM.cpp 8 | hiopKKTLinSys.cpp 9 | KktLinSysLowRank.cpp 10 | hiopKKTLinSysMDS.cpp 11 | HessianDiagPlusRowRank.cpp 12 | VectorSpace.cpp 13 | hiopDualsUpdater.cpp 14 | hiopNlpTransforms.cpp 15 | hiopPDPerturbation.cpp 16 | hiopAlgPrimalDecomp.cpp 17 | hiopFRProb.cpp 18 | ) 19 | 20 | set(hiopOptimization_SPARSE_SRC 21 | hiopKKTLinSysSparse.cpp 22 | hiopKKTLinSysSparseCondensed.cpp 23 | hiopKKTLinSysSparseNormalEqn.cpp 24 | ) 25 | 26 | set(hiopOptimization_INTERFACE_HEADERS 27 | hiopAlgFilterIPM.hpp 28 | hiopAlgPrimalDecomp.hpp 29 | hiopDualsUpdater.hpp 30 | hiopFactAcceptor.hpp 31 | hiopFilter.hpp 32 | HessianDiagPlusRowRank.hpp 33 | VectorSpace.hpp 34 | hiopIterate.hpp 35 | hiopKKTLinSys.hpp 36 | hiopKKTLinSysDense.hpp 37 | hiopKKTLinSysMDS.hpp 38 | hiopKKTLinSysSparse.hpp 39 | hiopKKTLinSysSparseCondensed.hpp 40 | hiopKKTLinSysSparseNormalEqn.hpp 41 | hiopLogBarProblem.hpp 42 | hiopNlpFormulation.hpp 43 | hiopNlpTransforms.hpp 44 | hiopPDPerturbation.hpp 45 | hiopResidual.hpp 46 | ) 47 | 48 | if(HIOP_SPARSE) 49 | list(APPEND hiopOptimization_SRC ${hiopOptimization_SPARSE_SRC}) 50 | endif() 51 | 52 | install( 53 | FILES ${hiopOptimization_INTERFACE_HEADERS} 54 | DESTINATION include 55 | ) 56 | 57 | add_library(hiopOptimization OBJECT ${hiopOptimization_SRC}) 58 | target_link_libraries(hiopOptimization PRIVATE hiop_tpl) 59 | -------------------------------------------------------------------------------- /cmake/FindUMFPACK.cmake: -------------------------------------------------------------------------------- 1 | 2 | #[[ 3 | 4 | Looks for `umfpack` library and header directory. 5 | 6 | Exports target `UMFPACK` which links to umfpack.(so|a) 7 | and add include directories where umfpack.h was found. 8 | 9 | Users may set the following variables: 10 | 11 | - HIOP_UMFPACK_DIR 12 | 13 | ]] 14 | 15 | find_library(UMFPACK_LIBRARY 16 | NAMES 17 | umfpack 18 | PATHS 19 | ${UMFPACK_DIR} $ENV{UMFPACK_DIR} ${HIOP_UMFPACK_DIR} 20 | ENV LD_LIBRARY_PATH ENV DYLD_LIBRARY_PATH 21 | PATH_SUFFIXES 22 | lib64 lib) 23 | 24 | if(UMFPACK_LIBRARY) 25 | get_filename_component(UMFPACK_LIBRARY_DIR ${UMFPACK_LIBRARY} DIRECTORY) 26 | endif() 27 | 28 | find_path(UMFPACK_INCLUDE_DIR 29 | NAMES 30 | umfpack.h 31 | PATHS 32 | ${UMFPACK_DIR} $ENV{UMFPACK_DIR} ${HIOP_UMFPACK_DIR} ${UMFPACK_LIBRARY_DIR}/.. 33 | PATH_SUFFIXES 34 | include 35 | include/suitesparse 36 | include/ufsparse) 37 | 38 | if(UMFPACK_LIBRARY) 39 | message(STATUS "Found umfpack include: ${UMFPACK_INCLUDE_DIR}") 40 | message(STATUS "Found umfpack library: ${UMFPACK_LIBRARY}") 41 | add_library(UMFPACK INTERFACE) 42 | target_link_libraries(UMFPACK INTERFACE ${UMFPACK_LIBRARY}) 43 | target_include_directories(UMFPACK INTERFACE ${UMFPACK_INCLUDE_DIR}) 44 | get_filename_component(UMFPACK_LIB_DIR ${UMFPACK_LIBRARY} DIRECTORY) 45 | set(CMAKE_INSTALL_RPATH "${UMFPACK_LIB_DIR}") 46 | install(TARGETS UMFPACK EXPORT hiop-targets) 47 | else() 48 | message(STATUS "UMFPACK was not found.") 49 | endif() 50 | 51 | set(UMFPACK_INCLUDE_DIR CACHE PATH "Path to umfpack.h") 52 | set(UMFPACK_LIBRARY CACHE PATH "Path to umfpack library") 53 | -------------------------------------------------------------------------------- /scripts/platforms/lassen/spack.yaml: -------------------------------------------------------------------------------- 1 | spack: 2 | specs: 3 | - hiop@develop+kron+mpi+raja+sparse+cuda+cusolver_lu cuda_arch=70 4 | - raja@2024.07.0 5 | - umpire@2024.07.0 6 | - coinhsl@2015.06.23 7 | 8 | view: false 9 | concretizer: 10 | unify: true 11 | reuse: false 12 | packages: 13 | all: 14 | providers: 15 | mpi: [spectrum-mpi] 16 | blas: [openblas] 17 | lapack: [openblas] 18 | spectrum-mpi: 19 | externals: 20 | - spec: spectrum-mpi@rolling-release 21 | modules: [spectrum-mpi/rolling-release] 22 | buildable: false 23 | coinnhsl: 24 | variants: +blas+metis 25 | python: 26 | externals: 27 | - spec: python@3.8.2 28 | modules: [python/3.8.2] 29 | buildable: false 30 | cuda: 31 | externals: 32 | - spec: cuda@11.7.0 33 | modules: 34 | - cuda/11.7.0 35 | buildable: false 36 | cmake: 37 | externals: 38 | - spec: cmake@3.23.1 39 | modules: [cmake/3.23.1] 40 | buildable: false 41 | compilers: 42 | - compiler: 43 | spec: gcc@11.2.1 44 | paths: 45 | cc: /usr/tce/packages/gcc/gcc-11.2.1/bin/cc 46 | cxx: /usr/tce/packages/gcc/gcc-11.2.1/bin/g++ 47 | f77: /usr/tce/packages/gcc/gcc-11.2.1/bin/gfortran 48 | fc: /usr/tce/packages/gcc/gcc-11.2.1/bin/gfortran 49 | flags: {} 50 | operating_system: rhel7 51 | target: ppc64le 52 | modules: [] 53 | environment: {} 54 | extra_rpaths: [] 55 | develop: 56 | hiop: 57 | path: /usr/workspace/hiop/lassen/hiop_from_spack 58 | spec: hiop@develop 59 | -------------------------------------------------------------------------------- /src/LinAlg/csr_iajaaa.md: -------------------------------------------------------------------------------- 1 | # CSR Format used by HiOp to save linear systems 2 | 3 | Each of the linear systems saved by HiOp in a .iajaaa file (see [this](readme.md) for more information) consists of the systems's matrix, the right-hand side(s) (rhs), and the solution(s). The matrix is assumed to be square and the indexes are Fortran style (1-based). For KKT symmetric matrices only the elements from the upper or lower triangle are used. The lower triangle elements are saved for all symmetric KKT systems, while for the rest of the symmetric KKT systems (MDS and dense) the upper triangle elements are saved. 4 | 5 | An example Matlab script that loads and solves such linear systems is provided [here](load_kkt_mat.m). 6 | 7 | The .iajaaa files contain 8 | 9 | 1. number of rows (nrows) [1 int] 10 | 11 | 2. number of primal variables, number of equality constraints, and number of inequality constraints of the underlying NLP problem [3 ints] 12 | 13 | 3. number of nonzeros (nnz) [1 int] 14 | 15 | 4. array of pointers/offsets in 4. and 5. of the first nonzero of each row; first entry is 1 and the last entry is nnz+1 [nrows+1 ints] 16 | 17 | 5. array of the column indexes of nonzeros [nnz ints] 18 | 19 | 6. array of nonzero entries [nnz doubles] 20 | 21 | 7. rhs [nrows doubles] 22 | 23 | 8. solution [nrows doubles] 24 | 25 | 9. more rhs-solution pairs (repetitions of 7-8 above) 26 | 27 | Please remark that there is a slight variation of the .iajaaa format used by Ipopt (more exactly by Pardiso from within Ipopt), namely, 28 | + HiOp's also saves the solution, see 8. above; 29 | + multiple rhs-solution pairs can be present (*i.e.*,7-8 can repeat) at the end of the output files 30 | -------------------------------------------------------------------------------- /scripts/platforms/newell/spack.yaml: -------------------------------------------------------------------------------- 1 | spack: 2 | specs: 3 | - hiop@develop+kron+mpi+raja+sparse+cuda+ginkgo+deepchecking+cusolver_lu cuda_arch=70 4 | - raja@0.14.0 5 | - umpire@6.0.0 6 | - coinhsl@2019.05.21 7 | view: false 8 | concretizer: 9 | unify: true 10 | reuse: false 11 | packages: 12 | coinhsl: 13 | variants: +blas 14 | openmpi: 15 | externals: 16 | - spec: openmpi@4.1.4%gcc@8.5.0 17 | prefix: /share/apps/openmpi/4.1.4/gcc/8.5.0 18 | modules: 19 | - openmpi/4.1.4 20 | buildable: false 21 | variants: +cuda 22 | python: 23 | externals: 24 | - spec: python@3.8.5 25 | modules: [python/miniconda3.8] 26 | - spec: python@2.7.5-system 27 | prefix: /usr 28 | buildable: false 29 | cuda: 30 | externals: 31 | - spec: cuda@11.4 32 | modules: 33 | - cuda/11.4 34 | buildable: false 35 | compilers: 36 | - compiler: 37 | spec: gcc@11.2.0 38 | paths: 39 | cc: /share/apps/gcc/11.2.0/bin/gcc 40 | cxx: /share/apps/gcc/11.2.0/bin/g++ 41 | f77: /share/apps/gcc/11.2.0/bin/gfortran 42 | fc: /share/apps/gcc/11.2.0/bin/gfortran 43 | flags: {} 44 | operating_system: centos8 45 | target: ppc64le 46 | modules: [] 47 | environment: {} 48 | extra_rpaths: [] 49 | - compiler: 50 | spec: gcc@8.5.0 51 | paths: 52 | cc: /usr/bin/gcc 53 | cxx: /usr/bin/g++ 54 | f77: /usr/bin/gfortran 55 | fc: /usr/bin/gfortran 56 | flags: {} 57 | operating_system: centos8 58 | target: ppc64le 59 | modules: [] 60 | environment: {} 61 | extra_rpaths: [] 62 | develop: 63 | hiop: 64 | path: /qfs/projects/exasgd/src/cameron/hiop-git 65 | spec: hiop@develop 66 | -------------------------------------------------------------------------------- /cmake/HiOpCheckGitSubmodules.cmake: -------------------------------------------------------------------------------- 1 | find_package(Git QUIET) 2 | if(GIT_FOUND) 3 | if(EXISTS "${PROJECT_SOURCE_DIR}/.git") 4 | # Update submodules as needed 5 | message(STATUS "Submodule update") 6 | execute_process( 7 | COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive 8 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} 9 | RESULT_VARIABLE GIT_SUBMOD_RESULT 10 | ) 11 | if(NOT GIT_SUBMOD_RESULT EQUAL "0") 12 | message( 13 | FATAL_ERROR 14 | "'git submodule update --init --recursive' failed with ${GIT_SUBMOD_RESULT}. " 15 | "Please checkout submodules manually with the folowing command and run cmake again:\n" 16 | "\t$ git submodule update --init --recursive\n" 17 | ) 18 | else() 19 | # For each submodule, we check a file in that submodule we expect to find to 20 | # make sure the submodules were downloaded correctly. 21 | foreach(CHK_FILE "eigen/Eigen/Core") 22 | if(NOT EXISTS "${PROJECT_SOURCE_DIR}/tpl/${CHK_FILE}") 23 | message( 24 | FATAL_ERROR 25 | "It seems that submodule ${PROJECT_SOURCE_DIR}/tpl/${CHK_FILE} was not downloaded! " 26 | "Please update submodules manually with the following command and try again:\n" 27 | "\t$ git submodule update --init --recursive\n" 28 | "Alternatively, use '-DHIOP_USE_EIGEN=ON -DHIOP_EIGEN_DIR=/path/to/eigen/root/dir'." 29 | ) 30 | endif() 31 | endforeach() 32 | 33 | endif() 34 | else() #EXISTS .git 35 | message( 36 | WARNING 37 | "It seems you are not using HiOp under a git repository. To enable EIGEN please use " 38 | "'-DHIOP_USE_EIGEN=ON -DHIOP_EIGEN_DIR=/path/to/eigen/root/dir'." 39 | ) 40 | set(HIOP_USE_EIGEN "OFF") 41 | endif() #EXISTS .git 42 | endif(GIT_FOUND) 43 | 44 | -------------------------------------------------------------------------------- /src/Drivers/PriDec/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if(HIOP_USE_MPI) 2 | add_executable(NlpPriDecEx1.exe NlpPriDecEx1.cpp NlpPriDecEx1Driver.cpp) 3 | target_link_libraries(NlpPriDecEx1.exe HiOp::HiOp) 4 | endif() 5 | 6 | if(HIOP_USE_MPI AND HIOP_SPARSE) 7 | include_directories("../Sparse") 8 | add_executable(NlpPriDecEx2.exe NlpPriDecEx2Driver.cpp NlpPriDecEx2.cpp ../Sparse/NlpSparseEx1.cpp) 9 | target_link_libraries(NlpPriDecEx2.exe HiOp::HiOp) 10 | add_executable(NlpPriDecEx2Sparse.exe NlpPriDecEx2SparseDriver.cpp NlpPriDecEx2Sparse.cpp ../Sparse/NlpSparseEx1.cpp) 11 | target_link_libraries(NlpPriDecEx2Sparse.exe HiOp::HiOp) 12 | add_executable(NlpPriDecEx3Sparse.exe NlpPriDecEx3SparseDriver.cpp) 13 | target_link_libraries(NlpPriDecEx3Sparse.exe HiOp::HiOp) 14 | 15 | if(HIOP_USE_RAJA) 16 | if(HIOP_USE_CUDA) 17 | set_source_files_properties( 18 | NlpPriDecEx2SparseRaja.cpp 19 | NlpPriDecEx2SparseRajaDriver.cpp 20 | PROPERTIES LANGUAGE CUDA) 21 | endif() 22 | add_executable(NlpPriDecEx2SparseRaja.exe NlpPriDecEx2SparseRajaDriver.cpp NlpPriDecEx2SparseRaja.cpp ../Sparse/NlpSparseEx1.cpp) 23 | target_link_libraries(NlpPriDecEx2SparseRaja.exe HiOp::HiOp) 24 | endif() 25 | endif() 26 | 27 | ########################################################## 28 | # CMake Tests 29 | ########################################################## 30 | if(HIOP_USE_MPI) 31 | add_test(NAME NlpPriDec1_1 COMMAND ${RUNCMD} "$" "-selfcheck") 32 | add_test(NAME NlpPriDec1_mpi COMMAND ${MPICMD} -n 2 "$" "-selfcheck") 33 | if(HIOP_SPARSE) 34 | add_test(NAME NlpPriDec2_1 COMMAND ${RUNCMD} "$" "-selfcheck") 35 | add_test(NAME NlpPriDec2_mpi COMMAND ${MPICMD} -n 2 "$" "-selfcheck") 36 | endif(HIOP_SPARSE) 37 | endif(HIOP_USE_MPI) 38 | 39 | 40 | -------------------------------------------------------------------------------- /src/LinAlg/hiopMatrixMDS.cpp: -------------------------------------------------------------------------------- 1 | #include "hiopMatrixMDS.hpp" 2 | #include 3 | 4 | #include 5 | 6 | namespace hiop 7 | { 8 | void hiopMatrixMDS::set_Jac_FR(const hiopMatrixMDS& Jac_c, 9 | const hiopMatrixMDS& Jac_d, 10 | int* iJacS, 11 | int* jJacS, 12 | double* MJacS, 13 | double* JacD) 14 | { 15 | const auto& J_c_sp = dynamic_cast(*(Jac_c.sp_mat())); 16 | const auto& J_d_sp = dynamic_cast(*(Jac_d.sp_mat())); 17 | mSp->set_Jac_FR(J_c_sp, J_d_sp, iJacS, jJacS, MJacS); 18 | 19 | const auto& J_c_de = dynamic_cast(*(Jac_c.de_mat())); 20 | const auto& J_d_de = dynamic_cast(*(Jac_d.de_mat())); 21 | assert(J_c_de.n() == mDe->n() && J_d_de.n() == mDe->n()); 22 | mDe->copyRowsFrom(J_c_de, J_c_de.m(), 0); 23 | mDe->copyRowsFrom(J_d_de, J_d_de.m(), J_c_de.m()); 24 | 25 | mDe->copy_to(JacD); 26 | } 27 | 28 | void hiopMatrixSymBlockDiagMDS::set_Hess_FR(const hiopMatrixSymBlockDiagMDS& Hess, 29 | int* iHSS, 30 | int* jHSS, 31 | double* MHSS, 32 | double* MHDD, 33 | const hiopVector& add_diag_sp, 34 | const hiopVector& add_diag_de) 35 | { 36 | const auto& Hess_sp = dynamic_cast(*(Hess.sp_mat())); 37 | mSp->set_Hess_FR(Hess_sp, iHSS, jHSS, MHSS, add_diag_sp); 38 | 39 | const auto& Hess_de = dynamic_cast(*(Hess.de_mat())); 40 | mDe->set_Hess_FR(Hess_de, add_diag_de); 41 | mDe->copy_to(MHDD); 42 | } 43 | 44 | } // namespace hiop 45 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: tests 2 | 3 | on: [push] 4 | 5 | jobs: 6 | test: 7 | runs-on: ${{ matrix.os }} 8 | strategy: 9 | matrix: 10 | os: [ubuntu-latest] 11 | 12 | steps: 13 | - name: Checkout code 14 | uses: actions/checkout@v4 15 | 16 | - name: Set up CMake 17 | uses: jwlawson/actions-setup-cmake@v2 18 | with: 19 | cmake-version: '3.21.x' 20 | 21 | - name: Set up GCC and G++ 22 | run: | 23 | sudo apt-get update 24 | sudo apt-get install -y build-essential libblas-dev liblapack-dev 25 | 26 | - name: Use cmake 27 | run: cmake --version 28 | 29 | - name: Cache CMake build 30 | uses: actions/cache@v3 31 | with: 32 | path: | 33 | ~/.cache/CMake 34 | ./hiop/build 35 | key: ${{ runner.os }}-cmake-${{ github.sha }} 36 | restore-keys: | 37 | ${{ runner.os }}-cmake- 38 | 39 | - name: Configure CMake 40 | run: | 41 | mkdir -p ${{ runner.workspace }}/hiop/build 42 | cd ${{ runner.workspace }}/hiop/build 43 | cmake ${{ runner.workspace }}/hiop \ 44 | -DHIOP_USE_RAJA=OFF \ 45 | -DHIOP_USE_MPI=OFF \ 46 | -DCMAKE_BUILD_TYPE=Debug \ 47 | -DHIOP_BUILD_SHARED=ON \ 48 | -DHIOP_BUILD_STATIC=ON \ 49 | -DCMAKE_INSTALL_PREFIX=.. \ 50 | -DHIOP_WITH_KRON_REDUCTION=OFF \ 51 | -DHIOP_SPARSE=OFF 52 | 53 | - name: Build hiop 54 | run: | 55 | cd ${{ runner.workspace }}/hiop/build 56 | make -j4 57 | 58 | - name: Install hiop 59 | run: | 60 | cd ${{ runner.workspace }}/hiop/build 61 | make install 62 | 63 | - name: Run Tests 64 | run: | 65 | cd ${{ runner.workspace }}/hiop/build 66 | make test 67 | 68 | -------------------------------------------------------------------------------- /.github/workflows/test_hiopbbpy.yml: -------------------------------------------------------------------------------- 1 | name: test_hiopbbpy 2 | 3 | on: [push] 4 | 5 | jobs: 6 | test: 7 | runs-on: ${{ matrix.os }} 8 | strategy: 9 | matrix: 10 | os: [ubuntu-latest] 11 | 12 | steps: 13 | - name: Checkout code 14 | uses: actions/checkout@v4 15 | 16 | - name: Set up Python 17 | uses: actions/setup-python@v4 18 | with: 19 | python-version: "3.13" 20 | 21 | - name: Set up Conda 22 | uses: conda-incubator/setup-miniconda@v2 23 | with: 24 | auto-activate-base: true 25 | channels: conda-forge 26 | 27 | - name: Install IPOPT via conda 28 | run: | 29 | conda init bash 30 | conda install -c conda-forge cyipopt pkg-config 31 | export LD_LIBRARY_PATH=$CONDA_PREFIX/lib:$LD_LIBRARY_PATH 32 | 33 | - name: Verify cyipopt installation 34 | run: | 35 | source ~/.bashrc 36 | conda activate base 37 | python -c "import cyipopt; print('cyipopt install OK')" 38 | 39 | - name: Install mpi4py via conda 40 | run: | 41 | conda init bash 42 | conda install -c conda-forge mpi4py mpich 43 | 44 | - name: Verify mpi4py installation 45 | run: | 46 | source ~/.bashrc 47 | conda activate base 48 | python -c "import mpi4py; print('mpi4py install OK')" 49 | 50 | - name: Install HiOpBBPy 51 | run: | 52 | source ~/.bashrc 53 | conda activate base 54 | python -m pip install --upgrade pip 55 | pip install . 56 | 57 | - name: Run BO Test 58 | run: | 59 | source ~/.bashrc 60 | conda activate base 61 | python src/Drivers/hiopbbpy/BODriverCI.py -nrepeat 10 62 | continue-on-error: false 63 | 64 | - name: Run MPI Evaluator Test 65 | run: | 66 | source ~/.bashrc 67 | conda activate base 68 | python src/Drivers/hiopbbpy/EvaluationManagerCI.py -n 10 -t 0.001 69 | continue-on-error: false 70 | -------------------------------------------------------------------------------- /src/LinAlg/load_kkt_mat.m: -------------------------------------------------------------------------------- 1 | %% specify filename 2 | filename = 'kkt_linsys_0.iajaaa'; 3 | f = fopen(filename,'r'); 4 | A = fscanf(f, '%f'); 5 | fclose(f); 6 | 7 | %% data loading 8 | m=A(1); % matrix size 9 | nx=A(2); % number of (primal) variables of the underlying NLP 10 | meq=A(3); % number of equalities of the underlying NLP 11 | nineq=A(4); % number of inequalities of the underlying NLP 12 | nnz=A(5); % number of nnz of matrix (or of the upper triangle for symmetric matrices) 13 | rowp = A(6:m+6); % row pointers in colidx and vals (see below) 14 | colidx=A(m+7:nnz+m+6); % column indexes for each nz 15 | vals=A(nnz+m+7:nnz+nnz+m+6); % values for each nz 16 | has_rhs = true; 17 | try 18 | rhs=A(nnz+nnz+m+7:nnz+nnz+m+m+6); % rhs 19 | catch 20 | warning('Cannot find rhs from the file. Set rhs as a vector of ones.'); 21 | rhs = ones(m,1); 22 | has_rhs = false; 23 | end 24 | has_sol = true; 25 | try 26 | sol=A(nnz+nnz+m+m+7:nnz+nnz+m+m+m+6); % solution 27 | catch 28 | warning('Cannot find sol from the file.'); 29 | has_sol = false; 30 | end 31 | 32 | fprintf('Loaded a matrix of size %d with %d nonzeros from "%s"\n', ... 33 | m, nnz, filename); 34 | 35 | %% convert to triplet needed by Matlab's 'sparse' 36 | rowidx=zeros(nnz,1); 37 | for ii=2:m+1 38 | for jj=rowp(ii-1):(rowp(ii)-1) 39 | rowidx(jj) = ii-1; 40 | end 41 | end 42 | 43 | %% form the matrix 44 | M = sparse(rowidx, colidx, vals, m, m); 45 | 46 | % if the matrix is known to be symmetric, it is either lower or upper 47 | % triangle 48 | if istril(M) 49 | % A. the lower triangle was saved 50 | M=M+transpose(tril(M,-1)); 51 | else 52 | if istriu(M) 53 | %the upper triangle was saved 54 | M=M+transpose(triu(M,1)); 55 | else 56 | %the matrix is not symmetric; do nothing 57 | end 58 | end 59 | 60 | %% solve using Matlab and check the residuals of the Matlab solution 61 | %% and of the solution from .iajaaa file 62 | if has_sol == true 63 | sol2 = M\rhs; 64 | fprintf('residuals norm: Matlab sol %.5e sol from file: %.5e\n', ... 65 | norm(M* sol2 - rhs), norm(M* sol - rhs)); 66 | end -------------------------------------------------------------------------------- /scripts/platforms/marianas/spack.yaml: -------------------------------------------------------------------------------- 1 | spack: 2 | specs: 3 | - hiop%gcc@10.2.0@develop+cuda+deepchecking+sparse+kron+cusolver_lu+ginkgo+raja cuda_arch=60 4 | - raja@0.14.0 5 | - umpire@6.0.0 6 | - coinhsl@2019.05.21 7 | view: false 8 | concretizer: 9 | unify: true 10 | packages: 11 | ipopt: 12 | version: 13 | - 3.12.10 14 | variants: 15 | - +debug 16 | - +coinhsl 17 | - ~mumps 18 | raja: 19 | variants: 20 | - ~examples 21 | - ~exercises 22 | umpire: 23 | variants: 24 | - ~openmp 25 | - ~examples 26 | python: 27 | externals: 28 | - spec: python@3.7.0 29 | prefix: /share/apps/python/3.7.0 30 | modules: 31 | - python/3.7.0 32 | all: 33 | providers: 34 | mpi: 35 | - openmpi 36 | openmpi: 37 | externals: 38 | - spec: openmpi@4.1.0%gcc@10.2.0 39 | modules: 40 | - openmpi/4.1.0 41 | prefix: /share/apps/openmpi/4.1.0/gcc/10.2.0 42 | buildable: false 43 | cuda: 44 | externals: 45 | - spec: cuda@11.4 46 | modules: 47 | - cuda/11.4 48 | buildable: false 49 | perl: 50 | externals: 51 | - spec: perl@5.26.0 52 | modules: 53 | - perl/5.26.0 54 | compilers: 55 | - compiler: 56 | spec: gcc@4.8.5 57 | paths: 58 | cc: /usr/bin/gcc 59 | cxx: /usr/bin/g++ 60 | f77: /usr/bin/gfortran 61 | fc: /usr/bin/gfortran 62 | operating_system: centos7 63 | target: x86_64 64 | modules: 65 | - gcc/4.8.5 66 | - compiler: 67 | spec: gcc@10.2.0 68 | paths: 69 | cc: /share/apps/gcc/10.2.0/bin/gcc 70 | cxx: /share/apps/gcc/10.2.0/bin/g++ 71 | f77: /share/apps/gcc/10.2.0/bin/gfortran 72 | fc: /share/apps/gcc/10.2.0/bin/gfortran 73 | flags: {} 74 | operating_system: centos7 75 | target: x86_64 76 | modules: [] 77 | environment: {} 78 | extra_rpaths: [] 79 | develop: 80 | hiop: 81 | path: /qfs/projects/exasgd/src/cameron/hiop-git 82 | spec: hiop@develop 83 | -------------------------------------------------------------------------------- /cmake/FindHiopHipLibraries.cmake: -------------------------------------------------------------------------------- 1 | #[[ 2 | 3 | Exports target `hiop_hip` which finds all hip libraries needed by hiop. 4 | 5 | #]] 6 | 7 | add_library(hiop_hip INTERFACE) 8 | add_library(Hipblas INTERFACE) 9 | 10 | # Get ROCm CMake Helpers onto your CMake Module Path 11 | if (NOT DEFINED ROCM_PATH ) 12 | if (NOT DEFINED ENV{ROCM_PATH} ) 13 | set(ROCM_PATH "/opt/rocm" CACHE PATH "ROCm path") 14 | else() 15 | set(ROCM_PATH $ENV{ROCM_PATH} CACHE PATH "ROCm path") 16 | endif() 17 | endif() 18 | set(CMAKE_MODULE_PATH "${ROCM_PATH}/lib/cmake" ${CMAKE_MODULE_PATH}) 19 | 20 | # Set GPU Targets and Find all the HIP modules 21 | set(GPU_TARGETS "gfx908" CACHE STRING "The GPU TARGETs") 22 | find_package(hip REQUIRED) 23 | find_package(hipfft REQUIRED) 24 | find_package(hiprand REQUIRED) 25 | find_package(rocrand REQUIRED) 26 | message(STATUS "Found Hipblas include: ${HIPBLAS_INCLUDE_DIR}") 27 | message(STATUS "Found Hipblas library: ${HIPBLAS_LIBRARY}") 28 | find_package(hipblas REQUIRED) 29 | find_package(rocblas REQUIRED) 30 | message(STATUS "Found Hipblas include: ${HIPBLAS_INCLUDE_DIR}") 31 | message(STATUS "Found Hipblas library: ${HIPBLAS_LIBRARY}") 32 | find_package(hipcub REQUIRED) 33 | find_package(rocprim REQUIRED) 34 | 35 | target_link_libraries(Hipblas INTERFACE ${HIPBLAS_LIBRARY}) 36 | target_include_directories(Hipblas INTERFACE ${HIPBLAS_INCLUDE_DIR}) 37 | 38 | # for now we rely on MAGMA for GPUs computations 39 | include(FindHiopMagma) 40 | target_link_libraries(Magma INTERFACE Hipblas) 41 | 42 | target_include_directories(hiop_hip INTERFACE ${ROCM_PATH}/include/hipfft) 43 | target_link_libraries(hiop_hip INTERFACE 44 | hip::hiprand roc::rocrand 45 | hip::hipfft 46 | roc::hipblas roc::rocblas 47 | hip::hipcub roc::rocprim_hip 48 | Magma 49 | ) 50 | 51 | message(STATUS "HiOp support for GPUs is on") 52 | get_target_property(hip_includes hiop_hip INTERFACE_INCLUDE_DIRECTORIES) 53 | message(STATUS "HIP include directories: ${hip_includes}") 54 | get_target_property(hip_libraries hiop_hip INTERFACE_LINK_LIBRARIES) 55 | message(STATUS "HIP linked libraries: ${hip_libraries}") 56 | 57 | install(TARGETS Hipblas hiop_hip EXPORT hiop-targets) 58 | 59 | -------------------------------------------------------------------------------- /cmake/HiOpConfig.cmake.in: -------------------------------------------------------------------------------- 1 | # Author(s): 2 | # - Cameron Rutherford 3 | 4 | include( "${CMAKE_CURRENT_LIST_DIR}/HiOpTargets.cmake" ) 5 | 6 | # Configure TPLs if not already in an export set 7 | 8 | # If using MPI, make sure module is loaded 9 | if(@HIOP_USE_MPI@ AND NOT TARGET MPI::MPI_CXX) 10 | find_package(MPI REQUIRED) 11 | include_directories(@MPI_CXX_ADDITIONAL_INCLUDE_DIRS@ @MPI_CXX_COMPILER_INCLUDE_DIRS@) 12 | if(NOT DEFINED MPI_CXX_COMPILER) 13 | set(CMAKE_CXX_COMPILER @MPI_CXX_COMPILER@) 14 | set(CMAKE_C_COMPILER @MPI_C_COMPILER@) 15 | endif() 16 | include_directories(@MPI_Fortran_ADDITIONAL_INCLUDE_DIRS@ @MPI_Fortran_COMPILER_INCLUDE_DIRS@) 17 | endif() 18 | 19 | if(@HIOP_USE_RAJA@ AND NOT TARGET OpenMP::OpenMP_CXX) 20 | find_package(OpenMP) 21 | endif() 22 | 23 | # Need to export RAJA and umpire as they have find_package 24 | if(@HIOP_USE_RAJA@ AND NOT TARGET RAJA) 25 | find_package(RAJA PATHS @RAJA_DIR@) 26 | find_package(umpire PATHS @umpire_DIR@) 27 | endif() 28 | 29 | set(HiOp::SPARSE @HIOP_SPARSE@ CACHE BOOL "indicates if hiop sparse is enabled") 30 | 31 | if(@HIOP_USE_GINKGO@ AND NOT TARGET Ginkgo) 32 | find_package(Ginkgo PATHS @Ginkgo_DIR@) 33 | endif() 34 | 35 | if(@HIOP_USE_GPU@) 36 | if(@HIOP_USE_CUDA@) 37 | include(CheckLanguage) 38 | # This must come before enable_language(CUDA) 39 | set(CMAKE_CUDA_COMPILER @CMAKE_CUDA_COMPILER@) 40 | enable_language(CUDA) 41 | check_language(CUDA) 42 | set(CMAKE_CUDA_FLAGS "@CMAKE_CUDA_FLAGS@") 43 | find_package(CUDAToolkit REQUIRED) 44 | elseif(@HIOP_USE_HIP@) 45 | find_package(hip REQUIRED) 46 | find_package(hipfft REQUIRED) 47 | find_package(hiprand REQUIRED) 48 | find_package(rocrand REQUIRED) 49 | find_package(hipblas REQUIRED) 50 | find_package(rocblas REQUIRED) 51 | find_package(hipcub REQUIRED) 52 | find_package(rocprim REQUIRED) 53 | add_definitions(-DHAVE_HIP) # For hipmagma 54 | endif() 55 | endif() 56 | 57 | # Add HiOp::HiOp alias library 58 | if(@HIOP_BUILD_SHARED@ AND NOT TARGET HiOp::HiOp) 59 | add_library(HiOp::HiOp ALIAS HiOp::@hiop_default_library_name@) 60 | endif() 61 | 62 | if(@HIOP_BUILD_STATIC@ AND NOT TARGET HiOp::HiOp) 63 | add_library(HiOp::HiOp ALIAS HiOp::@hiop_default_library_name@) 64 | endif() 65 | 66 | -------------------------------------------------------------------------------- /scripts/platforms/summit/spack.yaml: -------------------------------------------------------------------------------- 1 | spack: 2 | specs: 3 | - hiop@develop+cuda+raja+sparse+mpi+ginkgo+cusolver cuda_arch=70 build_type=Release 4 | ^raja@0.14.0 5 | ^umpire@6.0.0 6 | ^openblas 7 | compilers: 8 | - compiler: 9 | spec: gcc@10.2.0 10 | paths: 11 | cc: /sw/summit/gcc/10.2.0-2/bin/gcc 12 | cxx: /sw/summit/gcc/10.2.0-2/bin/g++ 13 | f77: /sw/summit/gcc/10.2.0-2/bin/gfortran 14 | fc: /sw/summit/gcc/10.2.0-2/bin/gfortran 15 | flags: {} 16 | operating_system: rhel8 17 | target: ppc64le 18 | modules: [gcc/10.2.0] 19 | environment: {} 20 | extra_rpaths: [] 21 | config: 22 | concretizer: clingo 23 | concretizer: 24 | unify: true 25 | targets: 26 | granularity: generic 27 | packages: 28 | all: 29 | providers: 30 | mpi: [spectrum-mpi] 31 | blas: [openblas] 32 | lapack: [openblas] 33 | python: 34 | externals: 35 | - spec: python@3.8.10 36 | modules: [python/3.8.10] 37 | buildable: false 38 | spectrum-mpi: 39 | externals: 40 | - spec: spectrum-mpi@10.4.0.3-20210112 41 | modules: [spectrum-mpi/10.4.0.3-20210112] 42 | buildable: false 43 | ipopt: 44 | version: [3.12.10] 45 | variants: +coinhsl+metis~mumps 46 | coinhsl: 47 | variants: +blas 48 | cuda: 49 | externals: 50 | - spec: cuda@11.5.2 51 | modules: [cuda/11.5.2] 52 | buildable: false 53 | raja: 54 | version: [0.14.0] 55 | variants: +cuda cuda_arch=70 build_type=Release 56 | umpire: 57 | version: [6.0.0] 58 | variants: ~c+cuda cuda_arch=70 build_type=Release 59 | magma: 60 | version: [2.6.1] 61 | variants: +cuda cuda_arch=70 build_type=Release 62 | cmake: 63 | externals: 64 | - spec: cmake@3.21.3 65 | modules: [cmake/3.21.3] 66 | buildable: false 67 | metis: 68 | externals: 69 | - spec: metis@5.1.0 70 | modules: [metis/5.1.0] 71 | buildable: false 72 | openblas: 73 | externals: 74 | - spec: openblas@0.17.0 75 | modules: [openblas/0.3.17-omp] 76 | buildable: false 77 | perl: 78 | externals: 79 | - spec: perl@5.30.1 80 | modules: [perl/5.30.1] 81 | buildable: false 82 | ginkgo: 83 | version: [glu_experimental] 84 | variants: +cuda cuda_arch=70 85 | -------------------------------------------------------------------------------- /src/Drivers/PriDec/NlpPriDecEx3SparseDriver.cpp: -------------------------------------------------------------------------------- 1 | #include "NlpPriDecEx3Sparse.hpp" 2 | #include "hiopNlpFormulation.hpp" 3 | #include "hiopAlgFilterIPM.hpp" 4 | 5 | using namespace hiop; 6 | 7 | #ifdef HIOP_USE_MAGMA 8 | #include "magma_v2.h" 9 | #endif 10 | 11 | #include 12 | #include 13 | 14 | /** 15 | * Driver for Sparse Example 3 that illustrates the use of hiop::hiopAlgPrimalDecomposition 16 | * 17 | * @note This example is built only when HIOP_USE_MPI and HIOP_SPARSE are enabled during cmake build 18 | * and require at least two MPI ranks in MPI_COMM_WORLD. 19 | * 20 | */ 21 | 22 | // 23 | // TODO: add -selfcheck option (see other drivers) and add the driver to cmake tests 24 | // 25 | 26 | using namespace hiop; 27 | 28 | int main(int argc, char **argv) 29 | { 30 | int rank = 0; 31 | #ifdef HIOP_USE_MPI 32 | MPI_Init(&argc, &argv); 33 | int comm_size; 34 | int ierr = MPI_Comm_size(MPI_COMM_WORLD, &comm_size); 35 | assert(MPI_SUCCESS == ierr); 36 | ierr = MPI_Comm_rank(MPI_COMM_WORLD, &rank); 37 | assert(MPI_SUCCESS == ierr); 38 | double t3 = MPI_Wtime(); 39 | double t4 = 0.; 40 | #endif 41 | 42 | #ifdef HIOP_USE_MAGMA 43 | magma_init(); 44 | #endif 45 | int nx = 1000; 46 | int S = 1920; 47 | int nS = 5; 48 | double x[nx + S * nx]; 49 | 50 | SparseEx3 nlp_interface(nx, S, nS); 51 | hiopNlpSparse nlp(nlp_interface); 52 | nlp.options->SetStringValue("compute_mode", "cpu"); // using CPU only in computations 53 | nlp.options->SetStringValue("KKTLinsys", "xdycyd"); 54 | // nlp.options->SetStringValue("KKTLinsys", "full"); 55 | 56 | hiopAlgFilterIPMNewton solver(&nlp); 57 | hiopSolveStatus status = solver.run(); 58 | 59 | double obj_value = solver.getObjective(); 60 | 61 | solver.getSolution(x); 62 | for(int i = 0; i < nx; i++) { 63 | printf("x%d %18.12e ", i, x[i]); 64 | } 65 | printf(" \n"); 66 | 67 | if(status != Solve_Success) { 68 | if(rank == 0) printf("Solve was NOT successfull."); 69 | } else { 70 | if(rank == 0) printf("Solve was successfull. Optimal value: %12.5e\n", obj_value); 71 | } 72 | #ifdef HIOP_USE_MPI 73 | t4 = MPI_Wtime(); 74 | printf("Elapsed time for sparseex9 is %f\n", t4 - t3); 75 | #endif 76 | 77 | #ifdef HIOP_USE_MAGMA 78 | magma_finalize(); 79 | #endif 80 | #ifdef HIOP_USE_MPI 81 | MPI_Finalize(); 82 | #endif 83 | 84 | printf("Returned successfully from driver! Rank=%d\n", rank); 85 | ; 86 | return 0; 87 | } 88 | -------------------------------------------------------------------------------- /src/Utils/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(hiopUtils_SRC 2 | hiopLogger.cpp 3 | hiopOptions.cpp 4 | MathKernelsHost.cpp 5 | ) 6 | 7 | set(hiopUtils_RAJA_SRC 8 | RajaUmpireUtils.cpp 9 | ) 10 | 11 | set(hiopUtils_KRON_REDUCTION_SRC 12 | hiopKronReduction.cpp 13 | ) 14 | 15 | set(hiopUtils_INTERFACE_HEADERS 16 | hiopCSR_IO.hpp 17 | hiopCppStdUtils.hpp 18 | hiopKronReduction.hpp 19 | hiopLogger.hpp 20 | hiopMPI.hpp 21 | hiopOptions.hpp 22 | hiopRunStats.hpp 23 | hiopTimer.hpp 24 | MathKernelsHost.hpp 25 | ) 26 | 27 | if(HIOP_USE_CUDA) 28 | list(APPEND hiopUtils_INTERFACE_HEADERS MathKernelsCuda.hpp) 29 | endif() 30 | 31 | if(HIOP_USE_HIP) 32 | list(APPEND hiopUtils_INTERFACE_HEADERS MathKernelsHip.hpp) 33 | endif() 34 | 35 | if(HIOP_USE_RAJA) 36 | list(APPEND hiopUtils_INTERFACE_HEADERS RajaUmpireUtils.hpp) 37 | list(APPEND hiopUtils_SRC ${hiopUtils_RAJA_SRC}) 38 | endif() 39 | 40 | if(HIOP_USE_CUDA) 41 | # RAJA-related 42 | set_source_files_properties(${hiopUtils_RAJA_SRC} PROPERTIES LANGUAGE CUDA) 43 | 44 | # CUDA kernels 45 | set(hiopUtils_CUDA_SRC MathKernelsCuda.cu) 46 | set_source_files_properties(${hiopUtils_CUDA_SRC} PROPERTIES LANGUAGE CUDA) 47 | list(APPEND hiopUtils_SRC ${hiopUtils_CUDA_SRC}) 48 | endif() 49 | 50 | if(HIOP_USE_HIP) 51 | # Mark appropriate source files as HIP. I guess in the future just a 52 | # LANGUAGE HIP property will suffice. For now do it via compile flags 53 | # set_source_files_properties(${hiopUtils_HIP_SRC} PROPERTIES LANGUAGE HIP) 54 | # Reference: https://www.olcf.ornl.gov/wp-content/uploads/2021/01/2021UM-Day-3-Joo-Developing-for-Frontier-using-HIP-on-Spock.pdf 55 | 56 | # RAJA-related 57 | set_source_files_properties(${hiopUtils_RAJA_SRC} PROPERTIES LANGUAGE CXX) 58 | set_source_files_properties(${hiopUtils_RAJA_SRC} PROPERTIES COMPILE_FLAGS "-x hip") 59 | 60 | # HIP kernels 61 | set(hiopUtils_HIP_SRC MathKernelsHip.cpp) 62 | set_source_files_properties( ${hiopUtils_HIP_SRC} PROPERTIES LANGUAGE CXX) 63 | set_source_files_properties( ${hiopUtils_HIP_SRC} PROPERTIES COMPILE_FLAGS "-x hip") 64 | list(APPEND hiopUtils_SRC ${hiopUtils_HIP_SRC}) 65 | endif() 66 | 67 | if(HIOP_WITH_KRON_REDUCTION) 68 | list(APPEND hiopUtils_SRC ${hiopUtils_KRON_REDUCTION_SRC}) 69 | endif() 70 | 71 | install(FILES ${hiopUtils_INTERFACE_HEADERS} DESTINATION include) 72 | 73 | add_library(hiopUtils OBJECT ${hiopUtils_SRC}) 74 | target_link_libraries(hiopUtils PRIVATE hiop_tpl) 75 | -------------------------------------------------------------------------------- /src/hiopbbpy/surrogate_modeling/krg.py: -------------------------------------------------------------------------------- 1 | ''' 2 | A subclass of GaussianProcess that implements a Kriging surrogate model using package SMT 3 | 4 | Authors: Tucker Hartland 5 | Nai-Yuan Chiang 6 | ''' 7 | 8 | import numpy as np 9 | from .gp import GaussianProcess 10 | from smt.surrogate_models import KRG 11 | from smt.design_space import DesignSpace 12 | 13 | 14 | class smtKRG(GaussianProcess): 15 | def __init__(self, theta, xlimits, ndim, corr="pow_exp", noise0=None, random_state=None): 16 | super().__init__(ndim, xlimits) 17 | if random_state is None: 18 | random_state = 42 19 | design_space = DesignSpace(xlimits, random_state=random_state) 20 | if noise0 is None: 21 | self.surrogatesmt = KRG(design_space=design_space, 22 | print_global=False, 23 | eval_noise=False, 24 | corr=corr) 25 | else: 26 | self.surrogatesmt = KRG(design_space=design_space, 27 | print_global=False, 28 | noise0=noise0, 29 | eval_noise=False, 30 | corr=corr) 31 | self.trained = False 32 | 33 | def mean(self, x): 34 | if not self.trained: 35 | raise ValueError("must train kriging model before utilizing it to predict mean or variances") 36 | return self.surrogatesmt.predict_values(x) 37 | 38 | def variance(self, x): 39 | if not self.trained: 40 | raise ValueError("must train kriging model before utilizing it to predict mean or variances") 41 | return self.surrogatesmt.predict_variances(x) 42 | 43 | def train(self, x, y): 44 | self.training_x = x 45 | self.training_y = y 46 | self.surrogatesmt.set_training_values(x, y) 47 | self.surrogatesmt.train() 48 | self.trained = True 49 | 50 | def mean_gradient(self, x: np.ndarray) -> np.ndarray: 51 | if not self.trained: 52 | raise ValueError("must train kriging model before utilizing it to predict gradient") 53 | assert (np.size(x,-1) == self.ndim) 54 | gradient = [self.surrogatesmt._predict_derivatives(x, kx) for kx in range(self.ndim)] 55 | return np.atleast_2d(gradient).T 56 | 57 | def variance_gradient(self, x: np.ndarray) -> np.ndarray: 58 | if not self.trained: 59 | raise ValueError("must train kriging model before utilizing it to predict gradient") 60 | return self.surrogatesmt.predict_variance_gradient(x) 61 | -------------------------------------------------------------------------------- /src/Drivers/hiopbbpy/EvaluationManagerCI.py: -------------------------------------------------------------------------------- 1 | """ 2 | This is a class to manage function evaluations using multiple parallel executors. 3 | It supports both intra-node and inter-node parallelism. 4 | 5 | Authors: Tucker Hartland 6 | Weslley S Pereira 7 | """ 8 | import logging 9 | import argparse 10 | import time 11 | import sys 12 | from hiopbbpy.utils import EvaluationManager, is_running_with_mpi 13 | from concurrent.futures import ThreadPoolExecutor 14 | 15 | def _fn_for_test(x, sleep_time=0.1): 16 | if is_running_with_mpi(): 17 | from mpi4py import MPI 18 | comm = MPI.COMM_WORLD 19 | rank = comm.Get_rank() 20 | print(f"Rank {rank}: Processing {x}") 21 | time.sleep(sleep_time) # Simulate some work 22 | return x * x 23 | 24 | 25 | 26 | if __name__ == "__main__": 27 | # Arguments for command line 28 | parser = argparse.ArgumentParser( 29 | description="Execute n function calls with t duration.", 30 | epilog="To properly run the example with mpi4py, use: env MPI4PY_FUTURES_MAX_WORKERS= mpiexec -n 1 python evaluation_manager.py", 31 | ) 32 | parser.add_argument("-n", type=int, default=100, help="Number of tasks to execute") 33 | parser.add_argument( 34 | "-t", "--sleep_time", type=float, default=1, help="Sleep time for each task" 35 | ) 36 | args = parser.parse_args() 37 | 38 | if is_running_with_mpi(): 39 | executor_type = "mpi" 40 | else: 41 | executor_type = "cpu" 42 | 43 | # Set up logging 44 | logging.basicConfig(level=logging.INFO) 45 | 46 | # Create manager 47 | cpu_executor = ThreadPoolExecutor() 48 | manager = EvaluationManager(cpu_executor=cpu_executor) 49 | 50 | # Submit tasks to the manager 51 | t0 = time.perf_counter() 52 | manager.submit_tasks( 53 | _fn_for_test, 54 | [i for i in range(args.n)], 55 | execute_at=executor_type, 56 | sleep_time=args.sleep_time, 57 | ) 58 | 59 | # Do some other work while tasks are running 60 | print("Doing other work", end="", flush=True) 61 | for i in range(5): 62 | print(".", end="", flush=True) 63 | time.sleep(args.sleep_time) 64 | print(" Done.") 65 | 66 | # Wait for all tasks to complete 67 | print("Waiting for tasks to complete...") 68 | manager.sync() 69 | t1 = time.perf_counter() 70 | 71 | # Retrieve and show results 72 | X, F = manager.retrieve_results() 73 | print("X:", X) 74 | print("F:", F) 75 | print(f"Total time: {t1 - t0:.2f} seconds") 76 | 77 | # Clean up 78 | del manager 79 | retval = 0 80 | sys.exit(retval) 81 | -------------------------------------------------------------------------------- /src/Interface/hiopVersion.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include "hiop_defs.hpp" 6 | 7 | namespace hiop 8 | { 9 | /** 10 | * @brief Contains statically determinable information about the current HiOp 11 | * build. 12 | */ 13 | struct hiopVersion 14 | { 15 | static constexpr bool useGPU = 16 | #ifdef HIOP_USE_GPU 17 | true; 18 | #else 19 | false; 20 | #endif 21 | 22 | static constexpr bool useMPI = 23 | #ifdef HIOP_USE_MPI 24 | true; 25 | #else 26 | false; 27 | #endif 28 | 29 | static constexpr bool useMagma = 30 | #ifdef HIOP_USE_MAGMA 31 | true; 32 | #else 33 | false; 34 | #endif 35 | 36 | static constexpr bool useRAJA = 37 | #ifdef HIOP_USE_RAJA 38 | true; 39 | #else 40 | false; 41 | #endif 42 | 43 | static constexpr bool useSparse = 44 | #ifdef HIOP_SPARSE 45 | true; 46 | #else 47 | false; 48 | #endif 49 | 50 | static constexpr bool useCOINHSL = 51 | #ifdef HIOP_USE_COINHSL 52 | true; 53 | #else 54 | false; 55 | #endif 56 | 57 | static constexpr bool useSTRUMPACK = 58 | #ifdef HIOP_USE_STRUMPACK 59 | true; 60 | #else 61 | false; 62 | #endif 63 | 64 | static constexpr bool usePARDISO = 65 | #ifdef HIOP_USE_PARDISO 66 | true; 67 | #else 68 | false; 69 | #endif 70 | 71 | static constexpr bool useReSolve = 72 | #ifdef HIOP_USE_RESOLVE 73 | true; 74 | #else 75 | false; 76 | #endif 77 | 78 | static constexpr bool useGINKGO = 79 | #ifdef HIOP_USE_GINKGO 80 | true; 81 | #else 82 | false; 83 | #endif 84 | 85 | static inline void version(int& major, int& minor, int& patch) 86 | { 87 | major = std::atoi(HIOP_VERSION_MAJOR); 88 | minor = std::atoi(HIOP_VERSION_MINOR); 89 | patch = std::atoi(HIOP_VERSION_PATCH); 90 | } 91 | 92 | static inline std::string version() { return HIOP_VERSION; } 93 | static inline std::string releaseDate() { return HIOP_RELEASE_DATE; } 94 | 95 | static inline std::string fullVersionInfo() 96 | { 97 | auto fmt = [](bool use) { return use ? "YES" : "NO"; }; 98 | std::stringstream ss; 99 | ss << "HiOp " << version() << " compiled on " << releaseDate() << "\n" 100 | << "Built with:" 101 | << "\nGPU: " << fmt(useGPU) << "\nMPI: " << fmt(useMPI) << "\nMAGMA: " << fmt(useMagma) << "\nRAJA: " << fmt(useRAJA) 102 | << "\nSparse: " << fmt(useSparse) << "\nCOINHSL: " << fmt(useCOINHSL) << "\nSTRUMPACK: " << fmt(useSTRUMPACK) 103 | << "\nPARDISO: " << fmt(usePARDISO) << "\nReSolve: " << fmt(useReSolve) << "\n"; 104 | return ss.str(); 105 | } 106 | }; 107 | 108 | } // namespace hiop 109 | -------------------------------------------------------------------------------- /src/Utils/hiopCppStdUtils.hpp: -------------------------------------------------------------------------------- 1 | #ifndef HIOP_STD_UTILS 2 | #define HIOP_STD_UTILS 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | namespace hiop 18 | { 19 | template 20 | inline void printvec(const std::vector& v, const std::string& msg = "") 21 | { 22 | std::cout.precision(6); 23 | std::cout << msg << " size:" << v.size() << std::endl; 24 | std::cout << std::scientific; 25 | typename std::vector::const_iterator it = v.begin(); 26 | for(; it != v.end(); ++it) std::cout << (*it) << " "; 27 | std::cout << std::endl; 28 | } 29 | 30 | template 31 | inline void printlist(const std::list& v, const std::string& msg = "") 32 | { 33 | std::cout.precision(6); 34 | std::cout << msg << " size:" << v.size() << std::endl; 35 | std::cout << std::scientific; 36 | typename std::list::const_iterator it = v.begin(); 37 | for(; it != v.end(); ++it) std::cout << (*it) << " "; 38 | std::cout << std::endl; 39 | } 40 | 41 | template 42 | inline void printvecvec(const std::vector >& v, const std::string& msg = "") 43 | { 44 | std::cout.precision(6); 45 | std::cout << msg << " size:" << v.size() << std::endl; 46 | std::cout << std::scientific; 47 | for(auto& l: v) { 48 | for(auto& c: l) std::cout << c << " "; 49 | std::cout << std::endl; 50 | } 51 | } 52 | template 53 | inline void hardclear(std::vector& in) 54 | { 55 | std::vector().swap(in); 56 | } 57 | 58 | static inline std::string tolower(const std::string& str_in) 59 | { 60 | auto str_out = str_in; 61 | std::transform(str_out.begin(), str_out.end(), str_out.begin(), ::tolower); 62 | return str_out; 63 | } 64 | 65 | static inline void tolower(std::string& str_in) { std::transform(str_in.begin(), str_in.end(), str_in.begin(), ::tolower); } 66 | 67 | static inline std::string toupper(const std::string& str_in) 68 | { 69 | auto str_out = str_in; 70 | std::transform(str_out.begin(), str_out.end(), str_out.begin(), ::toupper); 71 | return str_out; 72 | } 73 | static inline void toupper(std::string& str_in) { std::transform(str_in.begin(), str_in.end(), str_in.begin(), ::toupper); } 74 | 75 | // Function to reorder elements of arr[] according to index[] 76 | template 77 | inline void reorder(T* arr, const std::vector& index, int n) 78 | { 79 | const std::vector temp(arr, arr+n); 80 | 81 | // arr[i] should be present at index[i] index 82 | for(int i = 0; i < n; ++i) { 83 | arr[i] = temp[index[i]]; 84 | } 85 | } 86 | 87 | static inline unsigned long generate_seed() 88 | { 89 | #ifdef NDEBUG 90 | return std::random_device{}(); 91 | #else 92 | return 0; 93 | #endif 94 | } 95 | 96 | } // namespace hiop 97 | #endif 98 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License. Please also read “Additional BSD Notice” below. 2 | 3 | Copyright (c) 2017, Lawrence Livermore National Laboratory 4 | LLNL-CODE-742473.All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without modification, 7 | are permitted provided that the following conditions are met: 8 | i. Redistributions of source code must retain the above copyright notice, this list 9 | of conditions and the disclaimer below. 10 | ii. Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the disclaimer (as noted below) in the documentation and/or 12 | other materials provided with the distribution. 13 | iii. Neither the name of the LLNS/LLNL nor the names of its contributors may be used to 14 | endorse or promote products derived from this software without specific prior written 15 | permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 18 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 20 | SHALL LAWRENCE LIVERMORE NATIONAL SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR 21 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 24 | AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 26 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | 28 | Additional BSD Notice 29 | 1. This notice is required to be provided under our contract with the U.S. Department 30 | of Energy (DOE). This work was produced at Lawrence Livermore National Laboratory under 31 | Contract No. DE-AC52-07NA27344 with the DOE. 32 | 2. Neither the United States Government nor Lawrence Livermore National Security, LLC 33 | nor any of their employees, makes any warranty, express or implied, or assumes any 34 | liability or responsibility for the accuracy, completeness, or usefulness of any 35 | information, apparatus, product, or process disclosed, or represents that its use would 36 | not infringe privately-owned rights. 37 | 3. Also, reference herein to any specific commercial products, process, or services by 38 | trade name, trademark, manufacturer or otherwise does not necessarily constitute or 39 | imply its endorsement, recommendation, or favoring by the United States Government or 40 | Lawrence Livermore National Security, LLC. The views and opinions of authors expressed 41 | herein do not necessarily state or reflect those of the United States Government or 42 | Lawrence Livermore National Security, LLC, and shall not be used for advertising or 43 | product endorsement purposes. 44 | -------------------------------------------------------------------------------- /src/Drivers/IpoptAdapter/IpoptAdapter_driver.cpp: -------------------------------------------------------------------------------- 1 | #include "IpIpoptApplication.hpp" 2 | 3 | #include "IpoptAdapter.hpp" 4 | 5 | // use HiOp's MdsEx1 - mixed dense-sparse QP 6 | // #include "NlpMdsEx1.hpp" 7 | #include "NlpMdsEx2.hpp" 8 | 9 | #include 10 | 11 | using namespace Ipopt; 12 | using namespace hiop; 13 | // Example of how to use IpoptAdapter to solve HiOP-specified problems with Ipopt 14 | 15 | int main(int argv, char** argc) 16 | { 17 | // instantiate a HiOp problem 18 | // 19 | // MdsEx2 hiopNlp(300,100,true,true); 20 | MdsEx2 hiopNlp(0, 3, false, false, false); 21 | // 22 | // create 23 | 24 | // int n_sp = 12, n_de = 10; 25 | // MdsEx2 hiopNlp(n_sp, n_de); 26 | 27 | // Create a new instance of the Ipopt nlp 28 | // (use a SmartPtr, not raw) 29 | SmartPtr mynlp = new hiopMDS2IpoptTNLP(&hiopNlp); 30 | 31 | // Create a new instance of IpoptApplication 32 | // (use a SmartPtr, not raw) 33 | // We are using the factory, since this allows us to compile this 34 | // example with an Ipopt Windows DLL 35 | SmartPtr app = IpoptApplicationFactory(); 36 | 37 | // 38 | // HiOp-compatible Ipopt Options (Ipopt behaves or should behave like HiOp) 39 | // 40 | // app->Options()->SetStringValue("recalc_y", "no"); 41 | // app->Options()->SetStringValue("mu_strategy", "monotone"); 42 | // app->Options()->SetNumericValue("bound_push", 1e-2); 43 | // app->Options()->SetNumericValue("bound_relax_factor", 0.); 44 | // app->Options()->SetNumericValue("constr_mult_init_max", 0.001); 45 | 46 | // app->Options()->SetNumericValue("tol", 1e-7); 47 | app->Options()->SetStringValue("recalc_y", "no"); 48 | // app->Options()->SetIntegerValue("print_level", 11); 49 | app->Options()->SetStringValue("mu_strategy", "monotone"); 50 | app->Options()->SetNumericValue("bound_frac", 1e-8); 51 | app->Options()->SetNumericValue("bound_push", 1e-8); 52 | // app->Options()->SetNumericValue("slack_bound_push", 1e-24); 53 | app->Options()->SetNumericValue("bound_relax_factor", 0.); 54 | app->Options()->SetNumericValue("constr_mult_init_max", 0.001); 55 | 56 | // app->Options()->SetStringValue("output_file", "ipopt.out"); 57 | // app->Options()->SetStringValue("derivative_test", "second-order"); //"only-second-order" 58 | // Initialize the IpoptApplication and process the options 59 | ApplicationReturnStatus status; 60 | status = app->Initialize(); 61 | if(status != Solve_Succeeded) { 62 | std::cout << std::endl << std::endl << "*** Error during initialization!" << std::endl; 63 | return (int)status; 64 | } 65 | 66 | // Ask Ipopt to solve the problem 67 | status = app->OptimizeTNLP(mynlp); 68 | 69 | if(status == Solve_Succeeded) { 70 | std::cout << std::endl << std::endl << "*** The problem solved!" << std::endl; 71 | } else { 72 | std::cout << std::endl << std::endl << "*** The problem FAILED!" << std::endl; 73 | } 74 | 75 | // As the SmartPtrs go out of scope, the reference count 76 | // will be decremented and the objects will automatically 77 | // be deleted. 78 | 79 | return (int)status; 80 | } 81 | -------------------------------------------------------------------------------- /src/Drivers/IpoptAdapter/IpoptAdapterDriverPriDecEx1.cpp: -------------------------------------------------------------------------------- 1 | #include "IpIpoptApplication.hpp" 2 | 3 | #include "IpoptAdapter.hpp" 4 | 5 | // use HiOp's SparseEx1 - sparse NLP 6 | #include "NlpSparseEx1.hpp" 7 | 8 | #include 9 | 10 | using namespace Ipopt; 11 | using namespace hiop; 12 | // Example of how to use IpoptAdapter to solve HiOP-specified problems with Ipopt 13 | 14 | int main(int argv, char** argc) 15 | { 16 | // instantiate a HiOp problem 17 | // 18 | SparseEx1 hiopNlp(3, 1.0); 19 | // 20 | // create 21 | 22 | // int n_sp = 12, n_de = 10; 23 | // MdsEx2 hiopNlp(n_sp, n_de); 24 | 25 | // Create a new instance of the Ipopt nlp 26 | // (use a SmartPtr, not raw) 27 | SmartPtr mynlp = new hiopSparse2IpoptTNLP(&hiopNlp); 28 | 29 | // Create a new instance of IpoptApplication 30 | // (use a SmartPtr, not raw) 31 | // We are using the factory, since this allows us to compile this 32 | // example with an Ipopt Windows DLL 33 | SmartPtr app = IpoptApplicationFactory(); 34 | 35 | // 36 | // HiOp-compatible Ipopt Options (Ipopt behaves or should behave like HiOp) 37 | // 38 | // app->Options()->SetStringValue("recalc_y", "no"); 39 | // app->Options()->SetStringValue("mu_strategy", "monotone"); 40 | // app->Options()->SetNumericValue("bound_push", 1e-2); 41 | // app->Options()->SetNumericValue("bound_relax_factor", 0.); 42 | // app->Options()->SetNumericValue("constr_mult_init_max", 0.001); 43 | 44 | // app->Options()->SetNumericValue("tol", 1e-7); 45 | app->Options()->SetStringValue("recalc_y", "no"); 46 | // app->Options()->SetIntegerValue("print_level", 11); 47 | app->Options()->SetStringValue("mu_strategy", "monotone"); 48 | app->Options()->SetNumericValue("bound_frac", 1e-8); 49 | app->Options()->SetNumericValue("bound_push", 1e-8); 50 | // app->Options()->SetNumericValue("slack_bound_push", 1e-24); 51 | app->Options()->SetNumericValue("bound_relax_factor", 0.); 52 | // app->Options()->SetNumericValue("constr_mult_init_max", 0.001); 53 | app->Options()->SetNumericValue("kappa1", 1e-8); 54 | app->Options()->SetNumericValue("kappa2", 1e-8); 55 | 56 | app->Options()->SetStringValue("duals_init", "zero"); 57 | 58 | // app->Options()->SetStringValue("output_file", "ipopt.out"); 59 | // app->Options()->SetStringValue("derivative_test", "second-order"); //"only-second-order" 60 | // Initialize the IpoptApplication and process the options 61 | ApplicationReturnStatus status; 62 | status = app->Initialize(); 63 | if(status != Solve_Succeeded) { 64 | std::cout << std::endl << std::endl << "*** Error during initialization!" << std::endl; 65 | return (int)status; 66 | } 67 | 68 | // Ask Ipopt to solve the problem 69 | status = app->OptimizeTNLP(mynlp); 70 | 71 | if(status == Solve_Succeeded) { 72 | std::cout << std::endl << std::endl << "*** The problem solved!" << std::endl; 73 | } else { 74 | std::cout << std::endl << std::endl << "*** The problem FAILED!" << std::endl; 75 | } 76 | 77 | // As the SmartPtrs go out of scope, the reference count 78 | // will be decremented and the objects will automatically 79 | // be deleted. 80 | 81 | return (int)status; 82 | } 83 | -------------------------------------------------------------------------------- /COPYRIGHT: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2017, Lawrence Livermore National Security, LLC. 2 | # Produced at the Lawrence Livermore National Laboratory (LLNL). 3 | # Written by Cosmin G. Petra, petra1@llnl.gov. 4 | # LLNL-CODE-742473. All rights reserved. 5 | 6 | This file is part of HiOp. For details, see https://github.com/LLNL/hiop. HiOp 7 | is released under the BSD 3-clause license (https://opensource.org/licenses/BSD-3-Clause). 8 | Please also read “Additional BSD Notice” below. 9 | 10 | Redistribution and use in source and binary forms, with or without modification, 11 | are permitted provided that the following conditions are met: 12 | i. Redistributions of source code must retain the above copyright notice, this list 13 | of conditions and the disclaimer below. 14 | ii. Redistributions in binary form must reproduce the above copyright notice, 15 | this list of conditions and the disclaimer (as noted below) in the documentation and/or 16 | other materials provided with the distribution. 17 | iii. Neither the name of the LLNS/LLNL nor the names of its contributors may be used to 18 | endorse or promote products derived from this software without specific prior written 19 | permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 22 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 23 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 24 | SHALL LAWRENCE LIVERMORE NATIONAL SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR 25 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 28 | AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | Additional BSD Notice 33 | 1. This notice is required to be provided under our contract with the U.S. Department 34 | of Energy (DOE). This work was produced at Lawrence Livermore National Laboratory under 35 | Contract No. DE-AC52-07NA27344 with the DOE. 36 | 2. Neither the United States Government nor Lawrence Livermore National Security, LLC 37 | nor any of their employees, makes any warranty, express or implied, or assumes any 38 | liability or responsibility for the accuracy, completeness, or usefulness of any 39 | information, apparatus, product, or process disclosed, or represents that its use would 40 | not infringe privately-owned rights. 41 | 3. Also, reference herein to any specific commercial products, process, or services by 42 | trade name, trademark, manufacturer or otherwise does not necessarily constitute or 43 | imply its endorsement, recommendation, or favoring by the United States Government or 44 | Lawrence Livermore National Security, LLC. The views and opinions of authors expressed 45 | herein do not necessarily state or reflect those of the United States Government or 46 | Lawrence Livermore National Security, LLC, and shall not be used for advertising or 47 | product endorsement purposes. 48 | -------------------------------------------------------------------------------- /src/Drivers/Dense/NlpDenseConsEx4Driver.cpp: -------------------------------------------------------------------------------- 1 | #include "NlpDenseConsEx4.hpp" 2 | #include "hiopNlpFormulation.hpp" 3 | #include "hiopAlgFilterIPM.hpp" 4 | 5 | #include 6 | #include 7 | 8 | using namespace hiop; 9 | 10 | static bool self_check(double obj_value); 11 | 12 | static bool parse_arguments(int argc, char** argv, bool& self_check) 13 | { 14 | self_check = false; 15 | switch(argc) { 16 | case 1: 17 | // no arguments 18 | return true; 19 | break; 20 | case 2: // 1 arguments 21 | { 22 | if(std::string(argv[1]) == "-selfcheck") { 23 | self_check = true; 24 | } 25 | } break; 26 | default: 27 | return false; // 2 or more arguments 28 | } 29 | 30 | return true; 31 | }; 32 | 33 | static void usage(const char* exeName) 34 | { 35 | printf("hiOp driver %s that solves a tiny concave problem.\n", exeName); 36 | printf("Usage: \n"); 37 | printf(" '$ %s -selfcheck'\n", exeName); 38 | printf("Arguments:\n"); 39 | printf(" '-selfcheck': compares the optimal objective with a previously saved value. [optional]\n"); 40 | } 41 | 42 | int main(int argc, char** argv) 43 | { 44 | int rank = 0; 45 | #ifdef HIOP_USE_MPI 46 | MPI_Init(&argc, &argv); 47 | int ierr = MPI_Comm_rank(MPI_COMM_WORLD, &rank); 48 | assert(MPI_SUCCESS == ierr); 49 | // if(0==rank) printf("Support for MPI is enabled\n"); 50 | #endif 51 | bool selfCheck; 52 | 53 | if(!parse_arguments(argc, argv, selfCheck)) { 54 | usage(argv[0]); 55 | return 1; 56 | } 57 | 58 | DenseConsEx4 nlp_interface; 59 | // if(rank==0) printf("interface created\n"); 60 | hiopNlpDenseConstraints nlp(nlp_interface); 61 | // if(rank==0) printf("nlp formulation created\n"); 62 | 63 | nlp.options->SetStringValue("duals_update_type", "linear"); 64 | nlp.options->SetStringValue("compute_mode", "cpu"); 65 | nlp.options->SetNumericValue("mu0", 0.1); 66 | 67 | hiopAlgFilterIPM solver(&nlp); 68 | hiopSolveStatus status = solver.run(); 69 | 70 | double obj_value = solver.getObjective(); 71 | 72 | #ifdef HIOP_USE_MPI 73 | MPI_Finalize(); 74 | #endif 75 | 76 | if(status < 0) { 77 | if(rank == 0) printf("solver returned negative solve status: %d (with objective is %18.12e)\n", status, obj_value); 78 | return -1; 79 | } 80 | 81 | // this is used for "regression" testing when the driver is called with -selfcheck 82 | if(selfCheck) { 83 | if(!self_check(obj_value)) { 84 | return -1; 85 | } 86 | } else { 87 | if(rank == 0) { 88 | printf("Optimal objective: %22.14e. Solver status: %d\n", obj_value, status); 89 | } 90 | } 91 | 92 | return 0; 93 | } 94 | 95 | static bool self_check(double objval) 96 | { 97 | const double objval_saved = -3.32231409044575e+02; 98 | 99 | #define relerr 1e-6 100 | if(fabs((objval_saved - objval) / (1 + objval_saved)) > relerr) { 101 | printf("selfcheck failure. Objective (%18.12e) does not agree (%d digits) with the saved value (%18.12e).\n", 102 | objval, 103 | -(int)log10(relerr), 104 | objval_saved); 105 | return false; 106 | } else { 107 | printf("selfcheck success (%d digits)\n", -(int)log10(relerr)); 108 | } 109 | return true; 110 | } 111 | -------------------------------------------------------------------------------- /src/Interface/README.md: -------------------------------------------------------------------------------- 1 | HiOp supports three input formats: `hiopInterfaceDenseConstraints`,`hiopInterfaceSparse` and `hiopInterfaceMDS`. 2 | All formats are in the form of C++ interfaces (e.g., abstract classes), see [hiopInterface.hpp](hiopInterface.hpp) file, that the user must instantiate/implement and provide to HiOp. 3 | 4 | Please read carefully the (software) documentation provided in [hiopInterface.hpp](hiopInterface.hpp) and the (math) documentation provided in the [user manual](../../doc/hiop_usermanual.pdf). In addition, please be aware of the following notes in the case of `hiopInterfaceSpare` or `hiopInterfaceMDS`. 5 | 6 | ## Key points/conventions for `hiopInterfaceSparse` 7 | 8 | ### Jacobian and Hessian 9 | * both Jacobian and Hessian are sparse, and their triplet forms are user inputs via the interface. 10 | * Jacobian is implemented as a general sparse matrix and hence user need to provide all the nonzeros of it. 11 | * Hessian is implemented as a symmetric sparse matrix and hence user only need to provide a triangular part of it. 12 | * for conventions on symmetric matrices and sparse matrices see [this](../LinAlg/readme.md) 13 | 14 | 15 | ## Key points/conventions for `hiopInterfaceMDS` 16 | 17 | MDS stands for mixed dense-sparse, meaning that the derivatives (Jacobian and Hessian) have both dense and sparse blocks. The `hiopInterfaceMDS` allows the user to pass these blocks to HiOp, which then exploits this structure using a specialized linear algebra implementation. This feature is especially relevant for GPU (hybrid) computing mode. 18 | 19 | 20 | ### Optimization variables 21 | 22 | * the (vector of) optimization variables are supposed to be split in *dense* and *sparse* variables 23 | * HiOp expects the optimization variables in a certain order: sparse variables first, followed by dense variables 24 | * the implementer/user (inconveniently) has to keep an map between his internal variables indexes and the indexes HiOp expects in order to avoid expensive memory moves inside HiOp 25 | 26 | ### Jacobian 27 | 28 | * the columns in the Jacobian corresponding to sparse variables form the sparse Jacobian block (and can/should be provided as a sparse matrix, see `eval_Jac` function(s)) 29 | * the columns in the Jacobian corresponding to dense variables form the dense Jacobian block (and can/should be provided via the `double**` buffer provided by `eval_Jac` functions(); this buffer is primed to support double indexing, i.e., use `buffer[i][j]` to access the (i,j) element of the dense block) 30 | * as indicated at the previous bullet, the user needs to map the column/variable index in the true Jacobian to the column index in the sparse or dense Jacobian block. The indexes inside the sparse and dense Jacobian blocks is zero-based 31 | 32 | ### Hessian 33 | * the Hessian's structure is slightly different that of the Jacobian. The Hessian has three relevant blocks 34 | * Hessian with respect to (sparse,sparse) variables 35 | * Hessian with respect to (dense,dense) variables 36 | * Hessian with respect to (sparse,dense) variables, which is the transpose of (dense,sparse) Hessian. This blocks are ignored currently by HiOp (subject to change) 37 | * all the above indexing rules for the Jacobian blocks apply to the Hessian blocks 38 | * for conventions on symmetric matrices and sparse matrices see [this](../LinAlg/readme.md) 39 | 40 | -------------------------------------------------------------------------------- /src/Drivers/Dense/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(hiopDenseEx_INTERFACE_HEADERS 2 | NlpDenseConsEx1.hpp 3 | NlpDenseConsEx2.hpp 4 | NlpDenseConsEx3.hpp 5 | NlpDenseConsEx4.hpp 6 | ) 7 | 8 | add_executable(NlpDenseConsEx1.exe NlpDenseConsEx1.cpp NlpDenseConsEx1Driver.cpp) 9 | target_link_libraries(NlpDenseConsEx1.exe HiOp::HiOp) 10 | 11 | add_executable(NlpDenseConsEx2.exe NlpDenseConsEx2.cpp NlpDenseConsEx2Driver.cpp) 12 | target_link_libraries(NlpDenseConsEx2.exe HiOp::HiOp) 13 | 14 | add_executable(NlpDenseConsEx3.exe NlpDenseConsEx3Driver.cpp) 15 | target_link_libraries(NlpDenseConsEx3.exe HiOp::HiOp) 16 | 17 | add_executable(NlpDenseConsEx4.exe NlpDenseConsEx4.cpp NlpDenseConsEx4Driver.cpp) 18 | target_link_libraries(NlpDenseConsEx4.exe HiOp::HiOp) 19 | 20 | if(HIOP_BUILD_FORTRAN_EXAMPLE) 21 | add_executable(NlpDenseConsFEx1.exe NlpDenseConsFEx1.F90) 22 | target_link_libraries(NlpDenseConsFEx1.exe HiOp::HiOp) 23 | endif() 24 | 25 | install( 26 | FILES ${hiopDenseEx_INTERFACE_HEADERS} 27 | DESTINATION include 28 | ) 29 | 30 | ########################################################## 31 | # CMake Tests 32 | ########################################################## 33 | add_test(NAME NlpDenseCons1_5H COMMAND ${RUNCMD} "$" "500" "1.0" "-selfcheck") 34 | add_test(NAME NlpDenseCons1_5K COMMAND ${RUNCMD} "$" "5000" "1.0" "-selfcheck") 35 | add_test(NAME NlpDenseCons1_25K_InfDim COMMAND ${RUNCMD} "$" "25000" "1.0" "-selfcheck" "-use_L2") 36 | add_test(NAME NlpDenseCons1_50K COMMAND ${RUNCMD} "$" "50000" "1.0" "-selfcheck") 37 | if(HIOP_USE_MPI) 38 | add_test(NAME NlpDenseCons1_50K_mpi COMMAND ${MPICMD} -n 2 "$" "50000" "1.0" "-selfcheck") 39 | endif(HIOP_USE_MPI) 40 | add_test(NAME NlpDenseCons2_5H COMMAND ${RUNCMD} "$" "500" "-selfcheck") 41 | add_test(NAME NlpDenseCons2_5K COMMAND ${RUNCMD} "$" "5000" "-selfcheck") 42 | add_test(NAME NlpDenseCons2_UN_5K COMMAND ${RUNCMD} "$" "5000" "-unconstrained" "-selfcheck") 43 | add_test(NAME NlpDenseCons3_5H COMMAND ${RUNCMD} "$" "500" "-selfcheck") 44 | add_test(NAME NlpDenseCons3_5K COMMAND ${RUNCMD} "$" "5000" "-selfcheck") 45 | add_test(NAME NlpDenseCons3_50K COMMAND ${RUNCMD} "$" "50000" "-selfcheck") 46 | if(HIOP_USE_MPI) 47 | add_test(NAME NlpDenseCons3_50K_mpi COMMAND ${MPICMD} -n 2 "$" "50000" "-selfcheck") 48 | endif(HIOP_USE_MPI) 49 | 50 | add_test(NAME NlpDenseCons4 COMMAND ${RUNCMD} "$" "-selfcheck") 51 | if(HIOP_USE_MPI) 52 | add_test(NAME NlpDenseCons4_mpi COMMAND ${MPICMD} -n 2 "$" "-selfcheck") 53 | endif(HIOP_USE_MPI) 54 | 55 | if(HIOP_WITH_VALGRIND_TESTS) 56 | string(REPLACE ";" " " runcmd_str "${RUNCMD}") 57 | add_test( 58 | NAME NlpDenseCons1_5H_Valgrind 59 | COMMAND bash -c "${runcmd_str} ${HIOP_VALGRIND_CMD} $ 500 1.0 -selfcheck" 60 | ) 61 | endif() 62 | 63 | if(HIOP_BUILD_FORTRAN_EXAMPLE) 64 | add_test(NAME NlpDenseFinterface COMMAND ${RUNCMD} "$") 65 | endif() 66 | 67 | -------------------------------------------------------------------------------- /src/Drivers/MDS/hpc_benchmark.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #ifdef HIOP_USE_MPI 6 | #include "mpi.h" 7 | #endif 8 | 9 | #include 10 | 11 | using namespace std; 12 | 13 | void net_benchmark(const size_type baseDim); 14 | 15 | static const size_type default_num_doubles_per_rank = 32768; 16 | int main(int argc, char **argv) 17 | { 18 | int nranks = 1; 19 | #ifdef HIOP_USE_MPI 20 | MPI_Init(&argc, &argv); 21 | int err = MPI_Comm_size(MPI_COMM_WORLD, &nranks); 22 | assert(MPI_SUCCESS == err); 23 | #endif 24 | size_type base_dim = nranks * default_num_doubles_per_rank; 25 | if(argc > 1) base_dim = nranks * atol(argv[1]); 26 | 27 | net_benchmark(base_dim); 28 | 29 | #ifdef HIOP_USE_MPI 30 | MPI_Finalize(); 31 | #endif 32 | return 0; 33 | } 34 | 35 | const static int NUM_REPETES = 100; 36 | const static int NUM_REDUCES = 8; 37 | const static int NUM_TESTS = 5; 38 | const static int TEST_X_SIZE = 2; 39 | void net_benchmark(const size_type baseDim) 40 | { 41 | #ifndef HIOP_USE_MPI 42 | printf("non-MPI build, skipping network benchmark\n"); 43 | #else 44 | 45 | int nranks, my_rank; 46 | int err = MPI_Comm_size(MPI_COMM_WORLD, &nranks); 47 | assert(MPI_SUCCESS == err); 48 | err = MPI_Comm_rank(MPI_COMM_WORLD, &my_rank); 49 | assert(MPI_SUCCESS == err); 50 | 51 | if(0 == my_rank) printf("Network benchmark: base dimension is %lu\n", baseDim); 52 | 53 | vector > results(NUM_TESTS, vector(NUM_REPETES, 0.)); 54 | 55 | for(int r = 0; r < NUM_REPETES; r++) { 56 | size_type loc_size = baseDim / nranks; 57 | for(int t = 1; t <= NUM_TESTS; t++) { 58 | double* bufSend = new double[loc_size]; 59 | double* bufRecv = new double[loc_size]; 60 | 61 | for(int i = 0; i < loc_size; i++) bufSend[i] = (1e-6 + i) / (2. * loc_size); 62 | 63 | double tm_start = MPI_Wtime(); 64 | for(int i = 0; i < NUM_REDUCES; i++) { 65 | err = MPI_Allreduce(bufSend, bufRecv, loc_size, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); 66 | assert(MPI_SUCCESS == err); 67 | } 68 | double tm_end = MPI_Wtime(); 69 | if(0 == my_rank) printf(" buffer size %10lu reduced in %.10f seconds\n", loc_size, tm_end - tm_start); 70 | results[t - 1][r] = tm_end - tm_start; 71 | 72 | // increase loc_size for the next benchmark 73 | loc_size = loc_size * TEST_X_SIZE; 74 | 75 | delete[] bufSend; 76 | delete[] bufRecv; 77 | } 78 | } 79 | 80 | // outputing 81 | if(0 == my_rank) { 82 | printf("\nSummary: MPI ranks=%d baseDim=%lu X_size=%d TESTS=%d REDUCES=%d REPETITIONS=%d\n", 83 | nranks, 84 | baseDim, 85 | TEST_X_SIZE, 86 | NUM_TESTS, 87 | NUM_REDUCES, 88 | NUM_REPETES); 89 | size_type loc_size = baseDim / nranks; 90 | for(int t = 0; t < NUM_TESTS; t++) { 91 | double mean = 0.; 92 | for(int r = 0; r < NUM_REPETES; r++) mean += results[t][r]; 93 | mean /= NUM_REPETES; 94 | double stdd = 0.; 95 | for(int r = 0; r < NUM_REPETES; r++) stdd += (results[t][r] - mean) * (results[t][r] - mean); 96 | stdd = sqrt(stdd / NUM_REPETES); 97 | 98 | printf(" buffer size %10lu reduced in: mean %.10f seconds stddev %.3f percent\n", loc_size, mean, stdd / mean * 100); 99 | loc_size = loc_size * TEST_X_SIZE; 100 | } 101 | } 102 | #endif 103 | } 104 | -------------------------------------------------------------------------------- /tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Set sources for vector tests 2 | set(testVector_SRC testVector.cpp LinAlg/vectorTestsPar.cpp LinAlg/vectorTestsIntSeq.cpp) 3 | 4 | # Set sources for dense matrix tests 5 | set(testMatrix_SRC testMatrixDense.cpp LinAlg/matrixTestsDenseRowMajor.cpp) 6 | 7 | # Set sources for sparse matrix tests 8 | set(testMatrixSparse_SRC testMatrixSparse.cpp LinAlg/matrixTestsSparseTriplet.cpp) 9 | 10 | # Set sources for symmetric sparse matrix tests 11 | set(testMatrixSymSparse_SRC testMatrixSymSparse.cpp LinAlg/matrixTestsSymSparseTriplet.cpp) 12 | 13 | # Set sources for BiCGStab 14 | set(testBiCGStab_SRC test_bicgstab.cpp) 15 | 16 | # Set sources for symmetric sparse matrix tests 17 | set(testPCG_SRC test_pcg.cpp) 18 | 19 | # Check if using RAJA and Umpire and add RAJA sources 20 | if(HIOP_USE_RAJA) 21 | set(testVector_SRC ${testVector_SRC} LinAlg/vectorTestsRajaPar.cpp LinAlg/vectorTestsIntRaja.cpp) 22 | set(testMatrix_SRC ${testMatrix_SRC} LinAlg/matrixTestsRajaDense.cpp) 23 | set(testMatrixSparse_SRC ${testMatrixSparse_SRC} LinAlg/matrixTestsRajaSparseTriplet.cpp) 24 | set(testMatrixSymSparse_SRC ${testMatrixSymSparse_SRC} LinAlg/matrixTestsRajaSymSparseTriplet.cpp) 25 | endif() 26 | 27 | if(HIOP_USE_CUDA) 28 | set(testVector_SRC ${testVector_SRC} LinAlg/vectorTestsCuda.cpp) 29 | set(cuda_sources ${testVector_SRC} ${testMatrix_SRC} ${testMatrixSparse_SRC} ${testMatrixSymSparse_SRC} ${testPCG_SRC} ${testBiCGStab_SRC}) 30 | set_source_files_properties(${cuda_sources} PROPERTIES LANGUAGE CUDA) 31 | elseif(HIOP_USE_HIP) 32 | #set(testVector_SRC ${testVector_SRC} LinAlg/vectorTestsHip.cpp) 33 | set(hip_sources ${testVector_SRC} ${testMatrix_SRC} ${testMatrixSparse_SRC} ${testMatrixSymSparse_SRC} ${testPCG_SRC} ${testBiCGStab_SRC}) 34 | #set_source_files_properties(${hip_sources} PROPERTIES LANGUAGE HIP) 35 | else() 36 | # raja-omp or non-raja builds do nothing 37 | endif() 38 | 39 | if(HIOP_USE_GPU AND HIOP_USE_HIP) 40 | set(testVector_SRC ${testVector_SRC} LinAlg/vectorTestsHip.cpp ) 41 | set(hip_sources ${testVector_SRC} ${testMatrix_SRC} ${testMatrixSparse_SRC} ${testMatrixSymSparse_SRC}) 42 | 43 | # Mark appropriate source files as HIP. I guess in the future just a 44 | # LANGUAGE HIP property will suffice. For now do it via compile flags 45 | # Reference: https://www.olcf.ornl.gov/wp-content/uploads/2021/01/2021UM-Day-3-Joo-Developing-for-Frontier-using-HIP-on-Spock.pdf 46 | # set_source_files_properties(${hip_sources} PROPERTIES LANGUAGE HIP) 47 | 48 | # HIP kernels 49 | set_source_files_properties( ${hip_sources} PROPERTIES LANGUAGE CXX) 50 | set_source_files_properties( ${hip_sources} PROPERTIES COMPILE_FLAGS "-x hip") 51 | endif() 52 | 53 | # Build vector test 54 | add_executable(testVector ${testVector_SRC}) 55 | target_link_libraries(testVector PRIVATE HiOp::HiOp) 56 | 57 | # Build matrix test 58 | add_executable(testMatrixDense ${testMatrix_SRC}) 59 | target_link_libraries(testMatrixDense PRIVATE HiOp::HiOp) 60 | 61 | # Build sparse matrix test 62 | add_executable(testMatrixSparse ${testMatrixSparse_SRC}) 63 | target_link_libraries(testMatrixSparse PRIVATE HiOp::HiOp) 64 | 65 | # Build symmetric sparse matrix test 66 | add_executable(testMatrixSymSparse ${testMatrixSymSparse_SRC}) 67 | target_link_libraries(testMatrixSymSparse PRIVATE HiOp::HiOp) 68 | 69 | add_executable(test_pcg ${testPCG_SRC}) 70 | target_link_libraries(test_pcg PRIVATE HiOp::HiOp) 71 | 72 | add_executable(test_bicgstab ${testBiCGStab_SRC}) 73 | target_link_libraries(test_bicgstab PRIVATE HiOp::HiOp) 74 | -------------------------------------------------------------------------------- /src/Drivers/PriDec/NlpPriDecEx2UserBasecase.hpp: -------------------------------------------------------------------------------- 1 | #include "NlpSparseEx1.hpp" 2 | #include "hiopInterfacePrimalDecomp.hpp" 3 | 4 | /** This class is the basecase problem for Ex9. 5 | * To work for the master problem, it has a boolean include_rec_ to determine 6 | * whether a recourse approximation is in the objective. 7 | * There is no corresponding .cpp file. 8 | */ 9 | using namespace hiop; 10 | class PriDecBasecaseProbleEx2 : public SparseEx1 11 | { 12 | public: 13 | PriDecBasecaseProbleEx2(int n) 14 | : SparseEx1(n, 1.0), 15 | rec_evaluator_(nullptr) 16 | {} 17 | 18 | virtual ~PriDecBasecaseProbleEx2() {} 19 | 20 | bool eval_f(const size_type& n, const double* x, bool new_x, double& obj_value) 21 | { 22 | if(!SparseEx1::eval_f(n, x, new_x, obj_value)) { 23 | return false; 24 | } 25 | if(include_rec_) { // same as include_r 26 | assert(rec_evaluator_->get_rgrad() != NULL); 27 | rec_evaluator_->eval_f(n, x, new_x, obj_value); 28 | } 29 | // add regularization to the objective based on rec_evaluator_ 30 | return true; 31 | } 32 | 33 | bool eval_grad_f(const size_type& n, const double* x, bool new_x, double* gradf) 34 | { 35 | if(!SparseEx1::eval_grad_f(n, x, new_x, gradf)) { 36 | return false; 37 | } 38 | // add regularization gradient 39 | if(include_rec_) { 40 | assert(rec_evaluator_->get_rgrad() != NULL); 41 | rec_evaluator_->eval_grad(n, x, new_x, gradf); 42 | } 43 | return true; 44 | } 45 | 46 | bool eval_Hess_Lagr(const size_type& n, 47 | const size_type& m, 48 | const double* x, 49 | bool new_x, 50 | const double& obj_factor, 51 | const double* lambda, 52 | bool new_lambda, 53 | const int& nnzHSS, 54 | int* iHSS, 55 | int* jHSS, 56 | double* MHSS) 57 | { 58 | if(!SparseEx1::eval_Hess_Lagr(n, m, x, new_x, obj_factor, lambda, new_lambda, nnzHSS, iHSS, jHSS, MHSS)) { 59 | return false; 60 | } 61 | // Add diagonal to the Hessian 62 | // The indices are already added through the parent 63 | 64 | if(MHSS != nullptr) { 65 | // use rec_evaluator_ to add diagonal entries in the Hessian 66 | assert(nnzHSS == n); 67 | if(include_rec_) { 68 | for(int i = 0; i < n; i++) { 69 | MHSS[i] += obj_factor * (rec_evaluator_->get_rhess()->local_data_const()[i]); 70 | } 71 | } 72 | } 73 | return true; 74 | } 75 | 76 | bool set_quadratic_terms(const int& n, hiopInterfacePriDecProblem::RecourseApproxEvaluator* evaluator) 77 | { 78 | rec_evaluator_ = evaluator; 79 | return true; 80 | } 81 | 82 | void set_include(const bool include) { include_rec_ = include; }; 83 | 84 | bool quad_is_defined() // check if quadratic approximation is defined 85 | { 86 | if(rec_evaluator_ != NULL) { 87 | return true; 88 | } else { 89 | return false; 90 | } 91 | } 92 | 93 | void get_rec_obj(const size_type& n, const double* x, double& obj_value) 94 | { 95 | bool temp = rec_evaluator_->eval_f(n, x, false, obj_value); 96 | assert(temp); 97 | } 98 | 99 | protected: 100 | bool include_rec_ = false; 101 | hiopInterfacePriDecProblem::RecourseApproxEvaluator* rec_evaluator_; // this should be const 102 | }; 103 | -------------------------------------------------------------------------------- /src/Utils/hiopMPI.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017, Lawrence Livermore National Security, LLC. 2 | // Produced at the Lawrence Livermore National Laboratory (LLNL). 3 | // Written by Cosmin G. Petra, petra1@llnl.gov. 4 | // LLNL-CODE-742473. All rights reserved. 5 | // 6 | // This file is part of HiOp. For details, see https://github.com/LLNL/hiop. HiOp 7 | // is released under the BSD 3-clause license (https://opensource.org/licenses/BSD-3-Clause). 8 | // Please also read “Additional BSD Notice” below. 9 | // 10 | // Redistribution and use in source and binary forms, with or without modification, 11 | // are permitted provided that the following conditions are met: 12 | // i. Redistributions of source code must retain the above copyright notice, this list 13 | // of conditions and the disclaimer below. 14 | // ii. Redistributions in binary form must reproduce the above copyright notice, 15 | // this list of conditions and the disclaimer (as noted below) in the documentation and/or 16 | // other materials provided with the distribution. 17 | // iii. Neither the name of the LLNS/LLNL nor the names of its contributors may be used to 18 | // endorse or promote products derived from this software without specific prior written 19 | // permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 22 | // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 23 | // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 24 | // SHALL LAWRENCE LIVERMORE NATIONAL SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR 25 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 28 | // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | // 32 | // Additional BSD Notice 33 | // 1. This notice is required to be provided under our contract with the U.S. Department 34 | // of Energy (DOE). This work was produced at Lawrence Livermore National Laboratory under 35 | // Contract No. DE-AC52-07NA27344 with the DOE. 36 | // 2. Neither the United States Government nor Lawrence Livermore National Security, LLC 37 | // nor any of their employees, makes any warranty, express or implied, or assumes any 38 | // liability or responsibility for the accuracy, completeness, or usefulness of any 39 | // information, apparatus, product, or process disclosed, or represents that its use would 40 | // not infringe privately-owned rights. 41 | // 3. Also, reference herein to any specific commercial products, process, or services by 42 | // trade name, trademark, manufacturer or otherwise does not necessarily constitute or 43 | // imply its endorsement, recommendation, or favoring by the United States Government or 44 | // Lawrence Livermore National Security, LLC. The views and opinions of authors expressed 45 | // herein do not necessarily state or reflect those of the United States Government or 46 | // Lawrence Livermore National Security, LLC, and shall not be used for advertising or 47 | // product endorsement purposes. 48 | 49 | #pragma once 50 | 51 | #include "hiop_defs.hpp" 52 | 53 | #ifdef HIOP_USE_MPI 54 | #include "mpi.h" 55 | #else 56 | #ifndef MPI_COMM 57 | #define MPI_Comm int 58 | #endif 59 | #ifndef MPI_COMM_SELF 60 | #define MPI_COMM_SELF 0 61 | #endif 62 | #ifndef MPI_COMM_WORLD 63 | #define MPI_COMM_WORLD 0 64 | #endif 65 | #include 66 | #endif 67 | -------------------------------------------------------------------------------- /README_summit.md: -------------------------------------------------------------------------------- 1 | # Option 1: Use Combination of System Modules and ExaSGD-Built Modules 2 | 3 | On Summit, a limited number of dependecies are available by default, and the modules 4 | tend to change somewhat frequently. We have a script `./scripts/summitVariables.sh` 5 | which loads a combination of system modules and modules built in the ExaSGD 6 | shared project folder which enables a full build of HiOp. 7 | 8 | ```console 9 | $ git clone git@github.com:LLNL/hiop.git 10 | $ cd hiop 11 | $ source ./scripts/summitVariables.sh 12 | $ mkdir build install && cd build 13 | $ cmake .. -DCMAKE_INSTALL_PREFIX=$PWD/../install 14 | $ ccmake . # Optional, if you would like to customize the build 15 | $ make -j 16 install 16 | $ make test # Optional, if you would like to run tests. This command should be 17 | $ # ran in a BSUB allocation. 18 | ``` 19 | 20 | Note that this script may become out of date, and is not officially supported. 21 | 22 | ## Notes on HiOp's Buildsystem and the `module` Utility 23 | 24 | Different versions of modules may conflict with each other; in this case, one needs to inquire additional compatibility information using `module spider package_name`. 25 | 26 | HiOp with GPU support can be configured, built, and tested using with the cmake 27 | options `HIOP_USE_GPU` and `HIOP_USE_CUDA`. For example, you may invoke `cmake` 28 | like so: 29 | 30 | ``` 31 | cd build/ 32 | cmake -DHIOP_USE_GPU=ON -DHIOP_USE_CUDA=ON .. 33 | make -j 16 34 | make test 35 | make install 36 | ``` 37 | 38 | In some cases, `cmake` picks up a different gcc compiler than the one loaded via `module`. This situation can be remedied by preloading the `CC` and `CXX` for `cmake` as it is done above. 39 | 40 | Developers are usually required to perform a more comprehensive build like so: 41 | ``` 42 | rm -rf * 43 | CC=/sw/summit/gcc/9.2.0/bin/gcc CXX=/sw/summit/gcc/9.2.0/bin/g++ cmake -DHIOP_SPARSE=ON -DHIOP_USE_GPU=ON -HIOP_TEST_WITH_BSUB=ON -DHIOP_USE_MPI=ON -DMETIS_DIR=$INSTALL_DIR/Compiler/gcc-9.2.0/metis/5.1.0/ -DHIOP_COINHSL_DIR=/ccs/home/cpetra/work/installs/coinhsl-2015.06.23/_install -DCMAKE_BUILD_TYPE=DEBUG -DHIOP_TEST_WITH_BSUB=ON -DHIOP_USE_RAJA=ON -DHIOP_USE_UMPIRE=ON -DHIOP_USE_GPU=ON -DHIOP_DEEPCHECKS=ON .. 44 | make -j 45 | ``` 46 | 47 | Depending on the LAPACK/BLAS CPU library loaded by the `module` command, runtime crashes can occur (intermintently for different problems/linear systems sizes) if the `nvblas.conf` cannot be find or is not specifying the so-called NVBLAS CPU BLAS library required by CUDA. This can be remedied by specifying the location of the BLAS library in `NVBLAS_CPU_BLAS_LIB` in the `nvblas.conf` file; for example, this can be done by adding the following lines to `nvblas.conf` file 48 | ``` 49 | NVBLAS_CPU_BLAS_LIB /gpfs/alpine/proj-shared/csc359/installs/ExaSGD/Compiler/gcc-9.2.0/openblas/0.3.10/lib/libopenblas.so 50 | ``` 51 | Be aware that this assumes that the openblas has been `module load`ed. 52 | 53 | For non-standard locations of `nvblas.conf`, one can specify the path to `nvblas.conf` via the environment variable `NVBLAS_CONFIG_FILE`; for example, this can be achieved by exporting the variable in your submission `your_job_file.lsf` file: 54 | ``` 55 | # ##LSF directives here 56 | # other commands here 57 | # example assumes a bash shell 58 | export NVBLAS_CONFIG_FILE=/ccs/home/cpetra/work/projects/hiop/runs/nvblas.conf 59 | 60 | # jsrun command here 61 | 62 | ``` 63 | 64 | # Option 2 - using Spack 65 | 66 | ## Using official Spack recipe 67 | 68 | An Spack recipe is available in the builtin spack repository. To build HiOp 69 | on Summit using Spack requires some experience with Spack. Users are referred to 70 | [the Spack documentation here](https://spack.readthedocs.io/en/latest/). 71 | -------------------------------------------------------------------------------- /src/hiopbbpy/surrogate_modeling/gp.py: -------------------------------------------------------------------------------- 1 | """ 2 | This is a base class for Gaussian Process (GP) models. 3 | It defines methods for computing the mean, covariance, and variance of the GP. 4 | 5 | Authors: Tucker Hartland 6 | Nai-Yuan Chiang 7 | """ 8 | 9 | import numpy as np 10 | 11 | class GaussianProcess: 12 | def __init__(self, ndim, xlimits=None): 13 | self.ndim = ndim 14 | self.xlimits = xlimits 15 | self.training_x = [] 16 | self.training_y = [] 17 | self.trained = False 18 | 19 | # Abstract method for computing the mean of the GP at a given input x 20 | def mean(self, x: np.ndarray) -> np.ndarray: 21 | """ 22 | evaluation of the GP mean 23 | 24 | Parameters 25 | --------- 26 | x : ndarray[n, nx] 27 | 28 | Returns 29 | ------- 30 | ndarray[n, 1] 31 | Mean of GP at x 32 | """ 33 | raise NotImplementedError("Child class of GaussianProcess should implement method mean") 34 | 35 | # Abstract method for computing the covariance of the GP at a given input x 36 | def covariance(self, x: np.ndarray) -> np.ndarray: 37 | """ 38 | evaluation of the GP covariance 39 | 40 | Parameters 41 | --------- 42 | x: ndarray[n, nx] 43 | 44 | Returns 45 | ------- 46 | ndarray[n, n] 47 | Covariance of GP at w.r.t. x 48 | """ 49 | raise NotImplementedError("Child class of GaussianProcess should implement method covariance") 50 | 51 | # Abstract method for computing the variance of the GP at a given input x 52 | def variance(self, x: np.ndarray) -> np.ndarray: 53 | """ 54 | evaluation of the GP variance 55 | 56 | Parameters 57 | --------- 58 | x: ndarray[n, nx] 59 | 60 | Returns 61 | ------ 62 | ndarray[n, 1] 63 | Variance of GP at x 64 | """ 65 | y = np.ndarray((self.ndim, 1)) 66 | for i in range(x.shape[1]): 67 | y[i][0] = covariance(np.atleast_2d(x[i,:]))[0][0] 68 | return y 69 | 70 | # Retrieves the bounds of the input space if xlimits is provided. 71 | def get_bounds(self): 72 | if self.xlimits is None: 73 | return None 74 | else: 75 | return [(self.xlimits[i][0], self.xlimits[i][1]) for i in range(self.ndim)] 76 | 77 | # Abstract method for training the GP 78 | def train(self, x: np.ndarray, y: np.ndarray) -> np.ndarray: 79 | """ 80 | train the GP model 81 | 82 | Parameters 83 | --------- 84 | x : ndarray[n, nx] 85 | y : ndarray[n, 1] 86 | 87 | """ 88 | NotImplementedError("Child class of GaussianProcess should implement method train") 89 | 90 | # Abstract method for computing the gradient of the mean of the GP at a given input x 91 | def mean_gradient(self, x: np.ndarray) -> np.ndarray: 92 | """ 93 | evaluation of the gradien of GP mean 94 | 95 | Parameters 96 | --------- 97 | x : ndarray[n, nx] 98 | 99 | Returns 100 | ------- 101 | ndarray[n, 1] 102 | Gradient of Mean of GP at x 103 | """ 104 | raise NotImplementedError("Child class of GaussianProcess should implement method mean_gradient") 105 | 106 | # Abstract method for computing the gradient of variance of the GP at a given input x 107 | def variance_gradient(self, x: np.ndarray) -> np.ndarray: 108 | """ 109 | evaluation of the gradient of GP variance 110 | 111 | Parameters 112 | --------- 113 | x: ndarray[n, nx] 114 | 115 | Returns 116 | ------- 117 | ndarray[n, n] 118 | Gradient of variance of GP at w.r.t. x 119 | """ 120 | raise NotImplementedError("Child class of GaussianProcess should implement method variance_gradient") 121 | -------------------------------------------------------------------------------- /src/Drivers/MDS/hpc_multisolves.cpp: -------------------------------------------------------------------------------- 1 | #include "NlpMdsEx1.hpp" 2 | #include "hiopNlpFormulation.hpp" 3 | #include "hiopAlgFilterIPM.hpp" 4 | 5 | #ifdef HIOP_USE_MAGMA 6 | #include "magma_v2.h" 7 | #endif 8 | 9 | #include "mpi.h" 10 | 11 | #include // std::this_thread::sleep_for 12 | #include // std::chrono::seconds 13 | 14 | #include "hiopTimer.hpp" 15 | 16 | using namespace hiop; 17 | 18 | /** The driver performs multiple solves per MPI process using MDS Ex1 19 | * 20 | * Intended to be used to test intra-node CPU cores affinity or GPU streams multiprocessing 21 | * 22 | * 23 | * Usage with bsub, for example, on Summit: see end of file for a submission script 24 | */ 25 | int main(int argc, char* argv[]) 26 | { 27 | int ret; 28 | ret = MPI_Init(&argc, &argv); 29 | assert(ret == MPI_SUCCESS); 30 | if(MPI_SUCCESS != ret) { 31 | printf("MPI_Init failed\n"); 32 | return -1; 33 | } 34 | 35 | hiopTimer glob_timer, t; 36 | glob_timer.start(); 37 | 38 | int my_rank = 0, comm_size; 39 | ret = MPI_Comm_rank(MPI_COMM_WORLD, &my_rank); 40 | assert(ret == MPI_SUCCESS); 41 | 42 | ret = MPI_Comm_size(MPI_COMM_WORLD, &comm_size); 43 | assert(ret == MPI_SUCCESS); 44 | 45 | const int num_probs_per_rank = 5; 46 | const int n_de = 2000; 47 | const int n_sp = 2 * n_de; 48 | 49 | for(int i = 0; i < num_probs_per_rank; i++) { 50 | t.start(); 51 | printf("[driver] Rank %d solves problem %d\n", my_rank, (i + 1)); 52 | fflush(stdout); 53 | 54 | double obj_value = -1e+20; 55 | hiopSolveStatus status; 56 | 57 | // user's NLP -> implementation of hiop::hiopInterfaceMDS 58 | MdsEx1* my_nlp = new MdsEx1(n_sp, n_de); 59 | 60 | hiopNlpMDS nlp(*my_nlp); 61 | hiopAlgFilterIPMNewton solver(&nlp); 62 | status = solver.run(); 63 | obj_value = solver.getObjective(); 64 | 65 | delete my_nlp; 66 | 67 | t.stop(); 68 | printf("[driver] Rank %d solved problem %d (status=%d) (obj=%12.5e) in %g sec.\n", 69 | my_rank, 70 | (int)status, 71 | (i + 1), 72 | obj_value, 73 | t.getElapsedTime()); 74 | fflush(stdout); 75 | } 76 | 77 | glob_timer.stop(); 78 | double tmElapsed = glob_timer.getElapsedTime(); 79 | 80 | MPI_Barrier(MPI_COMM_WORLD); 81 | std::this_thread::sleep_for(std::chrono::milliseconds((1 + my_rank) * 100)); 82 | 83 | printf("[driver] Rank %d finished solves in %g seconds\n", my_rank, tmElapsed); 84 | fflush(stdout); 85 | 86 | double tmAvg, stdDevTm, aux; 87 | ret = MPI_Allreduce(&tmElapsed, &tmAvg, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); 88 | assert(ret == MPI_SUCCESS); 89 | tmAvg /= comm_size; 90 | 91 | if(comm_size > 1) { 92 | aux = (tmElapsed - tmAvg) * (tmElapsed - tmAvg) / (comm_size - 1); 93 | 94 | ret = MPI_Allreduce(&aux, &stdDevTm, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); 95 | assert(ret == MPI_SUCCESS); 96 | stdDevTm = sqrt(stdDevTm); 97 | } else { 98 | aux = 0.; 99 | } 100 | if(0 == my_rank) { 101 | printf("\n\nSummary: average time %g sec, std dev %.2f percent \n\n", tmAvg, 100 * stdDevTm / tmAvg); 102 | } 103 | 104 | MPI_Finalize(); 105 | return 0; 106 | } 107 | 108 | /* -- BSUB submission file -- 109 | 110 | # Begin LSF Directives 111 | #BSUB -P csc359 112 | #BSUB -W 00:20 113 | #BSUB -nnodes 1 114 | #BSUB -alloc_flags gpumps 115 | #BSUB -J RunSim16mpiprs 116 | #BSUB -o RunSim16mpiprs.%J 117 | #BSUB -e RunSim16mpiprs.%J 118 | 119 | 120 | export NVBLAS_CONFIG_FILE=/ccs/home/cpetra/work/projects/gocompet/specCpp/runs_wecc10k/nvblas.conf 121 | 122 | jsrun -n 1 -c 16 -a 16 -g 1 -d packed -l GPU-CPU ./src/Drivers/hpc_multisolves.exe 123 | 124 | 125 | */ 126 | -------------------------------------------------------------------------------- /scripts/summitVariables.sh: -------------------------------------------------------------------------------- 1 | module purge 2 | 3 | module use -a /autofs/nccs-svm1_proj/csc359/shared_installs/spack/share/spack/modules/linux-rhel8-ppc64le 4 | 5 | # Load spack-generated modules 6 | # blt@0.4.1%gcc@10.2.0 arch=linux-rhel8-ppc64le 7 | module load exasgd-blt/0.4.1/gcc-10.2.0-bz5htrf 8 | # camp@0.2.2%gcc@10.2.0+cuda~ipo~rocm~tests build_type=RelWithDebInfo cuda_arch=70 arch=linux-rhel8-ppc64le 9 | module load exasgd-camp/0.2.2/cuda-11.5.2/gcc-10.2.0-dc42bvq 10 | # cmake@3.21.3%gcc@10.2.0~doc+ncurses+ownlibs~qt build_type=Release arch=linux-rhel8-ppc64le 11 | module load exasgd-cmake/3.21.3/gcc-10.2.0-jtqszri 12 | # coinhsl@2015.06.23%gcc@10.2.0+blas arch=linux-rhel8-ppc64le 13 | module load exasgd-coinhsl/2015.06.23/gcc-10.2.0-btplbob 14 | # cuda@11.5.2%gcc@10.2.0~allow-unsupported-compilers~dev arch=linux-rhel8-ppc64le 15 | module load exasgd-cuda/11.5.2/gcc-10.2.0-7gofref 16 | # ginkgo@glu_experimental%gcc@10.2.0+cuda~develtools~full_optimizations~hwloc~ipo~oneapi+openmp~rocm+shared build_type=Release cuda_arch=70 arch=linux-rhel8-ppc64le 17 | module load exasgd-ginkgo/glu_experimental/cuda-11.5.2/gcc-10.2.0-4ybxcrk 18 | # ipopt@3.12.10%gcc@10.2.0+coinhsl~debug+metis~mumps patches=712f729 arch=linux-rhel8-ppc64le 19 | module load exasgd-ipopt/3.12.10/gcc-10.2.0-5x34omc 20 | # magma@2.6.2%gcc@10.2.0+cuda+fortran~ipo~rocm+shared build_type=Release cuda_arch=70 arch=linux-rhel8-ppc64le 21 | module load exasgd-magma/2.6.2/cuda-11.5.2/gcc-10.2.0-pkzoqx7 22 | # metis@5.1.0%gcc@10.2.0~gdb~int64~real64+shared build_type=Release patches=4991da9,b1225da arch=linux-rhel8-ppc64le 23 | module load exasgd-metis/5.1.0/gcc-10.2.0-c5niajq 24 | # openblas@0.17.0%gcc@10.2.0~bignuma~consistent_fpcsr~ilp64+locking+pic+shared symbol_suffix=none threads=none arch=linux-rhel8-ppc64le 25 | module load exasgd-openblas/0.17.0/gcc-10.2.0-jd6kkan 26 | # parmetis@4.0.3%gcc@10.2.0~gdb~int64~ipo+shared build_type=RelWithDebInfo patches=4f89253,50ed208,704b84f arch=linux-rhel8-ppc64le 27 | module load exasgd-parmetis/4.0.3/spectrum-mpi-10.4.0.3-20210112/gcc-10.2.0-skqvpvq 28 | # petsc@3.16.6%gcc@10.2.0~X~batch~cgns~complex~cuda~debug+double~exodusii~fftw+fortran~giflib~hdf5~hpddm~hwloc~hypre~int64~jpeg~knl~kokkos~libpng~libyaml~memkind+metis~mkl-pardiso~mmg~moab~mpfr+mpi~mumps~openmp~p4est~parmmg~ptscotch~random123~rocm~saws~scalapack+shared~strumpack~suite-sparse~superlu-dist~tetgen~trilinos~valgrind clanguage=C arch=linux-rhel8-ppc64le 29 | module load exasgd-petsc/3.16.6/spectrum-mpi-10.4.0.3-20210112/gcc-10.2.0-cmc5awz 30 | # raja@0.14.0%gcc@10.2.0+cuda+examples+exercises~ipo+openmp~rocm+shared~tests build_type=Release cuda_arch=70 arch=linux-rhel8-ppc64le 31 | module load exasgd-raja/0.14.0/cuda-11.5.2/gcc-10.2.0-ibkae64 32 | # suite-sparse@5.10.1%gcc@10.2.0~cuda~graphblas~openmp+pic~tbb arch=linux-rhel8-ppc64le 33 | module load exasgd-suite-sparse/5.10.1/gcc-10.2.0-bgorozs 34 | # umpire@6.0.0%gcc@10.2.0~c+cuda~device_alloc~deviceconst+examples~fortran~ipo~numa~openmp~rocm~shared build_type=Release cuda_arch=70 tests=none arch=linux-rhel8-ppc64le 35 | module load exasgd-umpire/6.0.0/cuda-11.5.2/gcc-10.2.0-wlm3tr7 36 | 37 | # Load system modules 38 | module load gcc/10.2.0 39 | module load spectrum-mpi/10.4.0.3-20210112 40 | 41 | export CC=/sw/summit/gcc/10.2.0-2/bin/gcc 42 | export CXX=/sw/summit/gcc/10.2.0-2/bin/g++ 43 | export FC=/sw/summit/gcc/10.2.0-2/bin/gfortran 44 | 45 | [ -f $PWD/nvblas.conf ] && rm $PWD/nvblas.conf 46 | cat > $PWD/nvblas.conf <<-EOD 47 | NVBLAS_LOGFILE nvblas.log 48 | NVBLAS_CPU_BLAS_LIB $OPENBLAS_LIBRARY_DIR/libopenblas.so 49 | NVBLAS_GPU_LIST ALL 50 | NVBLAS_TILE_DIM 2048 51 | NVBLAS_AUTOPIN_MEM_ENABLED 52 | EOD 53 | export NVBLAS_CONFIG_FILE=$PWD/nvblas.conf 54 | echo "Generated $PWD/nvblas.conf" 55 | 56 | export CMAKE_CACHE_SCRIPT=gcc-cuda.cmake 57 | 58 | EXTRA_CMAKE_ARGS="$EXTRA_CMAKE_ARGS -DCMAKE_CUDA_ARCHITECTURES=70 -DHIOP_TEST_WITH_BSUB=ON" 59 | -------------------------------------------------------------------------------- /src/Utils/hiopKronReduction.cpp: -------------------------------------------------------------------------------- 1 | #include "hiopKronReduction.hpp" 2 | 3 | #include "hiopLinSolverUMFPACKZ.hpp" 4 | #include "hiopCppStdUtils.hpp" 5 | 6 | namespace hiop 7 | { 8 | 9 | hiopKronReduction::hiopKronReduction() 10 | : linsolver_(NULL), 11 | map_nonaux_to_aux_(NULL) 12 | {} 13 | hiopKronReduction::~hiopKronReduction() 14 | { 15 | delete linsolver_; 16 | delete map_nonaux_to_aux_; 17 | } 18 | 19 | bool hiopKronReduction::go(const std::vector& idx_nonaux_buses, 20 | const std::vector& idx_aux_buses, 21 | const hiopMatrixComplexSparseTriplet& Ybus, 22 | hiopMatrixComplexDense& Ybus_red) 23 | { 24 | // printvec(idx_aux_buses, "aux="); 25 | // printvec(idx_nonaux_buses, "nonaux="); 26 | 27 | // Ybus.print(); 28 | // int nnz = Ybus.numberOfNonzeros(); 29 | // printf("Ybus has %d nnz\n", nnz); 30 | 31 | // Yaa = Matrix(Ybus[nonaux, nonaux]) 32 | auto* Yaa = 33 | Ybus.new_slice(idx_nonaux_buses.data(), idx_nonaux_buses.size(), idx_nonaux_buses.data(), idx_nonaux_buses.size()); 34 | 35 | auto* Ybb = Ybus.new_slice(idx_aux_buses.data(), idx_aux_buses.size(), idx_aux_buses.data(), idx_aux_buses.size()); 36 | 37 | auto* Yba = Ybus.new_slice(idx_aux_buses.data(), idx_aux_buses.size(), idx_nonaux_buses.data(), idx_nonaux_buses.size()); 38 | 39 | if(NULL != linsolver_) { 40 | assert(false); 41 | delete linsolver_; 42 | } 43 | 44 | linsolver_ = new hiopLinSolverUMFPACKZ(*Ybb); 45 | 46 | int nret = linsolver_->matrixChanged(); 47 | if(nret >= 0) { 48 | // 49 | // Yaa - Yab*(Ybb\Yba) 50 | // 51 | 52 | // Ybb\Yba 53 | // hiopMatrixComplexDense Ybbinv_Yba(Yba_->m(), Yba_->n()); 54 | assert(map_nonaux_to_aux_ == NULL); 55 | delete map_nonaux_to_aux_; 56 | map_nonaux_to_aux_ = new hiopMatrixComplexDense(Yba->m(), Yba->n()); 57 | linsolver_->solve(*Yba, *map_nonaux_to_aux_); 58 | 59 | map_nonaux_to_aux_->negate(); 60 | // Ybbinv_Yba.print(); 61 | delete Ybb; 62 | delete linsolver_; 63 | linsolver_ = NULL; 64 | 65 | // Ybus_red = - Yab*(Ybb\Yba) 66 | Yba->transTimesMat(0.0, Ybus_red, 1.0, *map_nonaux_to_aux_); 67 | delete Yba; 68 | 69 | Ybus_red.addSparseMatrix(std::complex(1.0, 0.0), *Yaa); 70 | delete Yaa; 71 | 72 | } else { 73 | printf("Error occured while performing the Kron reduction (factorization issue)\n"); 74 | delete linsolver_; 75 | linsolver_ = NULL; 76 | delete Yaa; 77 | delete Ybb; 78 | delete Yba; 79 | return false; 80 | } 81 | return true; 82 | } 83 | 84 | /** 85 | * Performs v_aux_out = (Ybb\Yba)* v_nonaux_in 86 | */ 87 | bool hiopKronReduction::apply_nonaux_to_aux(const std::vector >& v_nonaux_in, 88 | std::vector >& v_aux_out) 89 | { 90 | assert(map_nonaux_to_aux_); 91 | if(NULL == map_nonaux_to_aux_) return false; 92 | 93 | assert((size_type)v_nonaux_in.size() == map_nonaux_to_aux_->n()); 94 | assert((size_type)v_aux_out.size() == map_nonaux_to_aux_->m()); 95 | 96 | map_nonaux_to_aux_->timesVec(std::complex(0., 0.), 97 | v_aux_out.data(), 98 | std::complex(1., 0.), 99 | v_nonaux_in.data()); 100 | 101 | // assert(linsolver_); 102 | // std::complex Yba_x_vnonaux[Yba_->n()]; 103 | 104 | // for(int i=0; in(); i++) { 105 | // Yba_x_vnonaux[i]=0.; 106 | // } 107 | 108 | // Yba_->timesVec(0., Yba_x_vnonaux, 1., v_nonaux_in.data()); 109 | 110 | // assert(Yba_->m() == v_aux_out.size()); 111 | // linsolver_->solve(Yba_x_vnonaux, v_aux_out.data()); 112 | 113 | return true; 114 | } 115 | 116 | } // namespace hiop 117 | -------------------------------------------------------------------------------- /src/Drivers/Sparse/NlpSparseEx4.hpp: -------------------------------------------------------------------------------- 1 | #ifndef HIOP_EXAMPLE_SPARSE_EX4 2 | #define HIOP_EXAMPLE_SPARSE_EX4 3 | 4 | #include "hiopInterface.hpp" 5 | 6 | #include 7 | 8 | using size_type = hiop::size_type; 9 | using index_type = hiop::index_type; 10 | 11 | /* Test problem from a tiny concave example 12 | * min -3*x*x-2*y*y 13 | * s.t. 14 | * y - 0.06*x*x >= 0.0 15 | * y - 0.05*x*x <= 10. 16 | * y*y <= 64 17 | * x*x <= 100 18 | * 0 <= x <= 11 19 | * 0 <= y <= 11 20 | */ 21 | class SparseEx4 : public hiop::hiopInterfaceSparse 22 | { 23 | public: 24 | SparseEx4(double scal_in); 25 | virtual ~SparseEx4(); 26 | 27 | virtual bool get_prob_sizes(size_type& n, size_type& m); 28 | virtual bool get_vars_info(const size_type& n, double* xlow, double* xupp, NonlinearityType* type); 29 | virtual bool get_cons_info(const size_type& m, double* clow, double* cupp, NonlinearityType* type); 30 | 31 | virtual bool get_sparse_blocks_info(size_type& nx, 32 | size_type& nnz_sparse_Jaceq, 33 | size_type& nnz_sparse_Jacineq, 34 | size_type& nnz_sparse_Hess_Lagr); 35 | 36 | virtual bool eval_f(const size_type& n, const double* x, bool new_x, double& obj_value); 37 | virtual bool eval_cons(const size_type& n, 38 | const size_type& m, 39 | const size_type& num_cons, 40 | const index_type* idx_cons, 41 | const double* x, 42 | bool new_x, 43 | double* cons); 44 | virtual bool eval_cons(const size_type& n, const size_type& m, const double* x, bool new_x, double* cons); 45 | virtual bool eval_grad_f(const size_type& n, const double* x, bool new_x, double* gradf); 46 | virtual bool eval_Jac_cons(const size_type& n, 47 | const size_type& m, 48 | const size_type& num_cons, 49 | const index_type* idx_cons, 50 | const double* x, 51 | bool new_x, 52 | const size_type& nnzJacS, 53 | index_type* iJacS, 54 | index_type* jJacS, 55 | double* MJacS); 56 | virtual bool eval_Jac_cons(const size_type& n, 57 | const size_type& m, 58 | const double* x, 59 | bool new_x, 60 | const size_type& nnzJacS, 61 | index_type* iJacS, 62 | index_type* jJacS, 63 | double* MJacS); 64 | virtual bool get_starting_point(const size_type& n, double* x0); 65 | virtual bool eval_Hess_Lagr(const size_type& n, 66 | const size_type& m, 67 | const double* x, 68 | bool new_x, 69 | const double& obj_factor, 70 | const double* lambda, 71 | bool new_lambda, 72 | const size_type& nnzHSS, 73 | index_type* iHSS, 74 | index_type* jHSS, 75 | double* MHSS); 76 | 77 | // not implemented 78 | virtual bool 79 | get_starting_point(const size_type&, const size_type&, double*, bool&, double*, double*, double*, bool&, double*) 80 | { 81 | return false; 82 | } 83 | 84 | virtual bool 85 | get_warmstart_point(const size_type&, const size_type&, double*, double*, double*, double*, double*, double*, double*) 86 | { 87 | return false; 88 | } 89 | 90 | private: 91 | size_type n_vars; 92 | size_type n_cons; 93 | double scal; 94 | }; 95 | #endif 96 | -------------------------------------------------------------------------------- /src/Drivers/MDS/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(NlpMdsEx1.exe NlpMdsEx1Driver.cpp) 2 | target_link_libraries(NlpMdsEx1.exe HiOp::HiOp) 3 | install(TARGETS NlpMdsEx1.exe DESTINATION bin) 4 | 5 | if(HIOP_USE_RAJA) 6 | if(HIOP_USE_GPU AND HIOP_USE_CUDA) 7 | set_source_files_properties( 8 | NlpMdsRajaEx1.cpp 9 | NlpMdsEx1RajaDriver.cpp 10 | PROPERTIES LANGUAGE CUDA 11 | ) 12 | endif() 13 | add_executable(NlpMdsEx1Raja.exe NlpMdsEx1RajaDriver.cpp NlpMdsRajaEx1.cpp) 14 | target_link_libraries(NlpMdsEx1Raja.exe HiOp::HiOp) 15 | install(TARGETS NlpMdsEx1Raja.exe DESTINATION bin) 16 | endif() 17 | 18 | add_executable(NlpMdsEx2.exe NlpMdsEx2Driver.cpp) 19 | target_link_libraries(NlpMdsEx2.exe HiOp::HiOp) 20 | 21 | if(HIOP_USE_MPI) 22 | add_executable( hpc_multisolves.exe hpc_multisolves.cpp) 23 | target_link_libraries(hpc_multisolves.exe HiOp::HiOp) 24 | endif() 25 | 26 | if(HIOP_BUILD_SHARED) 27 | add_executable(NlpMdsCEx1.exe NlpMdsEx1.c) 28 | target_link_libraries(NlpMdsCEx1.exe HiOp::HiOp) 29 | endif() 30 | 31 | ########################################################## 32 | # CMake Tests 33 | ########################################################## 34 | 35 | set(STRIP_TABLE_CMD "awk '/Problem Summary/ { while (!match($0, /termination/)){ if(match($0, /^[ ]+[0-9]/)) { print $0; } getline } }'") 36 | add_test(NAME NlpMixedDenseSparse1_1 COMMAND ${RUNCMD} bash -c "$ 400 100 0 -selfcheck \ 37 | | ${STRIP_TABLE_CMD} \ 38 | | tee ${HIOP_CTEST_OUTPUT_DIR}/mds4_1.out") 39 | add_test(NAME NlpMixedDenseSparse1_2 COMMAND ${RUNCMD} bash -c "$ 400 100 1 -selfcheck \ 40 | | ${STRIP_TABLE_CMD} \ 41 | | tee ${HIOP_CTEST_OUTPUT_DIR}/mds4_2.out") 42 | 43 | add_test(NAME NlpMixedDenseSparse1_3 COMMAND ${RUNCMD} "$" "400" "100" "0" "-empty_sp_row" "-selfcheck") 44 | 45 | if(HIOP_USE_RAJA) 46 | add_test(NAME NlpMixedDenseSparseRaja1_1 COMMAND ${RUNCMD} bash -c "$ 400 100 0 -selfcheck \ 47 | | ${STRIP_TABLE_CMD} \ 48 | | tee ${HIOP_CTEST_OUTPUT_DIR}/mds4_raja_1.out") 49 | add_test(NAME NlpMixedDenseSparseRaja1_2 COMMAND ${RUNCMD} bash -c "$ 400 100 1 -selfcheck \ 50 | | ${STRIP_TABLE_CMD} \ 51 | | tee ${HIOP_CTEST_OUTPUT_DIR}/mds4_raja_2.out") 52 | add_test(NAME NlpMixedDenseSparseRaja1_3 COMMAND ${RUNCMD} bash -c "$ 400 100 0 -empty_sp_row -selfcheck") 53 | 54 | if(HIOP_DEEPCHECKS) 55 | foreach(iter 1 2) 56 | add_test( 57 | NAME "CompareExample4_NumIterations_${iter}" 58 | COMMAND bash -c "\ 59 | if [[ $(wc -l ${HIOP_CTEST_OUTPUT_DIR}/mds4_${iter}.out|cut -f1 -d' ') == $(wc -l ${HIOP_CTEST_OUTPUT_DIR}/mds4_raja_${iter}.out|cut -f1 -d' ') ]] 60 | then 61 | echo 'Output tables have the same number of iterations.' 62 | exit 0 63 | else 64 | echo 'Output tables have a different number of iterations!' 65 | exit 1 66 | fi") 67 | add_test( 68 | NAME "CompareExample4_ElementWise_${iter}" 69 | COMMAND bash -c "\ 70 | join ${HIOP_CTEST_OUTPUT_DIR}/mds4_${iter}.out ${HIOP_CTEST_OUTPUT_DIR}/mds4_raja_${iter}.out \ 71 | | ${PROJECT_SOURCE_DIR}/tests/testMDS1CompareIterations.awk") 72 | endforeach() 73 | endif(HIOP_DEEPCHECKS) 74 | endif() 75 | 76 | add_test(NAME NlpMixedDenseSparse2_1 COMMAND ${RUNCMD} "$" "400" "100" "-selfcheck") 77 | 78 | 79 | if(HIOP_WITH_VALGRIND_TESTS) 80 | string(REPLACE ";" " " runcmd_str "${RUNCMD}") 81 | add_test( 82 | NAME NlpMixedDenseSparse1_1_Valgrind 83 | COMMAND bash -c "${runcmd_str} ${HIOP_VALGRIND_CMD} $ 400 100 0 -selfcheck" 84 | ) 85 | endif() 86 | 87 | if(HIOP_BUILD_SHARED AND NOT HIOP_USE_GPU) 88 | add_test(NAME NlpMixedDenseSparseCinterface COMMAND ${RUNCMD} "$") 89 | endif() 90 | -------------------------------------------------------------------------------- /src/LinAlg/ReSolve/KrylovSolverKernels.h: -------------------------------------------------------------------------------- 1 | // This file is part of HiOp. For details, see https://github.com/LLNL/hiop. 2 | // HiOp is released under the BSD 3-clause license 3 | // (https://opensource.org/licenses/BSD-3-Clause). Please also read “Additional 4 | // BSD Notice” below. 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are met: 8 | // i. Redistributions of source code must retain the above copyright notice, 9 | // this list of conditions and the disclaimer below. ii. Redistributions in 10 | // binary form must reproduce the above copyright notice, this list of 11 | // conditions and the disclaimer (as noted below) in the documentation and/or 12 | // other materials provided with the distribution. 13 | // iii. Neither the name of the LLNS/LLNL nor the names of its contributors may 14 | // be used to endorse or promote products derived from this software without 15 | // specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | // ARE DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL SECURITY, LLC, 21 | // THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 22 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 25 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 27 | // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | // 29 | // Additional BSD Notice 30 | // 1. This notice is required to be provided under our contract with the U.S. 31 | // Department of Energy (DOE). This work was produced at Lawrence Livermore 32 | // National Laboratory under Contract No. DE-AC52-07NA27344 with the DOE. 33 | // 2. Neither the United States Government nor Lawrence Livermore National 34 | // Security, LLC nor any of their employees, makes any warranty, express or 35 | // implied, or assumes any liability or responsibility for the accuracy, 36 | // completeness, or usefulness of any information, apparatus, product, or 37 | // process disclosed, or represents that its use would not infringe 38 | // privately-owned rights. 39 | // 3. Also, reference herein to any specific commercial products, process, or 40 | // services by trade name, trademark, manufacturer or otherwise does not 41 | // necessarily constitute or imply its endorsement, recommendation, or favoring 42 | // by the United States Government or Lawrence Livermore National Security, 43 | // LLC. The views and opinions of authors expressed herein do not necessarily 44 | // state or reflect those of the United States Government or Lawrence Livermore 45 | // National Security, LLC, and shall not be used for advertising or product 46 | // endorsement purposes. 47 | 48 | /** 49 | * @file src/LinAlg/KrylovSolverKernels.h 50 | * 51 | * @author Kasia Swirydowicz , PNNL 52 | * 53 | */ 54 | 55 | 56 | void mass_inner_product_two_vectors(int n, 57 | int i, 58 | double* vec1, 59 | double* vec2, 60 | double* mvec, 61 | double* result); 62 | void mass_axpy(int n, int i, double* x, double* y, double* alpha); 63 | 64 | //needed for matrix inf nrm 65 | void matrix_row_sums(int n, 66 | int nnz, 67 | int* a_ia, 68 | double* a_val, 69 | double* result); 70 | 71 | -------------------------------------------------------------------------------- /scripts/quartzVariables.sh: -------------------------------------------------------------------------------- 1 | module use -a /usr/workspace/hiop/software/spack_modules_20240124/linux-rhel8-broadwell/ 2 | 3 | module purge 4 | 5 | module load gcc/12.1.1 6 | 7 | # cmake@=3.26.3%gcc@=12.1.1~doc+ncurses+ownlibs build_system=generic build_type=Release arch=linux-rhel8-broadwell 8 | module load cmake/3.26.3-gcc-12.1.1-module-lfjjtqg 9 | # blt@=0.4.1%gcc@=12.1.1 build_system=generic arch=linux-rhel8-broadwell 10 | module load blt/0.4.1-gcc-12.1.1-module-hg3sow3 11 | # gmake@=4.4.1%gcc@=12.1.1~guile build_system=generic arch=linux-rhel8-broadwell 12 | module load gmake/4.4.1-gcc-12.1.1-module-yjw2g3l 13 | # camp@=0.2.3%gcc@=12.1.1~cuda~ipo+openmp~rocm~tests build_system=cmake build_type=Release generator=make arch=linux-rhel8-broadwell 14 | module load camp/0.2.3-gcc-12.1.1-module-cidbesy 15 | # berkeley-db@=18.1.40%gcc@=12.1.1+cxx~docs+stl build_system=autotools patches=26090f4,b231fcc arch=linux-rhel8-broadwell 16 | module load berkeley-db/18.1.40-gcc-12.1.1-module-5m47fme 17 | # libiconv@=1.17%gcc@=12.1.1 build_system=autotools libs=shared,static arch=linux-rhel8-broadwell 18 | module load libiconv/1.17-gcc-12.1.1-module-46h7h6y 19 | # diffutils@=3.9%gcc@=12.1.1 build_system=autotools arch=linux-rhel8-broadwell 20 | module load diffutils/3.9-gcc-12.1.1-module-kfrjf2z 21 | # bzip2@=1.0.8%gcc@=12.1.1~debug~pic+shared build_system=generic arch=linux-rhel8-broadwell 22 | module load bzip2/1.0.8-gcc-12.1.1-module-3qjlvpe 23 | # pkgconf@=1.9.5%gcc@=12.1.1 build_system=autotools arch=linux-rhel8-broadwell 24 | module load pkgconf/1.9.5-gcc-12.1.1-module-v7mglhz 25 | # ncurses@=6.4%gcc@=12.1.1~symlinks+termlib abi=none build_system=autotools arch=linux-rhel8-broadwell 26 | module load ncurses/6.4-gcc-12.1.1-module-6xspqnr 27 | # readline@=8.2%gcc@=12.1.1 build_system=autotools patches=bbf97f1 arch=linux-rhel8-broadwell 28 | module load readline/8.2-gcc-12.1.1-module-hsso65n 29 | # gdbm@=1.23%gcc@=12.1.1 build_system=autotools arch=linux-rhel8-broadwell 30 | module load gdbm/1.23-gcc-12.1.1-module-qe3mdoi 31 | # zlib-ng@=2.1.5%gcc@=12.1.1+compat+opt build_system=autotools arch=linux-rhel8-broadwell 32 | module load zlib-ng/2.1.5-gcc-12.1.1-module-gq3pgym 33 | # perl@=5.38.0%gcc@=12.1.1+cpanm+opcode+open+shared+threads build_system=generic patches=714e4d1 arch=linux-rhel8-broadwell 34 | module load perl/5.38.0-gcc-12.1.1-module-laaewaq 35 | # openblas@=0.3.24%gcc@=12.1.1~bignuma~consistent_fpcsr+fortran~ilp64+locking+pic+shared build_system=makefile symbol_suffix=none threads=none arch=linux-rhel8-broadwell 36 | module load openblas/0.3.24-gcc-12.1.1-module-2cil5ig 37 | # coinhsl@=2015.06.23%gcc@=12.1.1+blas build_system=autotools arch=linux-rhel8-broadwell 38 | module load coinhsl/2015.06.23-gcc-12.1.1-module-gub3jr7 39 | # metis@=5.1.0%gcc@=12.1.1~gdb~int64~ipo~real64+shared build_system=cmake build_type=Release generator=make patches=4991da9,93a7903,b1225da arch=linux-rhel8-broadwell 40 | module load metis/5.1.0-gcc-12.1.1-module-spfpvqb 41 | # mvapich2@=2.3.7%gcc@=12.1.1~alloca~cuda~debug~hwloc_graphics~hwlocv2+regcache+wrapperrpath build_system=autotools ch3_rank_bits=32 fabrics=mrail file_systems=auto patches=d98d8e7 process_managers=auto threads=multiple arch=linux-rhel8-broadwell 42 | module load mvapich2/2.3.7-gcc-12.1.1-module-rtvhl4a 43 | # raja@=0.14.0%gcc@=12.1.1~cuda~examples~exercises~ipo+openmp~plugins~rocm+shared~tests build_system=cmake build_type=Release generator=make arch=linux-rhel8-broadwell 44 | module load raja/0.14.0-gcc-12.1.1-module-4ebos4c 45 | # umpire@=6.0.0%gcc@=12.1.1~c~cuda~device_alloc~deviceconst~examples~fortran~ipo~numa+openmp~rocm~shared build_system=cmake build_type=Release generator=make tests=none arch=linux-rhel8-broadwell 46 | module load umpire/6.0.0-gcc-12.1.1-module-hs2o4vr 47 | 48 | #export EXTRA_CMAKE_ARGS="$EXTRA_CMAKE_ARGS -DHIOP_CTEST_LAUNCH_COMMAND:STRING='jsrun -n 2 -a 1 -c 1 -g 1'" 49 | export EXTRA_CMAKE_ARGS="$EXTRA_CMAKE_ARGS -DHIOP_USE_RAJA:STRING=ON" 50 | export CMAKE_CACHE_SCRIPT=gcc-cpu.cmake 51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /src/Drivers/hiopbbpy/BODriverEX.py: -------------------------------------------------------------------------------- 1 | """ 2 | Code description: 3 | for a 2D example LpNormProblem 4 | 1) randomly sample training points 5 | 2) define a Kriging-based Gaussian-process (smt backend) 6 | trained on said data 7 | 3) determine the minimizer via BOAlgorithm 8 | 9 | Authors: Tucker Hartland 10 | Nai-Yuan Chiang 11 | """ 12 | 13 | import sys 14 | import os 15 | import numpy as np 16 | import matplotlib.pyplot as plt 17 | import warnings 18 | warnings.filterwarnings("ignore") 19 | from hiopbbpy.surrogate_modeling import smtKRG 20 | from hiopbbpy.opt import BOAlgorithm 21 | from hiopbbpy.problems import BraninProblem, LpNormProblem 22 | from hiopbbpy.utils import MPIEvaluator 23 | 24 | ### parameters 25 | n_samples = 5 # number of the initial samples to train GP 26 | theta = 1.e-2 # hyperparameter for GP kernel 27 | nx = 2 # dimension of the problem 28 | xlimits = np.array([[-5, 5], [-5, 5]]) # bounds on optimization variable 29 | 30 | prob_type_l = ["LpNorm"] # ["LpNorm", "Branin"] 31 | acq_type_l = ["LCB"] # ["LCB", "EI"] 32 | 33 | def con_eq(x): 34 | return x[0] + x[1] - 4 35 | 36 | def con_jac_eq(x): 37 | return np.array([1.0, 1.0]) 38 | 39 | def con_ineq(x): 40 | return x[0] - x[1] 41 | 42 | def con_jac_ineq(x): 43 | return np.array([1.0, -1.0]) 44 | 45 | # 'SLSQP' requires constraints defined in a list of dict. 46 | # IPOPT can suport this format, too 47 | user_constraint_list = [{'type': 'eq', 'fun': con_eq, 'jac': con_jac_eq}, 48 | {'type': 'ineq', 'fun': con_ineq, 'jac': con_jac_ineq}] 49 | 50 | def cons_vec(x): 51 | x1, x2 = x 52 | return np.array([ 53 | (x1 - 2)**2 + (x2 - 2.5)**2 - 2, 54 | x1 + x2 - 5, 55 | -x1 56 | ]) 57 | 58 | # Jacobian of constraints 59 | def cons_jac_vec(x): 60 | x1, x2 = x 61 | return np.array([ 62 | [2 * (x1 - 2), 2 * (x2 - 2.5)], 63 | [1, 1], 64 | [-1, 0] 65 | ]) 66 | 67 | cl = -np.inf * np.ones(3) 68 | cu = np.zeros(3) 69 | 70 | # 'trust-constr' and IPOPT support vector-valued constraints 71 | user_constraint_dict = {'cons': cons_vec, 'jac': cons_jac_vec, 'cl': cl, 'cu': cu} 72 | 73 | 74 | if __name__ == "__main__": 75 | for prob_type in prob_type_l: 76 | print() 77 | # ----- evaluator 78 | obj_evaluator = MPIEvaluator() 79 | opt_evaluator = MPIEvaluator(function_mode=False) 80 | if prob_type == "LpNorm": 81 | problem = LpNormProblem(nx, xlimits) 82 | else: 83 | problem = BraninProblem() 84 | problem.set_constraints(user_constraint_list) # for solver 'trust-constr' and IPOPT, use user_constraint_dict; for solver 'SLSQP' and IPOPT, user_constraint_list 85 | 86 | for acq_type in acq_type_l: 87 | ### initial training set 88 | x_train = problem.sample(n_samples) 89 | y_train = obj_evaluator.run(problem.evaluate, x_train) 90 | 91 | ### Define the GP surrogate model 92 | gp_model = smtKRG(theta, xlimits, nx) 93 | gp_model.train(x_train, y_train) 94 | 95 | opt_solver = 'SLSQP' #"SLSQP" "IPOPT" "trust-constr" 96 | if opt_solver == "SLSQP" or opt_solver == "trust-constr": 97 | solver_options = {"maxiter": 100} #for scipy solvers 98 | elif opt_solver == "IPOPT": 99 | solver_options = {"max_iter": 100, "print_level": 1} 100 | 101 | options = { 102 | 'acquisition_type': acq_type, 103 | 'log_level': 'info', 104 | 'bo_maxiter': 10, 105 | 'opt_solver': opt_solver, 106 | 'batch_size': 3, 107 | 'solver_options': solver_options, 108 | 'obj_evaluator': obj_evaluator, 109 | 'opt_evaluator': opt_evaluator 110 | } 111 | 112 | # Instantiate and run Bayesian Optimization 113 | bo = BOAlgorithm(problem, gp_model, x_train, y_train, options = options) #EI or LCB 114 | bo.optimize() 115 | -------------------------------------------------------------------------------- /src/Utils/MathKernelsHost.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022, Lawrence Livermore National Security, LLC. 2 | // Produced at the Lawrence Livermore National Laboratory (LLNL). 3 | // LLNL-CODE-742473. All rights reserved. 4 | // 5 | // This file is part of HiOp. For details, see https://github.com/LLNL/hiop. HiOp 6 | // is released under the BSD 3-clause license (https://opensource.org/licenses/BSD-3-Clause). 7 | // Please also read "Additional BSD Notice" below. 8 | // 9 | // Redistribution and use in source and binary forms, with or without modification, 10 | // are permitted provided that the following conditions are met: 11 | // i. Redistributions of source code must retain the above copyright notice, this list 12 | // of conditions and the disclaimer below. 13 | // ii. Redistributions in binary form must reproduce the above copyright notice, 14 | // this list of conditions and the disclaimer (as noted below) in the documentation and/or 15 | // other materials provided with the distribution. 16 | // iii. Neither the name of the LLNS/LLNL nor the names of its contributors may be used to 17 | // endorse or promote products derived from this software without specific prior written 18 | // permission. 19 | // 20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 21 | // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 | // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 23 | // SHALL LAWRENCE LIVERMORE NATIONAL SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR 24 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26 | // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 27 | // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 29 | // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | // 31 | // Additional BSD Notice 32 | // 1. This notice is required to be provided under our contract with the U.S. Department 33 | // of Energy (DOE). This work was produced at Lawrence Livermore National Laboratory under 34 | // Contract No. DE-AC52-07NA27344 with the DOE. 35 | // 2. Neither the United States Government nor Lawrence Livermore National Security, LLC 36 | // nor any of their employees, makes any warranty, express or implied, or assumes any 37 | // liability or responsibility for the accuracy, completeness, or usefulness of any 38 | // information, apparatus, product, or process disclosed, or represents that its use would 39 | // not infringe privately-owned rights. 40 | // 3. Also, reference herein to any specific commercial products, process, or services by 41 | // trade name, trademark, manufacturer or otherwise does not necessarily constitute or 42 | // imply its endorsement, recommendation, or favoring by the United States Government or 43 | // Lawrence Livermore National Security, LLC. The views and opinions of authors expressed 44 | // herein do not necessarily state or reflect those of the United States Government or 45 | // Lawrence Livermore National Security, LLC, and shall not be used for advertising or 46 | // product endorsement purposes. 47 | 48 | /** 49 | * @file MathKernelsHost.hpp 50 | * 51 | * @author Cosmin G. Petra , LLNL 52 | * @author Nai-Yuan Chiang , LLNL 53 | * 54 | */ 55 | 56 | #ifndef MATH_KERNEL_HOST 57 | #define MATH_KERNEL_HOST 58 | 59 | namespace hiop 60 | { 61 | namespace host 62 | { 63 | // Generates uniformly distributed double-precision floating-point values, from minv to maxv 64 | int array_random_uniform_kernel(int n, double* d_array, double minv, double maxv); 65 | 66 | // Generates uniformly distributed double-precision floating-point values, from 0.0 to 1.0 67 | int array_random_uniform_kernel(int n, double* d_array); 68 | 69 | } // end of namespace host 70 | } // end of namespace hiop 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /src/hiopbbpy/opt/optproblem.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from typing import Callable, Dict, List, Union, Tuple 3 | from ..utils.util import check_required_keys 4 | from importlib import import_module 5 | 6 | """ 7 | Convert a Scipy optimization problem to an Ipopt problem. 8 | 9 | Parameters: 10 | objective (callable): Objective function. 11 | gradient (callable): Gradient of the objective. 12 | constraints_list: Scipy-style list of dicts with 'type', 'fun', and optional 'jac'. 13 | xbounds (list of tuple): Variable bounds [(x0_lb, x0_ub), ...] 14 | 15 | Returns: 16 | Ipopt-compatible prob and bounds 17 | 18 | Authors: Tucker Hartland 19 | Nai-Yuan Chiang 20 | """ 21 | 22 | def _require_cyipopt(): 23 | """Import cyipopt only when actually needed, with a friendly error.""" 24 | try: 25 | return import_module("cyipopt") 26 | except ImportError as e: 27 | raise ImportError( 28 | "This feature requires the optional dependency 'cyipopt'." 29 | ) from e 30 | 31 | class IpoptProb: 32 | def __init__(self, objective, gradient, constraint:Union[Dict, List[Dict]], xbounds, solver_options=None): 33 | self.cons = constraint 34 | self.eval_f = objective 35 | self.eval_g = gradient 36 | self.xl = [b[0] for b in xbounds] 37 | self.xu = [b[1] for b in xbounds] 38 | self.cl = [] 39 | self.cu = [] 40 | self.nvar = len(xbounds) 41 | 42 | self.ipopt_options = solver_options 43 | self.ipopt_options['sb'] = 'yes' 44 | 45 | if isinstance(self.cons, list): 46 | # constraints is provided as a list of dict, supported by SLSQP and Ipopt 47 | for con in self.cons: 48 | check_required_keys(con,['type', 'fun']) 49 | if con['type'] == 'eq': 50 | self.cl.append(0.0) 51 | self.cu.append(0.0) 52 | elif con['type'] == 'ineq': 53 | self.cl.append(0.0) 54 | self.cu.append(np.inf) 55 | else: 56 | raise ValueError(f"Unknown constraint type: {con['type']}") 57 | elif isinstance(self.cons, dict): 58 | check_required_keys(self.cons,['cons', 'jac', 'cl', 'cu']) 59 | # vectorized constraints are provided as a dict, supported by trust-constr and Ipopt 60 | self.cl = constraint['cl'] 61 | self.cu = constraint['cu'] 62 | else: 63 | raise ValueError("constraints must be provided as a dict of a list of dict.") 64 | self.ncon = len(self.cl) 65 | 66 | cyipopt = _require_cyipopt() 67 | self.nlp = cyipopt.Problem( n=self.nvar, 68 | m=self.ncon, 69 | problem_obj=self, 70 | lb=self.xl, 71 | ub=self.xu, 72 | cl=self.cl, 73 | cu=self.cu 74 | ) 75 | 76 | def objective(self, x): 77 | return self.eval_f(x) 78 | 79 | def gradient(self, x): 80 | return self.eval_g(x) 81 | 82 | def constraints(self, x): 83 | if isinstance(self.cons, list): 84 | return np.array([con['fun'](x) for con in self.cons]) 85 | else: 86 | return self.cons['cons'](x) 87 | 88 | def jacobian(self, x): 89 | if isinstance(self.cons, list): 90 | jacs = [] 91 | for con in self.cons: 92 | if 'jac' in con: 93 | jacs.append(con['jac'](x)) 94 | else: 95 | raise ValueError("Jacobian not provided for constraint.") 96 | return np.vstack(jacs) 97 | else: 98 | return self.cons['jac'](x) 99 | 100 | def solve(self, x0, solver_options=None): 101 | ipopt_options = self.ipopt_options 102 | if solver_options is not None: 103 | ipopt_options = solver_options 104 | if ipopt_options is not None: 105 | for key, value in ipopt_options.items(): 106 | self.nlp.add_option(key, value) 107 | 108 | # Solve the optimization problem 109 | return self.nlp.solve(x0) 110 | -------------------------------------------------------------------------------- /src/Utils/RajaUmpireUtils.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017, Lawrence Livermore National Security, LLC. 2 | // Produced at the Lawrence Livermore National Laboratory (LLNL). 3 | // Written by Cosmin G. Petra, petra1@llnl.gov. 4 | // LLNL-CODE-742473. All rights reserved. 5 | // 6 | // This file is part of HiOp. For details, see https://github.com/LLNL/hiop. HiOp 7 | // is released under the BSD 3-clause license (https://opensource.org/licenses/BSD-3-Clause). 8 | // Please also read "Additional BSD Notice" below. 9 | // 10 | // Redistribution and use in source and binary forms, with or without modification, 11 | // are permitted provided that the following conditions are met: 12 | // i. Redistributions of source code must retain the above copyright notice, this list 13 | // of conditions and the disclaimer below. 14 | // ii. Redistributions in binary form must reproduce the above copyright notice, 15 | // this list of conditions and the disclaimer (as noted below) in the documentation and/or 16 | // other materials provided with the distribution. 17 | // iii. Neither the name of the LLNS/LLNL nor the names of its contributors may be used to 18 | // endorse or promote products derived from this software without specific prior written 19 | // permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 22 | // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 23 | // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 24 | // SHALL LAWRENCE LIVERMORE NATIONAL SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR 25 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 28 | // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | // 32 | // Additional BSD Notice 33 | // 1. This notice is required to be provided under our contract with the U.S. Department 34 | // of Energy (DOE). This work was produced at Lawrence Livermore National Laboratory under 35 | // Contract No. DE-AC52-07NA27344 with the DOE. 36 | // 2. Neither the United States Government nor Lawrence Livermore National Security, LLC 37 | // nor any of their employees, makes any warranty, express or implied, or assumes any 38 | // liability or responsibility for the accuracy, completeness, or usefulness of any 39 | // information, apparatus, product, or process disclosed, or represents that its use would 40 | // not infringe privately-owned rights. 41 | // 3. Also, reference herein to any specific commercial products, process, or services by 42 | // trade name, trademark, manufacturer or otherwise does not necessarily constitute or 43 | // imply its endorsement, recommendation, or favoring by the United States Government or 44 | // Lawrence Livermore National Security, LLC. The views and opinions of authors expressed 45 | // herein do not necessarily state or reflect those of the United States Government or 46 | // Lawrence Livermore National Security, LLC, and shall not be used for advertising or 47 | // product endorsement purposes. 48 | 49 | /** 50 | * @file RajaUmpireUtils.hpp 51 | * 52 | * @author Cosmin G. Petra , LLNL 53 | * 54 | */ 55 | 56 | #ifndef HIOP_RAJA_UMPIRE_UTILS 57 | #define HIOP_RAJA_UMPIRE_UTILS 58 | 59 | #include 60 | #include 61 | 62 | namespace hiop 63 | { 64 | /** 65 | * Returns a string with memory space Umpire keeps about the address passed as the argument, 66 | * "__not_managed_by_umpire__" if Umpire does not have a record of the address, or 67 | * "__info_not_available__HiOp_not_built_with_Umpire__" if HiOp was not built with Umpire. 68 | * 69 | * The function should be used for debugging purposes only. 70 | */ 71 | std::string get_umpire_mem_address_info(void* address); 72 | 73 | } // namespace hiop 74 | #endif // HIOP_RAJA_UMPIRE_UTILS 75 | -------------------------------------------------------------------------------- /BUILD.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # 4 | # A script file that builds and runs/tests HiOp on various paricular clusters, such as 5 | # summit and ascent @ ORNL and newell and marianas @ PNNL 6 | # 7 | # Usage: In a shell run 8 | # 9 | # ./BUILD.sh 10 | # 11 | # 12 | # Sometimes the cluster name is not detected correctly; in this cases, one can specify 13 | # the cluster name by prefixing the command with MY_CLUSTER=cluster_name, e.g., 14 | # 15 | # MY_CLUSTER=ascent ./BUILD.sh 16 | # 17 | # All variables that will change the build script's behaviour: 18 | # 19 | # - MAKE_CMD command the script will use to run makefiles 20 | # - CTEST_CMD command the script will use to run ctest 21 | # - BUILDDIR path to temp build directory 22 | # - EXTRA_CMAKE_ARGS extra arguments passed to CMake 23 | # - MY_CLUSTER determines cluster-specific variables to use 24 | 25 | export BASE_PATH=$(dirname $0) 26 | export MAKE_CMD=${MAKE_CMD:-'make -j 8'} 27 | export CTEST_CMD=${CTEST_CMD:-'ctest -VV --timeout 1800'} 28 | 29 | # we want this settable via env var to make CI triggered builds simpler 30 | export FULL_BUILD_MATRIX=${FULL_BUILD_MATRIX:-0} 31 | export BUILDDIR=${BUILDDIR:-"$(pwd)/build"} 32 | export EXTRA_CMAKE_ARGS=${EXTRA_CMAKE_ARGS:-""} 33 | export BUILD=1 34 | export TEST=1 35 | 36 | cleanup() { 37 | echo 38 | echo Exit code $1 caught in build script. 39 | echo 40 | if [[ "$1" == "0" ]]; then 41 | echo BUILD_STATUS:0 42 | else 43 | echo 44 | echo Failure found in build script. 45 | echo 46 | echo BUILD_STATUS:1 47 | fi 48 | } 49 | 50 | trap 'cleanup $? $LINENO' EXIT 51 | 52 | while [[ $# -gt 0 ]] 53 | do 54 | case $1 in 55 | --build-only|-B) 56 | echo 57 | echo Building only 58 | echo 59 | export BUILD=1 60 | export TEST=0 61 | shift 62 | ;; 63 | --test-only|-T) 64 | echo 65 | echo Testing only 66 | echo 67 | export BUILD=0 68 | export TEST=1 69 | shift 70 | ;; 71 | --help|*) 72 | trap - 1 2 3 15 # we don't need traps if a user is asking for help 73 | cat <, LLNL 53 | * 54 | */ 55 | 56 | #include "hiopVectorIntRaja.hpp" 57 | 58 | #include "MemBackendUmpireImpl.hpp" 59 | #include "ExecPoliciesRajaOmpImpl.hpp" 60 | 61 | namespace hiop 62 | { 63 | using hiop_raja_exec = ExecRajaPoliciesBackend::hiop_raja_exec; 64 | using hiop_raja_reduce = ExecRajaPoliciesBackend::hiop_raja_reduce; 65 | } // namespace hiop 66 | 67 | #include "hiopVectorIntRajaImpl.hpp" 68 | 69 | namespace hiop 70 | { 71 | 72 | // 73 | // Explicit instantiations: force compilation 74 | // 75 | template class hiopVectorIntRaja; 76 | template class hiopVectorIntRaja; 77 | } // namespace hiop 78 | -------------------------------------------------------------------------------- /src/Drivers/Sparse/NlpSparseEx1.hpp: -------------------------------------------------------------------------------- 1 | #ifndef HIOP_EXAMPLE_SPARSE_EX1 2 | #define HIOP_EXAMPLE_SPARSE_EX1 3 | 4 | #include "hiopInterface.hpp" 5 | 6 | #include 7 | 8 | using size_type = hiop::size_type; 9 | using index_type = hiop::index_type; 10 | 11 | /* Test with bounds and constraints of all types. For some reason this 12 | * example is not very well behaved numerically. 13 | * min sum scal*1/4* { (x_{i}-1)^4 : i=1,...,n} 14 | * s.t. 15 | * scal * 4*x_1 + 2*x_2 == scal*10 16 | * scal * 5<= scal * 2*x_1 + x_3 17 | * scal * 1<= scal * 2*x_1 + 0.5*x_i <= scal*2*n, for i=4,...,n 18 | * x_1 free 19 | * 0.0 <= x_2 20 | * 1.5 <= x_3 <= 10 21 | * x_i >=0.5, i=4,...,n 22 | */ 23 | class SparseEx1 : public hiop::hiopInterfaceSparse 24 | { 25 | public: 26 | SparseEx1(int n, double scal_in); 27 | virtual ~SparseEx1(); 28 | 29 | virtual bool get_prob_sizes(size_type& n, size_type& m); 30 | virtual bool get_vars_info(const size_type& n, double* xlow, double* xupp, NonlinearityType* type); 31 | virtual bool get_cons_info(const size_type& m, double* clow, double* cupp, NonlinearityType* type); 32 | 33 | virtual bool get_sparse_blocks_info(size_type& nx, 34 | size_type& nnz_sparse_Jaceq, 35 | size_type& nnz_sparse_Jacineq, 36 | size_type& nnz_sparse_Hess_Lagr); 37 | 38 | virtual bool eval_f(const size_type& n, const double* x, bool new_x, double& obj_value); 39 | virtual bool eval_cons(const size_type& n, 40 | const size_type& m, 41 | const size_type& num_cons, 42 | const index_type* idx_cons, 43 | const double* x, 44 | bool new_x, 45 | double* cons); 46 | virtual bool eval_cons(const size_type& n, const size_type& m, const double* x, bool new_x, double* cons); 47 | virtual bool eval_grad_f(const size_type& n, const double* x, bool new_x, double* gradf); 48 | virtual bool eval_Jac_cons(const size_type& n, 49 | const size_type& m, 50 | const size_type& num_cons, 51 | const index_type* idx_cons, 52 | const double* x, 53 | bool new_x, 54 | const size_type& nnzJacS, 55 | index_type* iJacS, 56 | index_type* jJacS, 57 | double* MJacS); 58 | virtual bool eval_Jac_cons(const size_type& n, 59 | const size_type& m, 60 | const double* x, 61 | bool new_x, 62 | const size_type& nnzJacS, 63 | index_type* iJacS, 64 | index_type* jJacS, 65 | double* MJacS); 66 | virtual bool get_starting_point(const size_type& n, double* x0); 67 | virtual bool eval_Hess_Lagr(const size_type& n, 68 | const size_type& m, 69 | const double* x, 70 | bool new_x, 71 | const double& obj_factor, 72 | const double* lambda, 73 | bool new_lambda, 74 | const size_type& nnzHSS, 75 | index_type* iHSS, 76 | index_type* jHSS, 77 | double* MHSS); 78 | 79 | // not implemented 80 | virtual bool 81 | get_starting_point(const size_type&, const size_type&, double*, bool&, double*, double*, double*, bool&, double*) 82 | { 83 | return false; 84 | } 85 | 86 | virtual bool 87 | get_warmstart_point(const size_type&, const size_type&, double*, double*, double*, double*, double*, double*, double*) 88 | { 89 | return false; 90 | } 91 | 92 | private: 93 | size_type n_vars, n_cons; 94 | double scal; 95 | }; 96 | #endif 97 | -------------------------------------------------------------------------------- /src/Optimization/hiopFilter.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017, Lawrence Livermore National Security, LLC. 2 | // Produced at the Lawrence Livermore National Laboratory (LLNL). 3 | // Written by Cosmin G. Petra, petra1@llnl.gov. 4 | // LLNL-CODE-742473. All rights reserved. 5 | // 6 | // This file is part of HiOp. For details, see https://github.com/LLNL/hiop. HiOp 7 | // is released under the BSD 3-clause license (https://opensource.org/licenses/BSD-3-Clause). 8 | // Please also read “Additional BSD Notice” below. 9 | // 10 | // Redistribution and use in source and binary forms, with or without modification, 11 | // are permitted provided that the following conditions are met: 12 | // i. Redistributions of source code must retain the above copyright notice, this list 13 | // of conditions and the disclaimer below. 14 | // ii. Redistributions in binary form must reproduce the above copyright notice, 15 | // this list of conditions and the disclaimer (as noted below) in the documentation and/or 16 | // other materials provided with the distribution. 17 | // iii. Neither the name of the LLNS/LLNL nor the names of its contributors may be used to 18 | // endorse or promote products derived from this software without specific prior written 19 | // permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 22 | // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 23 | // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 24 | // SHALL LAWRENCE LIVERMORE NATIONAL SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR 25 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 28 | // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | // 32 | // Additional BSD Notice 33 | // 1. This notice is required to be provided under our contract with the U.S. Department 34 | // of Energy (DOE). This work was produced at Lawrence Livermore National Laboratory under 35 | // Contract No. DE-AC52-07NA27344 with the DOE. 36 | // 2. Neither the United States Government nor Lawrence Livermore National Security, LLC 37 | // nor any of their employees, makes any warranty, express or implied, or assumes any 38 | // liability or responsibility for the accuracy, completeness, or usefulness of any 39 | // information, apparatus, product, or process disclosed, or represents that its use would 40 | // not infringe privately-owned rights. 41 | // 3. Also, reference herein to any specific commercial products, process, or services by 42 | // trade name, trademark, manufacturer or otherwise does not necessarily constitute or 43 | // imply its endorsement, recommendation, or favoring by the United States Government or 44 | // Lawrence Livermore National Security, LLC. The views and opinions of authors expressed 45 | // herein do not necessarily state or reflect those of the United States Government or 46 | // Lawrence Livermore National Security, LLC, and shall not be used for advertising or 47 | // product endorsement purposes. 48 | 49 | #include "hiopFilter.hpp" 50 | 51 | using namespace std; 52 | 53 | namespace hiop 54 | { 55 | 56 | bool hiopFilter::contains(const double& theta, const double& phi) const 57 | { 58 | list::const_iterator it = entries.begin(); 59 | bool bFound = false; 60 | while(it != entries.end()) { 61 | if(theta >= it->theta && phi >= it->phi) { 62 | bFound = true; 63 | break; 64 | } 65 | ++it; 66 | } 67 | return bFound; 68 | } 69 | 70 | void hiopFilter::print(FILE* file, const char* msg) const 71 | { 72 | if(msg) fprintf(file, "%s", msg); 73 | fprintf(file, " (theta, phi) pairs: "); 74 | 75 | for(auto& fe: entries) { 76 | fprintf(file, "(%22.16e, %22.16e) ", fe.theta, fe.phi); 77 | } 78 | 79 | if(entries.size() == 0) { 80 | fprintf(file, "filter is empty"); 81 | } 82 | fprintf(file, "\n"); 83 | } 84 | 85 | }; // namespace hiop 86 | -------------------------------------------------------------------------------- /tests/LinAlg/vectorTestsIntSeq.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017, Lawrence Livermore National Security, LLC. 2 | // Produced at the Lawrence Livermore National Laboratory (LLNL). 3 | // Written by Cosmin G. Petra, petra1@llnl.gov. 4 | // LLNL-CODE-742473. All rights reserved. 5 | // 6 | // This file is part of HiOp. For details, see https://github.com/LLNL/hiop. HiOp 7 | // is released under the BSD 3-clause license (https://opensource.org/licenses/BSD-3-Clause). 8 | // Please also read “Additional BSD Notice” below. 9 | // 10 | // Redistribution and use in source and binary forms, with or without modification, 11 | // are permitted provided that the following conditions are met: 12 | // i. Redistributions of source code must retain the above copyright notice, this list 13 | // of conditions and the disclaimer below. 14 | // ii. Redistributions in binary form must reproduce the above copyright notice, 15 | // this list of conditions and the disclaimer (as noted below) in the documentation and/or 16 | // other materials provided with the distribution. 17 | // iii. Neither the name of the LLNS/LLNL nor the names of its contributors may be used to 18 | // endorse or promote products derived from this software without specific prior written 19 | // permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 22 | // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 23 | // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 24 | // SHALL LAWRENCE LIVERMORE NATIONAL SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR 25 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 28 | // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | // 32 | // Additional BSD Notice 33 | // 1. This notice is required to be provided under our contract with the U.S. Department 34 | // of Energy (DOE). This work was produced at Lawrence Livermore National Laboratory under 35 | // Contract No. DE-AC52-07NA27344 with the DOE. 36 | // 2. Neither the United States Government nor Lawrence Livermore National Security, LLC 37 | // nor any of their employees, makes any warranty, express or implied, or assumes any 38 | // liability or responsibility for the accuracy, completeness, or usefulness of any 39 | // information, apparatus, product, or process disclosed, or represents that its use would 40 | // not infringe privately-owned rights. 41 | // 3. Also, reference herein to any specific commercial products, process, or services by 42 | // trade name, trademark, manufacturer or otherwise does not necessarily constitute or 43 | // imply its endorsement, recommendation, or favoring by the United States Government or 44 | // Lawrence Livermore National Security, LLC. The views and opinions of authors expressed 45 | // herein do not necessarily state or reflect those of the United States Government or 46 | // Lawrence Livermore National Security, LLC, and shall not be used for advertising or 47 | // product endorsement purposes. 48 | 49 | /** 50 | * @file vectorTestsIntSeq.hpp 51 | * 52 | * @author Asher Mancinelli , PNNL 53 | * 54 | */ 55 | #pragma once 56 | 57 | #include 58 | #include "vectorTestsInt.hpp" 59 | 60 | namespace hiop 61 | { 62 | namespace tests 63 | { 64 | 65 | /** 66 | * @brief Collection of helper methods for hiopVectorIntSeq 67 | * 68 | * Contains implementation details for testing hiopVectorIntSeq 69 | * 70 | */ 71 | class VectorTestsIntSeq : public VectorTestsInt 72 | { 73 | public: 74 | VectorTestsIntSeq() {} 75 | virtual ~VectorTestsIntSeq() {} 76 | 77 | private: 78 | virtual int getLocalElement(hiop::hiopVectorInt*, int) const; 79 | virtual void setLocalElement(hiop::hiopVectorInt*, int, int) const; 80 | virtual void setLocalElement(hiop::hiopVectorInt*, int) const; 81 | }; 82 | 83 | } // namespace tests 84 | } // namespace hiop 85 | -------------------------------------------------------------------------------- /tests/LinAlg/vectorTestsIntRaja.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017, Lawrence Livermore National Security, LLC. 2 | // Produced at the Lawrence Livermore National Laboratory (LLNL). 3 | // Written by Cosmin G. Petra, petra1@llnl.gov. 4 | // LLNL-CODE-742473. All rights reserved. 5 | // 6 | // This file is part of HiOp. For details, see https://github.com/LLNL/hiop. HiOp 7 | // is released under the BSD 3-clause license (https://opensource.org/licenses/BSD-3-Clause). 8 | // Please also read “Additional BSD Notice” below. 9 | // 10 | // Redistribution and use in source and binary forms, with or without modification, 11 | // are permitted provided that the following conditions are met: 12 | // i. Redistributions of source code must retain the above copyright notice, this list 13 | // of conditions and the disclaimer below. 14 | // ii. Redistributions in binary form must reproduce the above copyright notice, 15 | // this list of conditions and the disclaimer (as noted below) in the documentation and/or 16 | // other materials provided with the distribution. 17 | // iii. Neither the name of the LLNS/LLNL nor the names of its contributors may be used to 18 | // endorse or promote products derived from this software without specific prior written 19 | // permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 22 | // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 23 | // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 24 | // SHALL LAWRENCE LIVERMORE NATIONAL SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR 25 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 28 | // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | // 32 | // Additional BSD Notice 33 | // 1. This notice is required to be provided under our contract with the U.S. Department 34 | // of Energy (DOE). This work was produced at Lawrence Livermore National Laboratory under 35 | // Contract No. DE-AC52-07NA27344 with the DOE. 36 | // 2. Neither the United States Government nor Lawrence Livermore National Security, LLC 37 | // nor any of their employees, makes any warranty, express or implied, or assumes any 38 | // liability or responsibility for the accuracy, completeness, or usefulness of any 39 | // information, apparatus, product, or process disclosed, or represents that its use would 40 | // not infringe privately-owned rights. 41 | // 3. Also, reference herein to any specific commercial products, process, or services by 42 | // trade name, trademark, manufacturer or otherwise does not necessarily constitute or 43 | // imply its endorsement, recommendation, or favoring by the United States Government or 44 | // Lawrence Livermore National Security, LLC. The views and opinions of authors expressed 45 | // herein do not necessarily state or reflect those of the United States Government or 46 | // Lawrence Livermore National Security, LLC, and shall not be used for advertising or 47 | // product endorsement purposes. 48 | 49 | /** 50 | * @file vectorTestsIntRaja.hpp 51 | * 52 | * @author Asher Mancinelli , PNNL 53 | * 54 | */ 55 | #pragma once 56 | 57 | #include 58 | #include "vectorTestsInt.hpp" 59 | 60 | namespace hiop 61 | { 62 | namespace tests 63 | { 64 | 65 | /** 66 | * @brief Collection of helper methods for hiopVectorIntRaja 67 | * 68 | * Contains implementation details for testing hiopVectorIntRaja 69 | * 70 | */ 71 | class VectorTestsIntRaja : public VectorTestsInt 72 | { 73 | public: 74 | VectorTestsIntRaja() {} 75 | virtual ~VectorTestsIntRaja() {} 76 | 77 | private: 78 | virtual int getLocalElement(hiop::hiopVectorInt*, int) const; 79 | virtual void setLocalElement(hiop::hiopVectorInt*, int, int) const; 80 | virtual void setLocalElement(hiop::hiopVectorInt*, int) const; 81 | }; 82 | 83 | } // namespace tests 84 | } // namespace hiop 85 | -------------------------------------------------------------------------------- /src/Drivers/IpoptAdapter/IpoptAdapterDriverPriDecEx2.cpp: -------------------------------------------------------------------------------- 1 | #include "IpIpoptApplication.hpp" 2 | 3 | #include "IpoptAdapter.hpp" 4 | // use HiOp's SparseEx2 - sparse NLP 5 | #include "NlpSparseEx2.hpp" 6 | 7 | #include "NlpSparseEx1.hpp" 8 | #include "hiopNlpFormulation.hpp" 9 | #include "hiopAlgFilterIPM.hpp" 10 | 11 | #include 12 | 13 | using namespace Ipopt; 14 | using namespace hiop; 15 | // Example of how to use IpoptAdapter to solve HiOP-specified problems with Ipopt 16 | 17 | int main(int argv, char** argc) 18 | { 19 | // instantiate a HiOp problem 20 | int nx = 1000; 21 | int S = 1920; 22 | int nS = 5; 23 | double x0[nx]; 24 | for(int i = 0; i < nx; i++) x0[i] = 1.0; 25 | 26 | SparseEx1 nlp_interface(nx, 1.0); 27 | hiopNlpSparse nlp(nlp_interface); 28 | nlp.options->SetStringValue("Hessian", "analytical_exact"); 29 | nlp.options->SetStringValue("duals_update_type", "linear"); 30 | // nlp.options->SetStringValue("duals_init", "zero"); // "lsq" or "zero" 31 | nlp.options->SetStringValue("compute_mode", "cpu"); 32 | nlp.options->SetStringValue("KKTLinsys", "xdycyd"); 33 | // nlp.options->SetStringValue("KKTLinsys", "full"); 34 | // nlp.options->SetStringValue("write_kkt", "yes"); 35 | // nlp.options->SetIntegerValue("max_iter", 100); 36 | nlp.options->SetNumericValue("mu0", 0.1); 37 | hiopAlgFilterIPMNewton solver(&nlp); 38 | hiopSolveStatus status0 = solver.run(); 39 | solver.getSolution(x0); 40 | 41 | double x[nx + S * nx]; 42 | PriDecEx2 hiopNlp(nx, S, nS); 43 | hiopNlp.set_starting_point(x0); 44 | 45 | // Create a new instance of the Ipopt nlp 46 | // (use a SmartPtr, not raw) 47 | SmartPtr mynlp = new hiopSparse2IpoptTNLP(&hiopNlp); 48 | 49 | // Create a new instance of IpoptApplication 50 | // (use a SmartPtr, not raw) 51 | // We are using the factory, since this allows us to compile this 52 | // example with an Ipopt Windows DLL 53 | SmartPtr app = IpoptApplicationFactory(); 54 | 55 | // 56 | // HiOp-compatible Ipopt Options (Ipopt behaves or should behave like HiOp) 57 | // 58 | // app->Options()->SetStringValue("hessian_approximation", "limited-memory"); 59 | // app->Options()->SetStringValue("derivative_test", "first-order"); 60 | // app->Options()->SetNumericValue("derivative_test_perturbation", 1e-7); 61 | // app->Options()->SetNumericValue("bound_push", 1e-2); 62 | // app->Options()->SetNumericValue("bound_relax_factor", 0.); 63 | // app->Options()->SetNumericValue("constr_mult_init_max", 0.001); 64 | 65 | // app->Options()->SetNumericValue("tol", 1e-7); 66 | // app->Options()->SetStringValue("recalc_y", "no"); 67 | // app->Options()->SetIntegerValue("print_level", 11); 68 | // app->Options()->SetStringValue("mu_strategy", "monotone"); 69 | // app->Options()->SetNumericValue("bound_frac", 1e-8); 70 | // app->Options()->SetNumericValue("bound_push", 1e-8); 71 | // app->Options()->SetNumericValue("slack_bound_push", 1e-24); 72 | // app->Options()->SetNumericValue("bound_relax_factor", 0.); 73 | // app->Options()->SetNumericValue("constr_mult_init_max", 0.001); 74 | // app->Options()->SetNumericValue("kappa1", 1e-8); 75 | // app->Options()->SetNumericValue("kappa2", 1e-8); 76 | 77 | // app->Options()->SetStringValue("output_file", "ipopt.out"); 78 | // app->Options()->SetStringValue("derivative_test", "second-order"); //"only-second-order" 79 | // Initialize the IpoptApplication and process the options 80 | ApplicationReturnStatus status; 81 | status = app->Initialize(); 82 | if(status != Solve_Succeeded) { 83 | std::cout << std::endl << std::endl << "*** Error during initialization!" << std::endl; 84 | return (int)status; 85 | } 86 | 87 | // Ask Ipopt to solve the problem 88 | status = app->OptimizeTNLP(mynlp); 89 | 90 | if(status == Solve_Succeeded) { 91 | std::cout << std::endl << std::endl << "*** The problem solved!" << std::endl; 92 | } else { 93 | std::cout << std::endl << std::endl << "*** The problem FAILED!" << std::endl; 94 | } 95 | 96 | // As the SmartPtrs go out of scope, the reference count 97 | // will be decremented and the objects will automatically 98 | // be deleted. 99 | 100 | return (int)status; 101 | } 102 | -------------------------------------------------------------------------------- /src/LinAlg/hiopMatrixDenseRajaOmp.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017, Lawrence Livermore National Security, LLC. 2 | // Produced at the Lawrence Livermore National Laboratory (LLNL). 3 | // Written by Cosmin G. Petra, petra1@llnl.gov. 4 | // LLNL-CODE-742473. All rights reserved. 5 | // 6 | // This file is part of HiOp. For details, see https://github.com/LLNL/hiop. HiOp 7 | // is released under the BSD 3-clause license (https://opensource.org/licenses/BSD-3-Clause). 8 | // Please also read “Additional BSD Notice” below. 9 | // 10 | // Redistribution and use in source and binary forms, with or without modification, 11 | // are permitted provided that the following conditions are met: 12 | // i. Redistributions of source code must retain the above copyright notice, this list 13 | // of conditions and the disclaimer below. 14 | // ii. Redistributions in binary form must reproduce the above copyright notice, 15 | // this list of conditions and the disclaimer (as noted below) in the documentation and/or 16 | // other materials provided with the distribution. 17 | // iii. Neither the name of the LLNS/LLNL nor the names of its contributors may be used to 18 | // endorse or promote products derived from this software without specific prior written 19 | // permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 22 | // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 23 | // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 24 | // SHALL LAWRENCE LIVERMORE NATIONAL SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR 25 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 28 | // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | // 32 | // Additional BSD Notice 33 | // 1. This notice is required to be provided under our contract with the U.S. Department 34 | // of Energy (DOE). This work was produced at Lawrence Livermore National Laboratory under 35 | // Contract No. DE-AC52-07NA27344 with the DOE. 36 | // 2. Neither the United States Government nor Lawrence Livermore National Security, LLC 37 | // nor any of their employees, makes any warranty, express or implied, or assumes any 38 | // liability or responsibility for the accuracy, completeness, or usefulness of any 39 | // information, apparatus, product, or process disclosed, or represents that its use would 40 | // not infringe privately-owned rights. 41 | // 3. Also, reference herein to any specific commercial products, process, or services by 42 | // trade name, trademark, manufacturer or otherwise does not necessarily constitute or 43 | // imply its endorsement, recommendation, or favoring by the United States Government or 44 | // Lawrence Livermore National Security, LLC. The views and opinions of authors expressed 45 | // herein do not necessarily state or reflect those of the United States Government or 46 | // Lawrence Livermore National Security, LLC, and shall not be used for advertising or 47 | // product endorsement purposes. 48 | 49 | /** 50 | * @file hiopMatrixDenseRajaOmp.cpp 51 | * 52 | * @author Cosmin G. Petra , LLNL 53 | * 54 | */ 55 | 56 | #include "hiopMatrixDenseRaja.hpp" 57 | 58 | #include "MemBackendUmpireImpl.hpp" 59 | #include "MemBackendCppImpl.hpp" 60 | #include "ExecPoliciesRajaOmpImpl.hpp" 61 | 62 | namespace hiop 63 | { 64 | using hiop_raja_exec = ExecRajaPoliciesBackend::hiop_raja_exec; 65 | using hiop_raja_reduce = ExecRajaPoliciesBackend::hiop_raja_reduce; 66 | using matrix_exec = ExecRajaPoliciesBackend::matrix_exec; 67 | } // namespace hiop 68 | 69 | #include "hiopMatrixDenseRajaImpl.hpp" 70 | 71 | namespace hiop 72 | { 73 | 74 | // 75 | // Explicit instantiations: force compilation 76 | // 77 | template class hiopMatrixDenseRaja; 78 | template class hiopMatrixDenseRaja; 79 | } // namespace hiop 80 | -------------------------------------------------------------------------------- /src/LinAlg/hiopVectorIntRajaHip.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017, Lawrence Livermore National Security, LLC. 2 | // Produced at the Lawrence Livermore National Laboratory (LLNL). 3 | // Written by Cosmin G. Petra, petra1@llnl.gov. 4 | // LLNL-CODE-742473. All rights reserved. 5 | // 6 | // This file is part of HiOp. For details, see https://github.com/LLNL/hiop. HiOp 7 | // is released under the BSD 3-clause license (https://opensource.org/licenses/BSD-3-Clause). 8 | // Please also read “Additional BSD Notice” below. 9 | // 10 | // Redistribution and use in source and binary forms, with or without modification, 11 | // are permitted provided that the following conditions are met: 12 | // i. Redistributions of source code must retain the above copyright notice, this list 13 | // of conditions and the disclaimer below. 14 | // ii. Redistributions in binary form must reproduce the above copyright notice, 15 | // this list of conditions and the disclaimer (as noted below) in the documentation and/or 16 | // other materials provided with the distribution. 17 | // iii. Neither the name of the LLNS/LLNL nor the names of its contributors may be used to 18 | // endorse or promote products derived from this software without specific prior written 19 | // permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 22 | // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 23 | // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 24 | // SHALL LAWRENCE LIVERMORE NATIONAL SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR 25 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 28 | // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | // 32 | // Additional BSD Notice 33 | // 1. This notice is required to be provided under our contract with the U.S. Department 34 | // of Energy (DOE). This work was produced at Lawrence Livermore National Laboratory under 35 | // Contract No. DE-AC52-07NA27344 with the DOE. 36 | // 2. Neither the United States Government nor Lawrence Livermore National Security, LLC 37 | // nor any of their employees, makes any warranty, express or implied, or assumes any 38 | // liability or responsibility for the accuracy, completeness, or usefulness of any 39 | // information, apparatus, product, or process disclosed, or represents that its use would 40 | // not infringe privately-owned rights. 41 | // 3. Also, reference herein to any specific commercial products, process, or services by 42 | // trade name, trademark, manufacturer or otherwise does not necessarily constitute or 43 | // imply its endorsement, recommendation, or favoring by the United States Government or 44 | // Lawrence Livermore National Security, LLC. The views and opinions of authors expressed 45 | // herein do not necessarily state or reflect those of the United States Government or 46 | // Lawrence Livermore National Security, LLC, and shall not be used for advertising or 47 | // product endorsement purposes. 48 | 49 | /** 50 | * @file hiopVectorIntRajaHip.cpp 51 | * 52 | * @author Cosmin G. Petra , LLNL 53 | * 54 | */ 55 | 56 | #include "hiopVectorIntRaja.hpp" 57 | 58 | #include "MemBackendHipImpl.hpp" 59 | #include "MemBackendUmpireImpl.hpp" 60 | #include "MemBackendCppImpl.hpp" 61 | #include "ExecPoliciesRajaHipImpl.hpp" 62 | 63 | namespace hiop 64 | { 65 | using hiop_raja_exec = ExecRajaPoliciesBackend::hiop_raja_exec; 66 | using hiop_raja_reduce = ExecRajaPoliciesBackend::hiop_raja_reduce; 67 | } // namespace hiop 68 | 69 | #include "hiopVectorIntRajaImpl.hpp" 70 | 71 | namespace hiop 72 | { 73 | 74 | // CUDA-specific method implementation goes here 75 | 76 | // 77 | // Explicit instantiations: force compilation 78 | // 79 | template class hiopVectorIntRaja; 80 | template class hiopVectorIntRaja; 81 | } // namespace hiop 82 | -------------------------------------------------------------------------------- /src/LinAlg/hiopVectorIntRajaCuda.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017, Lawrence Livermore National Security, LLC. 2 | // Produced at the Lawrence Livermore National Laboratory (LLNL). 3 | // Written by Cosmin G. Petra, petra1@llnl.gov. 4 | // LLNL-CODE-742473. All rights reserved. 5 | // 6 | // This file is part of HiOp. For details, see https://github.com/LLNL/hiop. HiOp 7 | // is released under the BSD 3-clause license (https://opensource.org/licenses/BSD-3-Clause). 8 | // Please also read “Additional BSD Notice” below. 9 | // 10 | // Redistribution and use in source and binary forms, with or without modification, 11 | // are permitted provided that the following conditions are met: 12 | // i. Redistributions of source code must retain the above copyright notice, this list 13 | // of conditions and the disclaimer below. 14 | // ii. Redistributions in binary form must reproduce the above copyright notice, 15 | // this list of conditions and the disclaimer (as noted below) in the documentation and/or 16 | // other materials provided with the distribution. 17 | // iii. Neither the name of the LLNS/LLNL nor the names of its contributors may be used to 18 | // endorse or promote products derived from this software without specific prior written 19 | // permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 22 | // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 23 | // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 24 | // SHALL LAWRENCE LIVERMORE NATIONAL SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR 25 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 28 | // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | // 32 | // Additional BSD Notice 33 | // 1. This notice is required to be provided under our contract with the U.S. Department 34 | // of Energy (DOE). This work was produced at Lawrence Livermore National Laboratory under 35 | // Contract No. DE-AC52-07NA27344 with the DOE. 36 | // 2. Neither the United States Government nor Lawrence Livermore National Security, LLC 37 | // nor any of their employees, makes any warranty, express or implied, or assumes any 38 | // liability or responsibility for the accuracy, completeness, or usefulness of any 39 | // information, apparatus, product, or process disclosed, or represents that its use would 40 | // not infringe privately-owned rights. 41 | // 3. Also, reference herein to any specific commercial products, process, or services by 42 | // trade name, trademark, manufacturer or otherwise does not necessarily constitute or 43 | // imply its endorsement, recommendation, or favoring by the United States Government or 44 | // Lawrence Livermore National Security, LLC. The views and opinions of authors expressed 45 | // herein do not necessarily state or reflect those of the United States Government or 46 | // Lawrence Livermore National Security, LLC, and shall not be used for advertising or 47 | // product endorsement purposes. 48 | 49 | /** 50 | * @file hiopVectorIntRajaCuda.cpp 51 | * 52 | * @author Cosmin G. Petra , LLNL 53 | * 54 | */ 55 | 56 | #include "hiopVectorIntRaja.hpp" 57 | 58 | #include "MemBackendCudaImpl.hpp" 59 | #include "MemBackendUmpireImpl.hpp" 60 | #include "MemBackendCppImpl.hpp" 61 | #include "ExecPoliciesRajaCudaImpl.hpp" 62 | 63 | namespace hiop 64 | { 65 | using hiop_raja_exec = ExecRajaPoliciesBackend::hiop_raja_exec; 66 | using hiop_raja_reduce = ExecRajaPoliciesBackend::hiop_raja_reduce; 67 | } // namespace hiop 68 | 69 | #include "hiopVectorIntRajaImpl.hpp" 70 | 71 | namespace hiop 72 | { 73 | 74 | // CUDA-specific method implementation goes here 75 | 76 | // 77 | // Explicit instantiations: force compilation 78 | // 79 | template class hiopVectorIntRaja; 80 | template class hiopVectorIntRaja; 81 | } // namespace hiop 82 | -------------------------------------------------------------------------------- /src/LinAlg/hiopMatrixDenseRajaHip.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017, Lawrence Livermore National Security, LLC. 2 | // Produced at the Lawrence Livermore National Laboratory (LLNL). 3 | // Written by Cosmin G. Petra, petra1@llnl.gov. 4 | // LLNL-CODE-742473. All rights reserved. 5 | // 6 | // This file is part of HiOp. For details, see https://github.com/LLNL/hiop. HiOp 7 | // is released under the BSD 3-clause license (https://opensource.org/licenses/BSD-3-Clause). 8 | // Please also read “Additional BSD Notice” below. 9 | // 10 | // Redistribution and use in source and binary forms, with or without modification, 11 | // are permitted provided that the following conditions are met: 12 | // i. Redistributions of source code must retain the above copyright notice, this list 13 | // of conditions and the disclaimer below. 14 | // ii. Redistributions in binary form must reproduce the above copyright notice, 15 | // this list of conditions and the disclaimer (as noted below) in the documentation and/or 16 | // other materials provided with the distribution. 17 | // iii. Neither the name of the LLNS/LLNL nor the names of its contributors may be used to 18 | // endorse or promote products derived from this software without specific prior written 19 | // permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 22 | // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 23 | // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 24 | // SHALL LAWRENCE LIVERMORE NATIONAL SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR 25 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 28 | // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | // 32 | // Additional BSD Notice 33 | // 1. This notice is required to be provided under our contract with the U.S. Department 34 | // of Energy (DOE). This work was produced at Lawrence Livermore National Laboratory under 35 | // Contract No. DE-AC52-07NA27344 with the DOE. 36 | // 2. Neither the United States Government nor Lawrence Livermore National Security, LLC 37 | // nor any of their employees, makes any warranty, express or implied, or assumes any 38 | // liability or responsibility for the accuracy, completeness, or usefulness of any 39 | // information, apparatus, product, or process disclosed, or represents that its use would 40 | // not infringe privately-owned rights. 41 | // 3. Also, reference herein to any specific commercial products, process, or services by 42 | // trade name, trademark, manufacturer or otherwise does not necessarily constitute or 43 | // imply its endorsement, recommendation, or favoring by the United States Government or 44 | // Lawrence Livermore National Security, LLC. The views and opinions of authors expressed 45 | // herein do not necessarily state or reflect those of the United States Government or 46 | // Lawrence Livermore National Security, LLC, and shall not be used for advertising or 47 | // product endorsement purposes. 48 | 49 | /** 50 | * @file hiopMatrixDenseRajaHip.cpp 51 | * 52 | * @author Cosmin G. Petra , LLNL 53 | * 54 | */ 55 | 56 | #include "hiopMatrixDenseRaja.hpp" 57 | 58 | #include "MemBackendHipImpl.hpp" 59 | #include "MemBackendUmpireImpl.hpp" 60 | #include "MemBackendCppImpl.hpp" 61 | #include "ExecPoliciesRajaHipImpl.hpp" 62 | 63 | namespace hiop 64 | { 65 | using hiop_raja_exec = ExecRajaPoliciesBackend::hiop_raja_exec; 66 | using hiop_raja_reduce = ExecRajaPoliciesBackend::hiop_raja_reduce; 67 | using matrix_exec = ExecRajaPoliciesBackend::matrix_exec; 68 | } // namespace hiop 69 | 70 | #include "hiopMatrixDenseRajaImpl.hpp" 71 | 72 | namespace hiop 73 | { 74 | 75 | // 76 | // Explicit instantiations: force compilation 77 | // 78 | template class hiopMatrixDenseRaja; 79 | template class hiopMatrixDenseRaja; 80 | } // namespace hiop 81 | -------------------------------------------------------------------------------- /src/LinAlg/hiopMatrixDenseRajaCuda.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017, Lawrence Livermore National Security, LLC. 2 | // Produced at the Lawrence Livermore National Laboratory (LLNL). 3 | // Written by Cosmin G. Petra, petra1@llnl.gov. 4 | // LLNL-CODE-742473. All rights reserved. 5 | // 6 | // This file is part of HiOp. For details, see https://github.com/LLNL/hiop. HiOp 7 | // is released under the BSD 3-clause license (https://opensource.org/licenses/BSD-3-Clause). 8 | // Please also read “Additional BSD Notice” below. 9 | // 10 | // Redistribution and use in source and binary forms, with or without modification, 11 | // are permitted provided that the following conditions are met: 12 | // i. Redistributions of source code must retain the above copyright notice, this list 13 | // of conditions and the disclaimer below. 14 | // ii. Redistributions in binary form must reproduce the above copyright notice, 15 | // this list of conditions and the disclaimer (as noted below) in the documentation and/or 16 | // other materials provided with the distribution. 17 | // iii. Neither the name of the LLNS/LLNL nor the names of its contributors may be used to 18 | // endorse or promote products derived from this software without specific prior written 19 | // permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 22 | // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 23 | // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 24 | // SHALL LAWRENCE LIVERMORE NATIONAL SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR 25 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 28 | // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | // 32 | // Additional BSD Notice 33 | // 1. This notice is required to be provided under our contract with the U.S. Department 34 | // of Energy (DOE). This work was produced at Lawrence Livermore National Laboratory under 35 | // Contract No. DE-AC52-07NA27344 with the DOE. 36 | // 2. Neither the United States Government nor Lawrence Livermore National Security, LLC 37 | // nor any of their employees, makes any warranty, express or implied, or assumes any 38 | // liability or responsibility for the accuracy, completeness, or usefulness of any 39 | // information, apparatus, product, or process disclosed, or represents that its use would 40 | // not infringe privately-owned rights. 41 | // 3. Also, reference herein to any specific commercial products, process, or services by 42 | // trade name, trademark, manufacturer or otherwise does not necessarily constitute or 43 | // imply its endorsement, recommendation, or favoring by the United States Government or 44 | // Lawrence Livermore National Security, LLC. The views and opinions of authors expressed 45 | // herein do not necessarily state or reflect those of the United States Government or 46 | // Lawrence Livermore National Security, LLC, and shall not be used for advertising or 47 | // product endorsement purposes. 48 | 49 | /** 50 | * @file hiopMatrixDenseRajaCuda.cpp 51 | * 52 | * @author Cosmin G. Petra , LLNL 53 | * 54 | */ 55 | 56 | #include "hiopMatrixDenseRaja.hpp" 57 | 58 | #include "MemBackendCudaImpl.hpp" 59 | #include "MemBackendUmpireImpl.hpp" 60 | #include "MemBackendCppImpl.hpp" 61 | #include "ExecPoliciesRajaCudaImpl.hpp" 62 | 63 | namespace hiop 64 | { 65 | using hiop_raja_exec = ExecRajaPoliciesBackend::hiop_raja_exec; 66 | using hiop_raja_reduce = ExecRajaPoliciesBackend::hiop_raja_reduce; 67 | using matrix_exec = ExecRajaPoliciesBackend::matrix_exec; 68 | } // namespace hiop 69 | 70 | #include "hiopMatrixDenseRajaImpl.hpp" 71 | 72 | namespace hiop 73 | { 74 | 75 | // 76 | // Explicit instantiations: force compilation 77 | // 78 | template class hiopMatrixDenseRaja; 79 | template class hiopMatrixDenseRaja; 80 | } // namespace hiop 81 | -------------------------------------------------------------------------------- /src/Drivers/Sparse/NlpSparseEx3.hpp: -------------------------------------------------------------------------------- 1 | #ifndef HIOP_EXAMPLE_SPARSE_EX3 2 | #define HIOP_EXAMPLE_SPARSE_EX3 3 | 4 | #include "hiopInterface.hpp" 5 | 6 | #include 7 | 8 | using size_type = hiop::size_type; 9 | using index_type = hiop::index_type; 10 | 11 | /* Test with bounds and constraints of all types. For some reason this 12 | * example is not very well behaved numerically. 13 | * min sum { x_{i} : i=1,...,n} 14 | * s.t. 15 | * x_1 + x_n == 10, , if eq_feas == true or eq_infeas == true 16 | * x_1 + x_n == 10, i=3,...,n, if eq_feas == true 17 | * x_1 + x_n == 15, i=3,...,n, if eq_infeas == true 18 | * 10-a <= x_1 + x_n <= 10+a, , if ineq_feas == true or ineq_infeas == true 19 | * 10-a <= x_1 + x_n <= 15+a, i=3,...,n , if ineq_feas == true 20 | * 3-a <= x_1 + x_n <= 5-a, i=3,...,n, if ineq_infeas == true 21 | * x_i >= 0, i=1,...,n 22 | * 23 | * a >= 0 , by default a = 1e-6 24 | * n >= 3 25 | */ 26 | class SparseEx3 : public hiop::hiopInterfaceSparse 27 | { 28 | public: 29 | SparseEx3(int n, 30 | double scala_a = 1e-6, 31 | bool eq_feas = false, 32 | bool eq_infeas = false, 33 | bool ineq_feas = false, 34 | bool ineq_infeas = false); 35 | virtual ~SparseEx3(); 36 | 37 | virtual bool get_prob_sizes(size_type& n, size_type& m); 38 | virtual bool get_prob_info(NonlinearityType& type); 39 | virtual bool get_vars_info(const size_type& n, double* xlow, double* xupp, NonlinearityType* type); 40 | virtual bool get_cons_info(const size_type& m, double* clow, double* cupp, NonlinearityType* type); 41 | 42 | virtual bool get_sparse_blocks_info(size_type& nx, 43 | size_type& nnz_sparse_Jaceq, 44 | size_type& nnz_sparse_Jacineq, 45 | size_type& nnz_sparse_Hess_Lagr); 46 | 47 | virtual bool eval_f(const size_type& n, const double* x, bool new_x, double& obj_value); 48 | virtual bool eval_cons(const size_type& n, 49 | const size_type& m, 50 | const size_type& num_cons, 51 | const index_type* idx_cons, 52 | const double* x, 53 | bool new_x, 54 | double* cons); 55 | virtual bool eval_cons(const size_type& n, const size_type& m, const double* x, bool new_x, double* cons); 56 | virtual bool eval_grad_f(const size_type& n, const double* x, bool new_x, double* gradf); 57 | virtual bool eval_Jac_cons(const size_type& n, 58 | const size_type& m, 59 | const size_type& num_cons, 60 | const index_type* idx_cons, 61 | const double* x, 62 | bool new_x, 63 | const size_type& nnzJacS, 64 | index_type* iJacS, 65 | index_type* jJacS, 66 | double* MJacS); 67 | virtual bool eval_Jac_cons(const size_type& n, 68 | const size_type& m, 69 | const double* x, 70 | bool new_x, 71 | const size_type& nnzJacS, 72 | index_type* iJacS, 73 | index_type* jJacS, 74 | double* MJacS); 75 | virtual bool get_starting_point(const size_type& n, double* x0); 76 | virtual bool eval_Hess_Lagr(const size_type& n, 77 | const size_type& m, 78 | const double* x, 79 | bool new_x, 80 | const double& obj_factor, 81 | const double* lambda, 82 | bool new_lambda, 83 | const size_type& nnzHSS, 84 | index_type* iHSS, 85 | index_type* jHSS, 86 | double* MHSS); 87 | 88 | private: 89 | size_type n_vars_; 90 | size_type n_cons_; 91 | double scala_a_; 92 | bool eq_feas_; 93 | bool eq_infeas_; 94 | bool ineq_feas_; 95 | bool ineq_infeas_; 96 | size_type nnzJac_; 97 | }; 98 | #endif 99 | --------------------------------------------------------------------------------