diff --git a/packages/rol/pyrol/CMakeLists.txt b/packages/rol/pyrol/CMakeLists.txt index be85d4bf11bf..43f9bf395841 100644 --- a/packages/rol/pyrol/CMakeLists.txt +++ b/packages/rol/pyrol/CMakeLists.txt @@ -65,14 +65,19 @@ TRIBITS_ADD_OPTION_AND_DEFINE(PYROL_BINDER_SUPPRESS_ERRORS "Enable the suppress errors option of Binder." OFF ) +TRIBITS_ADD_OPTION_AND_DEFINE(PYROL_BINDER_USE_ONE_FILE + PYROL_USE_ONE_FILE + "Enable the use of one file by Binder." + OFF ) + TRIBITS_ADD_OPTION_AND_DEFINE(PYROL_BINDER_CMAKE_ERROR PYROL_CMAKE_ERROR - "Stop the configuration if binder fails." + "Stop the configuration if Binder fails." ON ) TRIBITS_ADD_OPTION_AND_DEFINE(PYROL_BINDER_VERBOSE PYROL_B_VERBOSE - "Increase the verbosity of binder" + "Increase the verbosity of Binder" OFF ) TRIBITS_ADD_OPTION_AND_DEFINE(PYROL_ENABLE_BINDER_UPDATE @@ -80,6 +85,8 @@ TRIBITS_ADD_OPTION_AND_DEFINE(PYROL_ENABLE_BINDER_UPDATE "Enable the update of the generated source files with Binder." OFF ) +SET(PYROL_BINDER_NUM_FILES "100" CACHE STRING "Maximum number of generated files by Binder.") + MESSAGE("-- PYTHON_EXECUTABLE:") IF(NOT DEFINED ${PYTHON_EXECUTABLE}) find_program(PYTHON_EXECUTABLE @@ -130,6 +137,7 @@ list(APPEND ROL_all_include_dirs "${${PACKAGE_NAME}_SOURCE_DIR}/src/algorithm") list(APPEND ROL_all_include_dirs "${${PACKAGE_NAME}_SOURCE_DIR}/src/algorithm/TypeB") list(APPEND ROL_all_include_dirs "${${PACKAGE_NAME}_SOURCE_DIR}/src/algorithm/TypeE") list(APPEND ROL_all_include_dirs "${${PACKAGE_NAME}_SOURCE_DIR}/src/algorithm/TypeG") +list(APPEND ROL_all_include_dirs "${${PACKAGE_NAME}_SOURCE_DIR}/src/algorithm/TypeP") list(APPEND ROL_all_include_dirs "${${PACKAGE_NAME}_SOURCE_DIR}/src/algorithm/TypeU") list(APPEND ROL_all_include_dirs "${${PACKAGE_NAME}_SOURCE_DIR}/src/algorithm/TypeB/pqn") list(APPEND ROL_all_include_dirs "${${PACKAGE_NAME}_SOURCE_DIR}/src/algorithm/TypeG/augmentedlagrangian/") @@ -266,15 +274,6 @@ IF (PYROL_GENERATE_SRC) endforeach() endforeach() - - #list(REMOVE_DUPLICATES PyROL_all_include_files_without_dir) - #list(REMOVE_ITEM PyROL_all_include_files_without_dir "") - - #list(REMOVE_DUPLICATES PyROL_all_include_files_with_dir) - #list(REMOVE_ITEM PyROL_all_include_files_with_dir "") - - #MESSAGE("PyROL_all_include_files_with_dir = ${PyROL_all_include_files_with_dir}") - SET(CONTENTS "") FOREACH(line IN LISTS all_include_dirs) SET(CONTENTS "${CONTENTS}${line}\n") @@ -295,7 +294,7 @@ IF (PYROL_GENERATE_SRC) file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/python) file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/src) - + file (GLOB PyROLPyFiles2 "${CMAKE_CURRENT_BINARY_DIR}/python/*.py") list (APPEND PyROLPyFiles ${PyROLPyFiles2}) @@ -307,7 +306,12 @@ IF (PYROL_GENERATE_SRC) list(APPEND BINDER_OPTIONS ${binder_include_name}) list(APPEND BINDER_OPTIONS --root-module pyrol) list(APPEND BINDER_OPTIONS --prefix ${CMAKE_CURRENT_BINARY_DIR}/binder) - list(APPEND BINDER_OPTIONS -max-file-size=1000000) + IF(PYROL_USE_ONE_FILE) + list(APPEND BINDER_OPTIONS -single-file) + ELSE() + list(APPEND BINDER_OPTIONS -max-file-size=1000000) + list(APPEND BINDER_OPTIONS -flat) + ENDIF() list(APPEND BINDER_OPTIONS --bind Teuchos) list(APPEND BINDER_OPTIONS --bind ROL) list(APPEND BINDER_OPTIONS --bind pyrol) @@ -317,7 +321,7 @@ IF (PYROL_GENERATE_SRC) list(APPEND BINDER_OPTIONS --config ${BINDER_CFG}) IF(PYROL_SUPPRESS_ERRORS) list(APPEND BINDER_OPTIONS --suppress-errors) - ENDIF() + ENDIF() list(APPEND BINDER_OPTIONS --) IF(TPL_ENABLE_CUDA) list(APPEND BINDER_OPTIONS -x cuda --cuda-host-only) @@ -337,10 +341,18 @@ IF (PYROL_GENERATE_SRC) message("BINDER_OPTIONS='${BINDER_OPTIONS}'") + IF(NOT PYROL_USE_ONE_FILE) + MATH(EXPR NUMBER_FILE "${PYROL_BINDER_NUM_FILES}") + + foreach(index RANGE 0 ${NUMBER_FILE}) + file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/binder/pyrol_${index}.cpp "") + endforeach() + ENDIF() + EXECUTE_PROCESS(COMMAND ${PyROL_BINDER_EXECUTABLE} ${BINDER_OPTIONS} RESULT_VARIABLE STATUS - OUTPUT_VARIABLE OUTPUT_BINDER + OUTPUT_VARIABLE OUTPUT_BINDER ) if(STATUS AND NOT STATUS EQUAL 0) @@ -351,7 +363,7 @@ IF (PYROL_GENERATE_SRC) message("BINDER FAILED: ${STATUS}") endif() else() - message(STATUS "BINDER SUCCESS:") + message(STATUS "BINDER SUCCESS:") message("${OUTPUT_BINDER}") endif() diff --git a/packages/rol/pyrol/example/pytorch/rosenbrock_torch.py b/packages/rol/pyrol/example/pytorch/rosenbrock_torch.py new file mode 100644 index 000000000000..a6e5da79f389 --- /dev/null +++ b/packages/rol/pyrol/example/pytorch/rosenbrock_torch.py @@ -0,0 +1,69 @@ +from TorchVectors import TensorVector +from TorchObjectives import TorchObjective + +from pyrol import getCout, Objective, Problem, Solver +from pyrol.vectors import NumPyVector + +from pyrol.pyrol.Teuchos import ParameterList + +import numpy as np +import time +import torch + + +class RosenbrockObjective(TorchObjective): + + def __init__(self): + super().__init__() + self.alpha = 100 + + def torch_value(self, x): + # return torch.sum(self.alpha*(x[::2]**2 - x[1::2])**2 + (x[::2] - 1)**2) + return torch.sum(self.alpha*(x[:-1]**2 - x[1:])**2 + (x[:-1] - 1)**2) + + +def build_parameter_list(): + params = ParameterList() + params['General'] = ParameterList() + params['General']['Output Level'] = 1 + params['Step'] = ParameterList() + params['Step']['Trust Region'] = ParameterList() + params['Step']['Trust Region']['Subproblem Solver'] = 'Truncated CG' + params['Status Test'] = ParameterList() + params['Status Test']['Iteration Limit'] = 10000 + + return params + + +def main(): + + torch.set_default_dtype(torch.float64) + + device = torch.device('cuda' if torch.cuda.is_available() else 'cpu') + #device = torch.device('cpu') + + start = time.time() + n = int(1e2) + print(device) + x = torch.empty(n, requires_grad=False, device=device) + x[ ::2] = -1.2 + x[1::2] = 1.0 + x = TensorVector(x) + + objective = RosenbrockObjective() + g = x.clone() + + stream = getCout() + + problem = Problem(objective, x, g) + # problem.checkDerivatives(True, stream) + + params = build_parameter_list() + solver = Solver(problem, params) + solver.solve(stream) + print(f"Solve time: {time.time() - start}\n") + + print(g.torch_object.device) + +if __name__ == "__main__": + main() diff --git a/packages/rol/pyrol/pyproject.toml b/packages/rol/pyrol/pyproject.toml index eadbd789546b..17c36d0221a2 100644 --- a/packages/rol/pyrol/pyproject.toml +++ b/packages/rol/pyrol/pyproject.toml @@ -47,3 +47,4 @@ ROL_ENABLE_PYROL = "ON" PYROL_ENABLE_BINDER = "OFF" PYROL_PIP_INSTALL = "ON" CMAKE_INSTALL_RPATH="$ORIGIN/lib64;$ORIGIN/lib;$ORIGIN;@loader_path/lib64;@loader_path/lib;@loader_path" +CMAKE_INTERPROCEDURAL_OPTIMIZATION="OFF" diff --git a/packages/rol/pyrol/python/__init__.py b/packages/rol/pyrol/python/__init__.py index 0aa9682944c4..1dbc5274c14d 100644 --- a/packages/rol/pyrol/python/__init__.py +++ b/packages/rol/pyrol/python/__init__.py @@ -1,6 +1,8 @@ import importlib from . getTypeName import getTypeName, getDefaultScalarType, ROL_classes, ROL_members +from pyrol.pyrol.Teuchos import ParameterList + __version__ = '0.1.0' def version(): diff --git a/packages/rol/pyrol/python/getTypeName.py b/packages/rol/pyrol/python/getTypeName.py index 7838425e1f0a..f71336fca1ac 100644 --- a/packages/rol/pyrol/python/getTypeName.py +++ b/packages/rol/pyrol/python/getTypeName.py @@ -19,13 +19,38 @@ def new_method(self, *args, **kwargs): return cls_method(self, *args, **kwargs) return new_method -def withTrackingConstructor(cls): +def _decorator23(value_method): + def value(*args): + if len(args) == 2: + x, tol = args + return value_method(x.get_1(), x.get_2(), tol) + elif len(args) == 3: + u, z, tol = args + return value_method(u, z, tol) + else: + raise ArgumentError("Unexcepted number of arguments") + return value + + +def _decorator34(value_method): + def value(*args): + if len(args) == 3: + c, x, tol = args + return value_method(c, x.get_1(), x.get_2(), tol) + elif len(args) == 4: + c, u, z, tol = args + return value_method(c, u, z, tol) + raise ArgumentError("Unexcepted number of arguments") + return value + + +def withTrackingConstructor(cls_name, cls): class newCls(cls): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self._tracked_constructor_args = [] - + track(self, *args, **kwargs) method_names = [m for m in dir(cls) if callable(getattr(cls, m))] @@ -33,13 +58,18 @@ def __init__(self, *args, **kwargs): if name.startswith('add'): setattr(newCls, name, tracking_method(getattr(cls, name))) + if cls_name.find('Objective_SimOpt') == 0: + self.value = _decorator23(self.value) + elif cls_name.find('Constraint_SimOpt') == 0: + self.value = _decorator34(self.value) + return newCls ROL_members = {} for cls_name, cls_obj in inspect.getmembers(sys.modules['pyrol.pyrol.ROL']): if inspect.isclass(cls_obj): - cls_obj = withTrackingConstructor(cls_obj) + cls_obj = withTrackingConstructor(cls_name, cls_obj) trackedTypes.append(cls_obj) setattr(sys.modules['pyrol.pyrol.ROL'], cls_name, cls_obj) ROL_members[cls_name] = (cls_obj, inspect.isclass(cls_obj)) @@ -57,3 +87,11 @@ def getTypeName(class_name, scalar_type=getDefaultScalarType()): return ROL_classes[i][1] print("Warning: Unknown type \"{}\", the function returns None.".format(class_name)) return None + + +def getTypeName2(class_name): + for i in range(0, len(ROL_classes)): + if ROL_classes[i][0].lower().find(class_name.lower()) == 0: + return ROL_classes[i][1] + print("Warning: Unknown type \"{}\", the function returns None.".format(class_name)) + return None diff --git a/packages/rol/pyrol/scripts/PyROL_RCP.cfg b/packages/rol/pyrol/scripts/PyROL_RCP.cfg index f587597d046c..3d22c6b3fc4b 100644 --- a/packages/rol/pyrol/scripts/PyROL_RCP.cfg +++ b/packages/rol/pyrol/scripts/PyROL_RCP.cfg @@ -75,6 +75,7 @@ -function ROL::TypeB::AlgorithmFactory -function ROL::TypeE::AlgorithmFactory -function ROL::TypeG::AlgorithmFactory +-function ROL::TypeP::AlgorithmFactory -function ROL::TypeU::AlgorithmFactory -class ROL::ConstraintAssembler @@ -101,7 +102,7 @@ +trampoline_member_function_binder ROL::Vector::clone customClone +include_for_namespace ROL::PyROL --namespace ROL::details +# -namespace ROL::details #################################################r # std library # @@ -156,6 +157,7 @@ -class std::vector +class std::vector +class std::vector ++class std::vector> +class std::vector> -namespace __gnu_cxx diff --git a/packages/rol/pyrol/scripts/create_sdist b/packages/rol/pyrol/scripts/create_sdist index a19ba13ba4fc..6fb60d51e67f 100755 --- a/packages/rol/pyrol/scripts/create_sdist +++ b/packages/rol/pyrol/scripts/create_sdist @@ -4,10 +4,10 @@ # to and then run from the directory containing the ROL repository. -# - Users of this script should check that the variables below are defined +# - Users of this script should check that the variables below are defined # properly. ############################################################################## -TRILINOS_VERSION="14.5" +TRILINOS_VERSION="15.1" REPO_NAME="ROL-Trilinos" LLVM_PREFIX=$(spack location -i llvm) @@ -15,7 +15,7 @@ LLVM_VERSION=$(echo ${LLVM_PREFIX} | awk -F[\-\-] '{print $5}') GCC_PREFIX=$(spack location -i gcc) ############################################################################## -## Other prerequisites: +## Other prerequisites: # * Binder (after the changes on its smart_holder branch) if [ ! command -v binder &> /dev/null ] @@ -54,23 +54,20 @@ cmake -G Ninja \ -D CMAKE_INSTALL_PREFIX:PATH=install \ ./${REPO_NAME} -B./build -## Step 2: Run Binder. -make -C build - -## Step 3: Create the reduced tarball. +## Step 2: Create the reduced tarball. make package_source -C build TARBALL_NAME="trilinos-${TRILINOS_VERSION}-Source" -## Step 4: Unpack the reduced tarball. +## Step 3: Unpack the reduced tarball. [ -d ${TARBALL_NAME} ] && rm -rf ${TARBALL_NAME} tar -zxf "build/${TARBALL_NAME}.tar.gz" -mv ${TARBALL_NAME} pyrol +mv ${TARBALL_NAME} pyrol -## Step 5: Create an SDist from the tarball. +## Step 4: Create an SDist from the tarball. python -m pipx run build --sdist pyrol cp -r pyrol/dist/* . -## Step 6: Clean up. +## Step 5: Clean up. rm -rf build rm -rf ${REPO_NAME}/packages/rol/pyrol/binder rm -rf pyrol diff --git a/packages/rol/pyrol/src/CMakeLists.txt b/packages/rol/pyrol/src/CMakeLists.txt index 1ebc1e8ab97f..d086b86937d2 100644 --- a/packages/rol/pyrol/src/CMakeLists.txt +++ b/packages/rol/pyrol/src/CMakeLists.txt @@ -4,17 +4,41 @@ FILE(COPY ${PYROL_SRC} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) MESSAGE("CMAKE_CURRENT_BINARY_DIR = ${CMAKE_CURRENT_BINARY_DIR}") -file(STRINGS ${CMAKE_CURRENT_BINARY_DIR}/../binder/pyrol.sources BINDER_SRCS) +# file(STRINGS ${CMAKE_CURRENT_BINARY_DIR}/../binder/pyrol.sources BINDER_SRCS) list(TRANSFORM BINDER_SRCS PREPEND "${CMAKE_CURRENT_BINARY_DIR}/../binder/") list(APPEND PYROL_SRC ${BINDER_SRCS}) -MESSAGE("PYROL_SRC with binder = ${PYROL_SRC}") +list(APPEND PYROL_SRC ${CMAKE_CURRENT_BINARY_DIR}/../binder/pyrol.cpp) + +IF(NOT PYROL_USE_ONE_FILE) + MATH(EXPR NUMBER_FILE "${PYROL_BINDER_NUM_FILES}") + + foreach(index RANGE 0 ${NUMBER_FILE}) + list(APPEND PYROL_SRC ${CMAKE_CURRENT_BINARY_DIR}/../binder/pyrol_${index}.cpp) + endforeach() + + MATH(EXPR NUMBER_FILE "${NUMBER_FILE}+1") + + EXECUTE_PROCESS(COMMAND "${CMAKE_COMMAND}" + -D "NUMBER_FILE=${NUMBER_FILE}" + -P "${CMAKE_CURRENT_SOURCE_DIR}/checkNumberFiles.cmake" + RESULT_VARIABLE STATUS + OUTPUT_VARIABLE OUTPUT_CHECKNUMBERFILES + ) + + if(STATUS AND NOT STATUS EQUAL 0) + message("${OUTPUT_CHECKNUMBERFILES}") + message(FATAL_ERROR "checkNumberFiles FAILED: ${STATUS}") + endif() +ENDIF() + +MESSAGE("PYROL_SRC with Binder = ${PYROL_SRC}") pybind11_add_module(pyrol ${PYROL_SRC}) target_include_directories(pyrol PUBLIC ${Mpi4Py_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/../binder "$") target_compile_features(pyrol PUBLIC cxx_std_14) -foreach(depPkg IN LISTS ROL_LIB_ENABLED_DEPENDENCIES) +foreach(depPkg IN LISTS ROL_LIB_ENABLED_DEPENDENCIES) target_link_libraries(pyrol PUBLIC ${depPkg}::all_libs) endforeach() target_link_libraries(pyrol PUBLIC ${Trilinos_EXTRA_LINK_FLAGS}) @@ -25,5 +49,5 @@ INSTALL(TARGETS pyrol add_custom_command(TARGET pyrol POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/pyrol.so ${CMAKE_CURRENT_BINARY_DIR}/../pyrol/. - COMMENT "Copy ${PROJECT_BINARY_DIR}/src/PyROL.so" + COMMENT "Copy ${PROJECT_BINARY_DIR}/src/pyrol.so" ) diff --git a/packages/rol/pyrol/src/PyROL_ETI.hpp b/packages/rol/pyrol/src/PyROL_ETI.hpp index 5cb0efd345b9..979f641cbc6d 100644 --- a/packages/rol/pyrol/src/PyROL_ETI.hpp +++ b/packages/rol/pyrol/src/PyROL_ETI.hpp @@ -1,68 +1,83 @@ #ifndef PYROL_ETI #define PYROL_ETI -#include -#include -#include -#include -#include +#include -#include -#include -#include -#include #include -#include - +#include +#include +#include +#include +#include +#include #include +#include #include - -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #define BINDER_ETI_ABSTRACT(CLASS_NAME) \ template class CLASS_NAME; -#define BINDER_ETI_WITH_FOO(CLASS_NAME) \ - template class CLASS_NAME; \ - template <> inline void PyROL::foo(CLASS_NAME a){} +// #define BINDER_ETI_WITH_FOO(CLASS_NAME) \ +// template class CLASS_NAME; \ +// template <> inline void PyROL::foo(CLASS_NAME a){} -#define BINDER_ROL_VECTOR(SCALAR) \ - BINDER_ETI_ABSTRACT(Vector) \ - BINDER_ETI_ABSTRACT(Vector_SimOpt) - -#define BINDER_ROL_OBJECTIVE(SCALAR) \ +#define BINDER_ROL_CORE(SCALAR) \ + BINDER_ETI_ABSTRACT(Constraint) \ BINDER_ETI_ABSTRACT(Objective) \ - BINDER_ETI_ABSTRACT(Objective_SimOpt) \ - BINDER_ETI_ABSTRACT(Reduced_Objective_SimOpt) \ - BINDER_ETI_ABSTRACT(ReducedDynamicObjective) + BINDER_ETI_ABSTRACT(Problem) \ + BINDER_ETI_ABSTRACT(Solver) \ + BINDER_ETI_ABSTRACT(Vector) -#define BINDER_ROL_CONSTRAINT(SCALAR) \ - BINDER_ETI_ABSTRACT(Constraint) \ - BINDER_ETI_ABSTRACT(SimConstraint) \ +#define BINDER_ROL_SIMOPT(SCALAR) \ BINDER_ETI_ABSTRACT(BoundConstraint_SimOpt) \ - BINDER_ETI_ABSTRACT(SerialConstraint) + BINDER_ETI_ABSTRACT(Reduced_Objective_SimOpt) \ + BINDER_ETI_ABSTRACT(SimConstraint) \ + BINDER_ETI_ABSTRACT(Vector_SimOpt) -#define BINDER_ROL_SOLVER(SCALAR) \ - BINDER_ETI_ABSTRACT(Solver) +#define BINDER_ROL_DYNAMIC(SCALAR) \ + BINDER_ETI_ABSTRACT(DynamicConstraintCheck) \ + BINDER_ETI_ABSTRACT(DynamicObjectiveCheck) \ + BINDER_ETI_ABSTRACT(ReducedDynamicObjective) \ + BINDER_ETI_ABSTRACT(SerialConstraint) \ + BINDER_ETI_ABSTRACT(SerialObjective) -#define BINDER_ROL_PROBLEM(SCALAR) \ - BINDER_ETI_ABSTRACT(Problem) +#define BINDER_ROL_UTILS(SCALAR) \ + BINDER_ETI_ABSTRACT(ValidateFunction) + +#define BINDER_ROL_STOCHASTIC(SCALAR) \ + BINDER_ETI_ABSTRACT(MonteCarloGenerator) \ + BINDER_ETI_ABSTRACT(RiskNeutralObjective) \ + BINDER_ETI_ABSTRACT(SampleGenerator) #define BINDER_ROL_OED(SCALAR) \ BINDER_ETI_ABSTRACT(Factory) namespace ROL { - BINDER_ROL_VECTOR(double) - BINDER_ROL_OBJECTIVE(double) - BINDER_ROL_CONSTRAINT(double) - BINDER_ROL_SOLVER(double) - BINDER_ROL_PROBLEM(double) + BINDER_ROL_CORE(double) + BINDER_ROL_SIMOPT(double) + BINDER_ROL_DYNAMIC(double) + BINDER_ROL_STOCHASTIC(double) + +namespace details { + BINDER_ROL_UTILS(double) +} namespace OED { BINDER_ROL_OED(double) } + } #endif // PYROL_ETI diff --git a/packages/rol/pyrol/src/checkNumberFiles.cmake b/packages/rol/pyrol/src/checkNumberFiles.cmake new file mode 100644 index 000000000000..9cdbbcf3357d --- /dev/null +++ b/packages/rol/pyrol/src/checkNumberFiles.cmake @@ -0,0 +1,12 @@ +if(NOT NUMBER_FILE) + message(FATAL_ERROR "NUMBER_FILE must be specified") +endif() + +if(EXISTS ${CMAKE_CURRENT_BINARY_DIR}/../binder/pyrol_${NUMBER_FILE}.cpp) + MATH(EXPR INDEX "${NUMBER_FILE}+1") + while (EXISTS ${CMAKE_CURRENT_BINARY_DIR}/../binder/pyrol_${INDEX}.cpp) + MATH(EXPR INDEX "${INDEX}+1") + endwhile() + MATH(EXPR INDEX "${INDEX}-1") + message(FATAL_ERROR "File pyrol_${NUMBER_FILE}.cpp exists; please rerun the configuration with PyROL_BINDER_NUM_FILES at least equal to ${INDEX}.") +endif() diff --git a/packages/rol/src/function/dynamic/ROL_DynamicConstraint.hpp b/packages/rol/src/function/dynamic/ROL_DynamicConstraint.hpp index 8606d677ca89..5e0bdb51da3f 100644 --- a/packages/rol/src/function/dynamic/ROL_DynamicConstraint.hpp +++ b/packages/rol/src/function/dynamic/ROL_DynamicConstraint.hpp @@ -124,7 +124,9 @@ class DynamicConstraint : public DynamicFunction { virtual ~DynamicConstraint() {} - DynamicConstraint( std::initializer_list zero_deriv_terms={} ): + DynamicConstraint() : DynamicConstraint( {} ) {} + + DynamicConstraint( std::initializer_list zero_deriv_terms ): DynamicFunction(zero_deriv_terms), unew_ ( nullPtr ), jv_ ( nullPtr ), diff --git a/packages/rol/src/function/dynamic/ROL_DynamicObjective.hpp b/packages/rol/src/function/dynamic/ROL_DynamicObjective.hpp index e68c65099c1c..570ddcd65750 100644 --- a/packages/rol/src/function/dynamic/ROL_DynamicObjective.hpp +++ b/packages/rol/src/function/dynamic/ROL_DynamicObjective.hpp @@ -75,8 +75,9 @@ class DynamicObjective : public DynamicFunction { using V = Vector; using TS = TimeStamp; + DynamicObjective() : DynamicObjective( {} ) {} - DynamicObjective( std::initializer_list zero_deriv_terms={} ) : + DynamicObjective( std::initializer_list zero_deriv_terms ) : DynamicFunction( zero_deriv_terms ) {} virtual ~DynamicObjective() {}