Commit 668f7760 authored by Alexandra Heuschling's avatar Alexandra Heuschling
Browse files

Merge branch 'master' into ssymmetric_dirichlet

# Conflicts:
#	CMakeLists.txt
parents 8774f93e fba5e448
......@@ -2,3 +2,6 @@ Config/config.hh
*.orig
*.rej
.project
*.swp
.DS_Store
/build*/
Base @ 3623fbdf
Subproject commit 5c54ef0065f46b07dbea44644515a00665563235
Subproject commit 3623fbdfb4eba14a65926ff4034bc3916eab2cf0
......@@ -3,10 +3,7 @@ if (WIN32)
cmake_minimum_required (VERSION 3.13)
endif()
#Only set project name if CoMISo is built as stand-alone library
if("${PROJECT_NAME}" STREQUAL "")
project(CoMISo)
endif()
project(CoMISo VERSION 1.1.0)
# add our macro directory to cmake search path
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
......@@ -27,7 +24,7 @@ if( WANT_COMISO_QT )
else()
set (COMISO_QT_CONFIG_FILE_SETTINGS "#define COMISO_QT_AVAILABLE 0" )
endif()
endif( WANT_COMISO_QT )
acg_get_version ()
......@@ -82,7 +79,7 @@ set(CMAKE_FIND_LIBRARY_PREFIXES lib "") #Our blas librariy is called libblas.lib
find_package (BLAS)
if (BLAS_FOUND )
set (COMISO_BLAS_CONFIG_FILE_SETTINGS "#define COMISO_BLAS_AVAILABLE 1" )
list( APPEND COMISO_INCLUDE_DIRECTORIES ${BLAS_INCLUDE_DIRS} )
list( APPEND COMISO_LINK_DIRECTORIES ${BLAS_LIBRARY_DIRS} ${BLAS_LIBRARY_DIR} )
list( APPEND COMISO_LINK_LIBRARIES ${BLAS_LIBRARIES} )
......@@ -106,9 +103,9 @@ endif ()
find_package (SUITESPARSE)
if (SUITESPARSE_FOUND )
list (APPEND NEED_LAPACK "SUITESPARSE")
set (COMISO_SUITESPARSE_CONFIG_FILE_SETTINGS "#define COMISO_SUITESPARSE_AVAILABLE 1" )
list( APPEND COMISO_INCLUDE_DIRECTORIES ${SUITESPARSE_INCLUDE_DIRS} )
list( APPEND COMISO_LINK_DIRECTORIES ${SUITESPARSE_LIBRARY_DIRS} )
list( APPEND COMISO_LINK_LIBRARIES ${SUITESPARSE_LIBRARIES} )
......@@ -177,7 +174,7 @@ endif ()
find_package (METIS)
if (METIS_FOUND )
set (COMISO_METIS_CONFIG_FILE_SETTINGS "#define COMISO_METIS_AVAILABLE 1" )
list( APPEND COMISO_INCLUDE_DIRECTORIES ${METIS_INCLUDE_DIRS} )
list( APPEND COMISO_LINK_DIRECTORIES ${METIS_LIBRARY_DIRS} )
list( APPEND COMISO_LINK_LIBRARIES ${METIS_LIBRARIES} )
......@@ -203,9 +200,9 @@ if (IPOPT_FOUND)
list( APPEND COMISO_LINK_DIRECTORIES ${IPOPT_LIBRARY_DIRS} )
list( APPEND COMISO_LINK_LIBRARIES ${IPOPT_LIBRARIES} )
if ( IPOPT_HSL_LIBRARY_DIR )
set (COMISO_HSL_CONFIG_FILE_SETTINGS "#define COMISO_HSL_AVAILABLE 1" )
set (COMISO_HSL_CONFIG_FILE_SETTINGS "#define COMISO_HSL_AVAILABLE 1" )
else ()
set (COMISO_HSL_CONFIG_FILE_SETTINGS "#define COMISO_HSL_AVAILABLE 0" )
set (COMISO_HSL_CONFIG_FILE_SETTINGS "#define COMISO_HSL_AVAILABLE 0" )
endif()
else ()
message (STATUS "IPOPT or dependency not found!")
......@@ -281,14 +278,14 @@ else ()
set (COMISO_OSI_CONFIG_FILE_SETTINGS "#define COMISO_OSI_AVAILABLE 0" )
endif ()
find_package (Taucs)
find_package (Taucs QUIET)
set (SUPRESS_TAUCS OFF CACHE BOOL "Set to ON if CoMISo should be built without TAUCS.")
if (TAUCS_FOUND AND NOT SUPRESS_TAUCS)
list (APPEND NEED_LAPACK "Taucs")
set (COMISO_TAUCS_CONFIG_FILE_SETTINGS "#define COMISO_TAUCS_AVAILABLE 1" )
list( APPEND COMISO_INCLUDE_DIRECTORIES ${TAUCS_INCLUDE_DIR} )
list( APPEND COMISO_LINK_LIBRARIES ${TAUCS_LIBRARY} )
else ()
message (STATUS "TAUCS not found!")
set (COMISO_TAUCS_CONFIG_FILE_SETTINGS "#define COMISO_TAUCS_AVAILABLE 0" )
......@@ -333,7 +330,7 @@ if (CPLEX_FOUND )
set (COMISO_CPLEX_CONFIG_FILE_SETTINGS "#define COMISO_CPLEX_AVAILABLE 1" )
list( APPEND COMISO_INCLUDE_DIRECTORIES ${CPLEX_INCLUDE_DIRS} )
list( APPEND COMISO_LINK_LIBRARIES ${CPLEX_LIBRARIES} )
#enable c++ support
add_definitions(-DIL_STD)
else ()
......@@ -356,7 +353,7 @@ endif(NEED_LAPACK AND NOT SUITESPARSE_FOUND)
set(CMAKE_FIND_LIBRARY_PREFIXES "${TMP_CMAKE_FIND_LIBRARY_PREFIXES}")
# source code directories
set (directories
set (directories
.
Base/Code
Base/Debug
......@@ -398,7 +395,7 @@ if ( QT5_FOUND )
# Enable automoc
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
list (APPEND COMISO_LINK_LIBRARIES ${QT_LIBRARIES})
endif()
......@@ -406,24 +403,25 @@ endif()
# Then link directories is set as target property below.
link_directories(${COMISO_LINK_DIRECTORIES})
acg_add_library (CoMISo SHARED ${ui} ${sources} ${headers} )
acg_add_library (CoMISo SHARED ${ui} ${sources} ${headers} )
add_library(CoMISo::CoMISo ALIAS CoMISo)
target_include_directories (CoMISo PUBLIC
$<BUILD_INTERFACE:
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/../
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_BINARY_DIR}/../>
$<INSTALL_INTERFACE:include>
${COMISO_INCLUDE_DIRECTORIES}
target_include_directories(CoMISo
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..> # TODO: this is dangerous!
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/>
)
get_target_property(INC_DIRS CoMISo INCLUDE_DIRECTORIES)
message("Target CoMISo include dirs: ${INC_DIRS}")
message("COMISO_INCLUDE_DIRECTORIES: ${COMISO_INCLUDE_DIRECTORIES}")
target_include_directories(CoMISo PUBLIC "${COMISO_INCLUDE_DIRECTORIES}")
#get_target_property(INC_DIRS CoMISo INCLUDE_DIRECTORIES)
#get_target_property(INT_INC_DIRS CoMISo INTERFACE_INCLUDE_DIRECTORIES)
#message("Target CoMISo include dirs: ${INC_DIRS}")
#message("Target CoMISo int include dirs: ${INT_INC_DIRS}")
#message("COMISO_INCLUDE_DIRECTORIES: ${COMISO_INCLUDE_DIRECTORIES}")
#message("COMISO_LINK_DIRECTORIES: ${COMISO_LINK_DIRECTORIES}")
message("COMISO_LINK_DIRECTORIES: ${COMISO_LINK_DIRECTORIES}")
if (COMISO_LINK_DIRECTORIES)
set_target_properties(CoMISo PROPERTIES LINK_DIRECTORIES "${COMISO_LINK_DIRECTORIES}")
endif()
......@@ -463,13 +461,13 @@ if ( QT5_FOUND )
if ( NOT WIN32 )
# Allow targets depending on ACG find the autogenerated header files
target_include_directories( CoMISo PUBLIC
${CMAKE_CURRENT_BINARY_DIR}/CoMISo_autogen/include )
#target_include_directories( CoMISo PUBLIC
# ${CMAKE_CURRENT_BINARY_DIR}/CoMISo_autogen/include )
else()
# Allow targets depending on ACG find the autogenerated header files
target_include_directories( CoMISo PUBLIC
$<$<CONFIG:Debug>:${CMAKE_CURRENT_BINARY_DIR}/CoMISo_autogen/include_Debug/>
$<$<CONFIG:Release>:${CMAKE_CURRENT_BINARY_DIR}/CoMISo_autogen/include_Release/> )
#target_include_directories( CoMISo PUBLIC
# $<$<CONFIG:Debug>:${CMAKE_CURRENT_BINARY_DIR}/CoMISo_autogen/include_Debug/>
# $<$<CONFIG:Release>:${CMAKE_CURRENT_BINARY_DIR}/CoMISo_autogen/include_Release/> )
endif()
endif()
......@@ -485,9 +483,9 @@ acg_print_configure_header (COMISO "CoMISo")
# write config file
configure_file ("${CMAKE_CURRENT_SOURCE_DIR}/Config/config.hh.in"
"CoMISo/Config/config.hh" @ONLY IMMEDIATE)
#######################################################################
# Configure the examples last to be sure, that all configure files
# of the library are already there
......@@ -501,99 +499,119 @@ endif()
if (COMISO_BUILD_EXAMPLES )
if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Examples/factored_solver/CMakeLists.txt" )
add_subdirectory (Examples/factored_solver)
add_subdirectory (Examples/factored_solver)
endif()
if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Examples/quadratic_solver/CMakeLists.txt" )
add_subdirectory (Examples/quadratic_solver)
add_subdirectory (Examples/quadratic_solver)
endif()
if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Examples/test2/CMakeLists.txt" )
add_subdirectory (Examples/test2)
add_subdirectory (Examples/test2)
endif()
if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Examples/small_quadratic_example/CMakeLists.txt" )
add_subdirectory (Examples/small_quadratic_example)
add_subdirectory (Examples/small_quadratic_example)
endif()
if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Examples/small_factored_example/CMakeLists.txt" )
add_subdirectory (Examples/small_factored_example)
add_subdirectory (Examples/small_factored_example)
endif()
if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Examples/super_sparse_matrix/CMakeLists.txt" )
add_subdirectory (Examples/super_sparse_matrix)
add_subdirectory (Examples/super_sparse_matrix)
endif()
if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Examples/eigen_solver/CMakeLists.txt" )
add_subdirectory (Examples/eigen_solver)
add_subdirectory (Examples/eigen_solver)
endif()
if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Examples/small_nsolver/CMakeLists.txt" )
add_subdirectory (Examples/small_nsolver)
add_subdirectory (Examples/small_nsolver)
endif()
if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Examples/small_eigenproblem/CMakeLists.txt" )
add_subdirectory (Examples/small_eigenproblem)
add_subdirectory (Examples/small_eigenproblem)
endif()
if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Examples/small_miqp/CMakeLists.txt" )
add_subdirectory (Examples/small_miqp)
add_subdirectory (Examples/small_miqp)
endif()
if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Examples/small_nleast_squares/CMakeLists.txt" )
add_subdirectory (Examples/small_nleast_squares)
add_subdirectory (Examples/small_nleast_squares)
endif()
if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Examples/small_sparseqr/CMakeLists.txt" )
add_subdirectory (Examples/small_sparseqr)
add_subdirectory (Examples/small_sparseqr)
endif()
if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Examples/small_quadratic_resolve_example/CMakeLists.txt" )
add_subdirectory (Examples/small_quadratic_resolve_example)
add_subdirectory (Examples/small_quadratic_resolve_example)
endif()
if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Examples/small_cplex_soc/CMakeLists.txt" )
add_subdirectory (Examples/small_cplex_soc)
add_subdirectory (Examples/small_cplex_soc)
endif()
if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Examples/small_adolc/CMakeLists.txt" )
add_subdirectory (Examples/small_adolc)
add_subdirectory (Examples/small_adolc)
endif()
if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Examples/small_dco/CMakeLists.txt" )
add_subdirectory (Examples/small_dco)
add_subdirectory (Examples/small_dco)
endif()
if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Examples/vector1_adolc/CMakeLists.txt" )
add_subdirectory (Examples/vector1_adolc)
add_subdirectory (Examples/vector1_adolc)
endif()
if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Examples/small_linear_problem/CMakeLists.txt" )
add_subdirectory (Examples/small_linear_problem)
add_subdirectory (Examples/small_linear_problem)
endif()
if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Examples/crossfield3d/CMakeLists.txt" )
add_subdirectory (Examples/crossfield3d)
add_subdirectory (Examples/crossfield3d)
endif()
if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Examples/crossfield3d/CMakeLists.txt" )
add_subdirectory (Examples/crossfield3d_dco)
add_subdirectory (Examples/crossfield3d_dco)
endif()
if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Examples/small_finite_element/CMakeLists.txt" )
add_subdirectory (Examples/small_finite_element)
add_subdirectory (Examples/small_finite_element)
endif()
if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Examples/small_AQP/CMakeLists.txt" )
add_subdirectory (Examples/small_AQP)
add_subdirectory (Examples/small_AQP)
endif()
if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Examples/finite_element_integrability_problem/CMakeLists.txt" )
add_subdirectory (Examples/finite_element_integrability_problem)
add_subdirectory (Examples/finite_element_integrability_problem)
endif()
if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Examples/small_mosek_native/CMakeLists.txt" )
add_subdirectory (Examples/small_mosek_native)
add_subdirectory (Examples/small_mosek_native)
endif()
if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Examples/small_mosek_fusion_sdp/CMakeLists.txt" )
add_subdirectory (Examples/small_mosek_fusion_sdp)
add_subdirectory (Examples/small_mosek_fusion_sdp)
endif()
if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Examples/small_symmetric_dirichlet/CMakeLists.txt" )
add_subdirectory (Examples/small_symmetric_dirichlet)
endif()
endif (COMISO_BUILD_EXAMPLES )
# Only create install target, when we are building CoMISo standalone
if(${PROJECT_NAME} MATCHES "CoMISo")
if(NOT COMISO_NO_INSTALL)
include(CMakePackageConfigHelpers)
include(GNUInstallDirs)
target_include_directories(CoMISo
PUBLIC
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/CoMISo>
)
set(INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake/CoMISo)
write_basic_package_version_file(
CoMISoConfigVersion.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion)
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/CoMISoConfigVersion.cmake"
DESTINATION ${INSTALL_CONFIGDIR})
# Install library
install (TARGETS CoMISo EXPORT CoMISoTargets
RUNTIME DESTINATION lib
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
install(TARGETS CoMISo EXPORT CoMISoTargets
RUNTIME DESTINATION lib
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
# Install Header Files
install(DIRECTORY .
DESTINATION include/CoMISo
FILES_MATCHING
install(DIRECTORY .
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/CoMISo # include/CoMISo
FILES_MATCHING
PATTERN "*.hh"
PATTERN "*T.cc"
PATTERN "CVS" EXCLUDE
......@@ -606,18 +624,19 @@ if(${PROJECT_NAME} MATCHES "CoMISo")
PATTERN "Debian*" EXCLUDE)
# Install Config File
install( FILES ${CMAKE_BINARY_DIR}/CoMISo/Config/config.hh
DESTINATION include/CoMISo/Config )
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/CoMISo/Config/config.hh
DESTINATION include/CoMISo/Config)
# Create export target to reference CoMISo installation
install(EXPORT CoMISoTargets
FILE CoMISoTargets.cmake
FILE CoMISoConfig.cmake
NAMESPACE CoMISo::
DESTINATION cmake)
install(FILES "${CMAKE_CURRENT_LIST_DIR}/cmake/CoMISoConfig.cmake"
DESTINATION cmake
)
DESTINATION ${INSTALL_CONFIGDIR})
export(EXPORT CoMISoTargets
NAMESPACE CoMISo::
FILE CoMISoConfig.cmake)
export(PACKAGE CoMISo)
endif()
list(REMOVE_AT CMAKE_MODULE_PATH -1)
......@@ -114,14 +114,13 @@ int main(void)
std::cout << "---------- 5) Solve with IPOPT solver... " << std::endl;
COMISO::IPOPTSolver ipopt;
ipopt.app().Options()->SetStringValue("derivative_test", "second-order");
ipopt.set_ipopt_option("derivative_test", "second-order");
ipopt.solve(&lsqp, constraints);
#endif
std::cout << "---------- 6) Print solution..." << std::endl;
for( int i=0; i<n; ++i)
std::cerr << "x_" << i << " = " << lsqp.x()[i] << std::endl;
return 0;
}
......@@ -76,6 +76,8 @@ solve(NProblemInterface* _problem,
// move to next constraint
++n_constraints;
} else {
std::cerr << "Warning: COMISOSolver received a problem with non-equality constraints!!!" << std::endl;
}
// resize matrix to final number of constraints
......
......@@ -80,7 +80,7 @@ private:
} // namespace COMISO
//=============================================================================
// support std vectors
EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(COMISO::ConeConstraint);
EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(COMISO::ConeConstraint)
//=============================================================================
#endif // ACG_CONECONSTRAINT_HH defined
//=============================================================================
......
//=============================================================================
//
// STRUCT IPOPTCallbackParameters
//
//=============================================================================
#ifndef COMISO_IPOPTCALLBACKPARAMETERS_HH
#define COMISO_IPOPTCALLBACKPARAMETERS_HH
#include <IpTNLP.hpp>
//== TYPE DEFINITION CALLBACK PARAMETERS ======================================
namespace COMISO {
struct IPOPTCallbackParameters {
Ipopt::AlgorithmMode mode;
Ipopt::Index iter;
Ipopt::Number obj_value;
Ipopt::Number inf_pr;
Ipopt::Number inf_du;
Ipopt::Number mu;
Ipopt::Number d_norm;
Ipopt::Number regularization_size;
Ipopt::Number alpha_du;
Ipopt::Number alpha_pr;
Ipopt::Index ls_trials;
const Ipopt::IpoptData* ip_data;
Ipopt::IpoptCalculatedQuantities* ip_cq;
};
}
#endif
......@@ -11,21 +11,18 @@
#if COMISO_IPOPT_AVAILABLE
//=============================================================================
#include "CoMISo/Utils/CoMISoError.hh"
#include <CoMISo/Utils/gmm.hh>
#include <Base/Debug/DebTime.hh>
#include "NProblemIPOPT.hh"
#include "NProblemGmmInterface.hh"
#include "NProblemInterface.hh"
#include "NConstraintInterface.hh"
#include "BoundConstraint.hh"
#include "CoMISo/Utils/CoMISoError.hh"
#include <Base/Debug/DebTime.hh>
#include <CoMISo/Utils/gmm.hh>
#include "IPOPTCallbackParameters.hh"
#include <IpTNLP.hpp>
#include <IpIpoptApplication.hpp>
#include <IpSolveStatistics.hpp>
#include "IPOPTProblemInstance.hh"
//== NAMESPACES ===============================================================
......@@ -33,11 +30,10 @@ namespace COMISO {
//== IMPLEMENTATION PROBLEM INSTANCE==========================================================
//== IMPLEMENTATION PROBLEM INSTANCE===========================================
void
NProblemIPOPT::
IPOPTProblemInstance::
split_constraints(const std::vector<NConstraintInterface*>& _constraints)
{
DEB_enter_func;
......@@ -61,7 +57,7 @@ split_constraints(const std::vector<NConstraintInterface*>& _constraints)
void
NProblemIPOPT::
IPOPTProblemInstance::
analyze_special_properties(const NProblemInterface* _problem, const std::vector<NConstraintInterface*>& _constraints)
{
hessian_constant_ = true;
......@@ -98,7 +94,7 @@ analyze_special_properties(const NProblemInterface* _problem, const std::vector<
//-----------------------------------------------------------------------------
bool NProblemIPOPT::get_nlp_info(Index& n, Index& m, Index& nnz_jac_g,
bool IPOPTProblemInstance::get_nlp_info(Index& n, Index& m, Index& nnz_jac_g,
Index& nnz_h_lag, IndexStyleEnum& index_style)
{
DEB_enter_func;
......@@ -161,7 +157,7 @@ bool NProblemIPOPT::get_nlp_info(Index& n, Index& m, Index& nnz_jac_g,
//-----------------------------------------------------------------------------
bool NProblemIPOPT::get_bounds_info(Index n, Number* x_l, Number* x_u,
bool IPOPTProblemInstance::get_bounds_info(Index n, Number* x_l, Number* x_u,
Index m, Number* g_l, Number* g_u)
{
DEB_enter_func;
......@@ -230,7 +226,7 @@ bool NProblemIPOPT::get_bounds_info(Index n, Number* x_l, Number* x_u,
//-----------------------------------------------------------------------------
bool NProblemIPOPT::get_starting_point(Index n, bool init_x, Number* x,
bool IPOPTProblemInstance::get_starting_point(Index n, bool init_x, Number* x,
bool init_z, Number* z_L, Number* z_U,
Index m, bool init_lambda,
Number* lambda)
......@@ -246,7 +242,7 @@ bool NProblemIPOPT::get_starting_point(Index n, bool init_x, Number* x,
//-----------------------------------------------------------------------------
bool NProblemIPOPT::eval_f(Index n, const Number* x, bool new_x, Number& obj_value)
bool IPOPTProblemInstance::eval_f(Index n, const Number* x, bool new_x, Number& obj_value)
{
DEB_enter_func;
// return the value of the objective function
......@@ -258,7 +254,7 @@ bool NProblemIPOPT::eval_f(Index n, const Number* x, bool new_x, Number& obj_val
//-----------------------------------------------------------------------------
bool NProblemIPOPT::eval_grad_f(Index n, const Number* x, bool new_x, Number* grad_f)
bool IPOPTProblemInstance::eval_grad_f(Index n, const Number* x, bool new_x, Number* grad_f)
{
DEB_enter_func;
problem_->eval_gradient(x, grad_f);
......@@ -270,7 +266,7 @@ bool NProblemIPOPT::eval_grad_f(Index n, const Number* x, bool new_x, Number* gr
//-----------------------------------------------------------------------------
bool NProblemIPOPT::eval_g(Index n, const Number* x, bool new_x, Index m, Number* g)
bool IPOPTProblemInstance::eval_g(Index n, const Number* x, bool new_x, Index m, Number* g)
{
DEB_enter_func;
// evaluate all constraint functions
......@@ -284,7 +280,7 @@ bool NProblemIPOPT::eval_g(Index n, const Number* x, bool new_x, Index m, Number
//-----------------------------------------------------------------------------
bool NProblemIPOPT::eval_jac_g(Index n, const Number* x, bool new_x,
bool IPOPTProblemInstance::eval_jac_g(Index n, const Number* x, bool new_x,
Index m, Index nele_jac, Index* iRow, Index *jCol,
Number* values)
{
......@@ -342,7 +338,7 @@ bool NProblemIPOPT::eval_jac_g(Index n, const Number* x, bool new_x,
//-----------------------------------------------------------------------------
bool NProblemIPOPT::eval_h(Index n, const Number* x, bool new_x,
bool IPOPTProblemInstance::eval_h(Index n, const Number* x, bool new_x,
Number obj_factor, Index m, const Number* lambda,
bool new_lambda, Index nele_hess, Index* iRow,
Index* jCol, Number* values)
......@@ -476,7 +472,7 @@ bool NProblemIPOPT::eval_h(Index n, const Number* x, bool new_x,
double _QNT(const double x) { return x; }
void NProblemIPOPT::finalize_solution(SolverReturn status,
void IPOPTProblemInstance::finalize_solution(SolverReturn status,
Index n, const Number* x, const Number* z_L, const Number* z_U,
Index m, const Number* g, const Number* lambda,
Number obj_value,
......@@ -516,21 +512,44 @@ void NProblemIPOPT::finalize_solution(SolverReturn status,
//-----------------------------------------------------------------------------
void
IPOPTProblemInstance::
set_callback_function
(std::function<bool(const IPOPTCallbackParameters &)> func)
{
intermediate_callback_ = func;
}
bool NProblemIPOPT::intermediate_callback(
Ipopt::AlgorithmMode /*mode*/,
Index /*iter*/, Number /*obj_value*/,
Number /*inf_pr*/, Number /*inf_du*/,
Number /*mu*/, Number /*d_norm*/,
Number /*regularization_size*/,
Number /*alpha_du*/, Number /*alpha_pr*/,
Index /*ls_trials*/,
const IpoptData* /*ip_data*/,
IpoptCalculatedQuantities* /*ip_cq*/
)
bool IPOPTProblemInstance::intermediate_callback(
Ipopt::AlgorithmMode mode,
Index iter, Number obj_value,
Number inf_pr, Number inf_du,
Number mu, Number d_norm,
Number regularization_size,
Number alpha_du, Number alpha_pr,
Index ls_trials,
const IpoptData* ip_data,
IpoptCalculatedQuantities* ip_cq
)
{
PROGRESS_TICK;
if(intermediate_callback_) {
IPOPTCallbackParameters callbackParameters {
mode,
iter, obj_value,
inf_pr, inf_du,
mu, d_norm,
regularization_size,
alpha_du, alpha_pr,
ls_trials,
ip_data,
ip_cq
};
return intermediate_callback_(callbackParameters);
}
return true;
}
......@@ -538,7 +557,7 @@ bool NProblemIPOPT::intermediate_callback(
//-----------------------------------------------------------------------------
bool NProblemIPOPT::hessian_constant() const
bool IPOPTProblemInstance::hessian_constant() const
{
return hessian_constant_;
}
......@@ -547,7 +566,7 @@ bool NProblemIPOPT::hessian_constant() const
//-----------------------------------------------------------------------------
bool NProblemIPOPT::jac_c_constant() const