Skip to content

Commit

Permalink
Merge 6.9.5 to master (dartsim#1517)
Browse files Browse the repository at this point in the history
reverted two changes to make patch easier to apply

Co-authored-by: Grey <[email protected]>
Co-authored-by: Steve Peters <[email protected]>
  • Loading branch information
3 people committed Oct 27, 2020
1 parent 836421c commit d8500b7
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 6 deletions.
43 changes: 43 additions & 0 deletions dart/optimizer/ipopt/BackwardCompatibility.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright (c) 2011-2019, The DART development contributors
* All rights reserved.
*
* The list of contributors can be found at:
* https://github.com/dartsim/dart/blob/master/LICENSE
*
* This file is provided under the following "BSD-style" License:
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the following
* conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef DART_OPTIMIZER_IPOPT_BACKWARDCOMPATIBILITY_HPP_
#define DART_OPTIMIZER_IPOPT_BACKWARDCOMPATIBILITY_HPP_

// clang-format off
#define IPOPT_VERSION_GE(x,y,z) \
(IPOPT_VERSION_MAJOR > x || (IPOPT_VERSION_MAJOR >= x && \
(IPOPT_VERSION_MINOR > y || (IPOPT_VERSION_MINOR >= y && \
IPOPT_VERSION_PATCH >= z))))
// clang-format on

#endif // DART_OPTIMIZER_IPOPT_BACKWARDCOMPATIBILITY_HPP_
12 changes: 12 additions & 0 deletions dart/optimizer/ipopt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,18 @@ dart_generate_include_header_file(
${header_names}
)

# Add definitions for the IpOpt version
string(REPLACE "." ";" ipopt_version_list ${IPOPT_VERSION})
list(GET ipopt_version_list 0 IPOPT_VERSION_MAJOR)
list(GET ipopt_version_list 1 IPOPT_VERSION_MINOR)
list(GET ipopt_version_list 2 IPOPT_VERSION_PATCH)
target_compile_definitions(${target_name}
PUBLIC
IPOPT_VERSION_MAJOR=${IPOPT_VERSION_MAJOR}
IPOPT_VERSION_MINOR=${IPOPT_VERSION_MINOR}
IPOPT_VERSION_PATCH=${IPOPT_VERSION_PATCH}
)

# Install
install(
FILES ${hdrs} ${CMAKE_CURRENT_BINARY_DIR}/ipopt.hpp
Expand Down
6 changes: 3 additions & 3 deletions dart/optimizer/ipopt/IpoptSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@ bool IpoptSolver::solve()
std::size_t freq = mProperties.mIterationsPerPrint;
if (freq > 0)
{
mIpoptApp->Options()->SetNumericValue("print_frequency_iter", freq);
mIpoptApp->Options()->SetIntegerValue("print_frequency_iter", freq);
}
else
{
mIpoptApp->Options()->SetNumericValue(
"print_frequency_iter", std::numeric_limits<int>::infinity());
mIpoptApp->Options()->SetIntegerValue(
"print_frequency_iter", std::numeric_limits<int>::max());
}

// Intialize the IpoptApplication and process the options
Expand Down
12 changes: 9 additions & 3 deletions dart/optimizer/ipopt/IpoptSolver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,17 @@
#ifndef DART_OPTIMIZER_IPOPT_IPOPTSOLVER_HPP_
#define DART_OPTIMIZER_IPOPT_IPOPTSOLVER_HPP_

#include <coin/IpIpoptApplication.hpp>
#include <coin/IpTNLP.hpp>

#include <memory>

#include "dart/optimizer/ipopt/BackwardCompatibility.hpp"
#if IPOPT_VERSION_GE(3, 13, 0)
# include <IpIpoptApplication.hpp>
# include <IpTNLP.hpp>
#else
# include <coin/IpIpoptApplication.hpp>
# include <coin/IpTNLP.hpp>
#endif

#include "dart/optimizer/Solver.hpp"

namespace dart {
Expand Down

0 comments on commit d8500b7

Please sign in to comment.