Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
loco-3d
crocoddyl
Commits
786b3d6c
Unverified
Commit
786b3d6c
authored
May 17, 2022
by
Carlos Mastalli
Committed by
GitHub
May 17, 2022
Browse files
Merge pull request #1073 from cmastalli/topic/solvers-and-openmp
Enabled OpenMP in Apple + improved documentation in solvers
parents
c120d80f
f4563ba9
Pipeline
#18697
passed with stage
in 28 minutes and 25 seconds
Changes
8
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
CMakeLists.txt
View file @
786b3d6c
...
...
@@ -20,6 +20,7 @@ INCLUDE(cmake/apple.cmake)
# Print initial message
MESSAGE
(
STATUS
"
${
PROJECT_DESCRIPTION
}
, version
${
PROJECT_VERSION
}
"
)
MESSAGE
(
STATUS
"Copyright (C) 2018-2022 CNRS-LAAS, University of Edinburgh, INRIA"
)
MESSAGE
(
STATUS
" Heriot-Watt University"
)
MESSAGE
(
STATUS
"All rights reserved."
)
MESSAGE
(
STATUS
"Released under the BSD 3-Clause License."
)
...
...
@@ -111,11 +112,15 @@ IF(BUILD_WITH_CODEGEN_SUPPORT)
ENDIF
()
# Add OpenMP
if
(
BUILD_WITH_MULTITHREADS
)
IF
(
BUILD_WITH_MULTITHREADS
)
FIND_PACKAGE
(
OpenMP
)
ENDIF
()
if
(
OPENMP_FOUND AND BUILD_WITH_MULTITHREADS
)
SET
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-fopenmp"
)
IF
(
OPENMP_FOUND AND BUILD_WITH_MULTITHREADS
)
IF
(
APPLE
)
SET
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Xpreprocessor -fopenmp"
)
ELSE
()
SET
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-fopenmp"
)
ENDIF
(
APPLE
)
ADD_DEFINITIONS
(
-DCROCODDYL_WITH_MULTITHREADING
)
ADD_DEFINITIONS
(
-DCROCODDYL_WITH_NTHREADS=
${
BUILD_WITH_NTHREADS
}
)
SET
(
PACKAGE_EXTRA_MACROS
"
${
PACKAGE_EXTRA_MACROS
}
\n
ADD_DEFINITIONS(-DCROCODDYL_WITH_MULTITHREADING -DCROCODDYL_WITH_NTHREADS=
${
BUILD_WITH_NTHREADS
}
)"
)
...
...
bindings/python/crocoddyl/core/solvers/ddp.cpp
View file @
786b3d6c
///////////////////////////////////////////////////////////////////////////////
// BSD 3-Clause License
//
// Copyright (C) 2019-2020, LAAS-CNRS, University of Edinburgh
// Copyright (C) 2019-2022, LAAS-CNRS, University of Edinburgh,
// Heriot-Watt University
// Copyright note valid unless otherwise stated in individual files.
// All rights reserved.
///////////////////////////////////////////////////////////////////////////////
...
...
@@ -34,7 +35,7 @@ void exposeSolverDDP() {
":param problem: shooting problem."
))
.
def
(
"solve"
,
&
SolverDDP
::
solve
,
SolverDDP_solves
(
bp
::
args
(
"self"
,
"init_xs"
,
"init_us"
,
"maxiter"
,
"is
F
easible"
,
"
regInit
"
),
bp
::
args
(
"self"
,
"init_xs"
,
"init_us"
,
"maxiter"
,
"is
_f
easible"
,
"
init_reg
"
),
"Compute the optimal trajectory xopt, uopt as lists of T+1 and T terms.
\n\n
"
"From an initial guess init_xs,init_us (feasible or not), iterate
\n
"
"over computeDirection and tryStep until stoppingCriteria is below
\n
"
...
...
@@ -43,10 +44,10 @@ void exposeSolverDDP() {
":param init_xs: initial guess for state trajectory with T+1 elements (default []).
\n
"
":param init_us: initial guess for control trajectory with T elements (default []) (default []).
\n
"
":param maxiter: maximum allowed number of iterations (default 100).
\n
"
":param is
F
easible: true if the init_xs are obtained from integrating the init_us (rollout)
(default
"
"False).
\n
"
":param
regInit
: initial guess for the regularization value. Very low values are typical
\n
"
" used with very good guess points
(init_xs, init_us)
(default
None
).
\n
"
":param is
_f
easible: true if the init_xs are obtained from integrating the init_us (rollout)
\n
"
"
(default
False).
\n
"
":param
init_reg
: initial guess for the regularization value. Very low values are typical
\n
"
"
used with very good guess points (default
1e-9
).
\n
"
":returns the optimal trajectory xopt, uopt and a boolean that describes if convergence was reached."
))
.
def
(
"computeDirection"
,
&
SolverDDP
::
computeDirection
,
SolverDDP_computeDirections
(
...
...
bindings/python/crocoddyl/core/solvers/fddp.cpp
View file @
786b3d6c
///////////////////////////////////////////////////////////////////////////////
// BSD 3-Clause License
//
// Copyright (C) 2019-2020, LAAS-CNRS, The University of Edinburgh
// Copyright (C) 2019-2022, LAAS-CNRS, University of Edinburgh,
// Heriot-Watt University
// Copyright note valid unless otherwise stated in individual files.
// All rights reserved.
///////////////////////////////////////////////////////////////////////////////
...
...
@@ -32,7 +33,7 @@ void exposeSolverFDDP() {
":param problem: shooting problem."
))
.
def
(
"solve"
,
&
SolverFDDP
::
solve
,
SolverFDDP_solves
(
bp
::
args
(
"self"
,
"init_xs"
,
"init_us"
,
"maxiter"
,
"is
F
easible"
,
"
regInit
"
),
bp
::
args
(
"self"
,
"init_xs"
,
"init_us"
,
"maxiter"
,
"is
_f
easible"
,
"
init_reg
"
),
"Compute the optimal trajectory xopt, uopt as lists of T+1 and T terms.
\n\n
"
"From an initial guess init_xs,init_us (feasible or not), iterate
\n
"
"over computeDirection and tryStep until stoppingCriteria is below
\n
"
...
...
@@ -41,10 +42,10 @@ void exposeSolverFDDP() {
":param init_xs: initial guess for state trajectory with T+1 elements (default [])
\n
"
":param init_us: initial guess for control trajectory with T elements (default []).
\n
"
":param maxiter: maximum allowed number of iterations (default 100).
\n
"
":param is
F
easible: true if the init_xs are obtained from integrating the init_us (rollout)
(default
"
"False).
\n
"
":param
regInit
: initial guess for the regularization value. Very low values are typical
\n
"
" used with very good guess points
(init_xs, init_us)
(default
None
).
\n
"
":param is
_f
easible: true if the init_xs are obtained from integrating the init_us (rollout)
\n
"
"
(default
False).
\n
"
":param
init_reg
: initial guess for the regularization value. Very low values are typical
\n
"
"
used with very good guess points (default
1e-9
).
\n
"
":returns the optimal trajectory xopt, uopt and a boolean that describes if convergence was reached."
))
.
def
(
"updateExpectedImprovement"
,
&
SolverFDDP
::
updateExpectedImprovement
,
bp
::
return_value_policy
<
bp
::
copy_const_reference
>
(),
bp
::
args
(
"self"
),
...
...
include/crocoddyl/core/solver-base.hpp
View file @
786b3d6c
///////////////////////////////////////////////////////////////////////////////
// BSD 3-Clause License
//
// Copyright (C) 2019-2021, LAAS-CNRS, University of Edinburgh
// Copyright (C) 2019-2022, LAAS-CNRS, University of Edinburgh,
// Heriot-Watt University
// Copyright note valid unless otherwise stated in individual files.
// All rights reserved.
///////////////////////////////////////////////////////////////////////////////
...
...
@@ -67,13 +68,13 @@ class SolverAbstract {
* until `stoppingCriteria()` is below threshold. It also describes the globalization strategy used during the
* numerical optimization.
*
* @param[in] init_xs initial guess for state trajectory with \f$T+1\f$ elements (default [])
* @param[in] init_us initial guess for control trajectory with \f$T\f$ elements (default [])
* @param[in] maxiter maximum allowed number of iterations (default 100)
* @param[in] is
F
easible true if the \p init_xs are obtained from integrating the \p init_us (rollout) (default
* @param[in] init_xs
initial guess for state trajectory with \f$T+1\f$ elements (default [])
* @param[in] init_us
initial guess for control trajectory with \f$T\f$ elements (default [])
* @param[in] maxiter
maximum allowed number of iterations (default 100)
* @param[in] is
_f
easible true if the \p init_xs are obtained from integrating the \p init_us (rollout) (default
* false)
* @param[in]
regInit
initial guess for the regularization value. Very low values are typical used with very
* good guess points (
init_xs, init_us)
* @param[in]
init_reg
initial guess for the regularization value. Very low values are typical used with very
* good guess points (
default 1e-9).
* @return A boolean that describes if convergence was reached.
*/
virtual
bool
solve
(
const
std
::
vector
<
Eigen
::
VectorXd
>&
init_xs
=
DEFAULT_VECTOR
,
...
...
include/crocoddyl/core/solvers/ddp.hpp
View file @
786b3d6c
///////////////////////////////////////////////////////////////////////////////
// BSD 3-Clause License
//
// Copyright (C) 2019-2021, LAAS-CNRS, University of Edinburgh, University of Oxford
// Copyright (C) 2019-2022, LAAS-CNRS, University of Edinburgh,
// University of Oxford, Heriot-Watt University
// Copyright note valid unless otherwise stated in individual files.
// All rights reserved.
///////////////////////////////////////////////////////////////////////////////
...
...
@@ -62,7 +63,7 @@ class SolverDDP : public SolverAbstract {
virtual
bool
solve
(
const
std
::
vector
<
Eigen
::
VectorXd
>&
init_xs
=
DEFAULT_VECTOR
,
const
std
::
vector
<
Eigen
::
VectorXd
>&
init_us
=
DEFAULT_VECTOR
,
const
std
::
size_t
maxiter
=
100
,
const
bool
is_feasible
=
false
,
const
double
regInit
=
1e-9
);
const
bool
is_feasible
=
false
,
const
double
init_reg
=
1e-9
);
virtual
void
computeDirection
(
const
bool
recalc
=
true
);
virtual
double
tryStep
(
const
double
steplength
=
1
);
virtual
double
stoppingCriteria
();
...
...
include/crocoddyl/core/solvers/fddp.hpp
View file @
786b3d6c
///////////////////////////////////////////////////////////////////////////////
// BSD 3-Clause License
//
// Copyright (C) 2019-2021, LAAS-CNRS, University of Edinburgh
// Copyright (C) 2019-2022, LAAS-CNRS, University of Edinburgh,
// Heriot-Watt University
// Copyright note valid unless otherwise stated in individual files.
// All rights reserved.
///////////////////////////////////////////////////////////////////////////////
...
...
@@ -61,7 +62,7 @@ class SolverFDDP : public SolverDDP {
virtual
bool
solve
(
const
std
::
vector
<
Eigen
::
VectorXd
>&
init_xs
=
DEFAULT_VECTOR
,
const
std
::
vector
<
Eigen
::
VectorXd
>&
init_us
=
DEFAULT_VECTOR
,
const
std
::
size_t
maxiter
=
100
,
const
bool
is_feasible
=
false
,
const
double
regInit
=
1e-9
);
const
bool
is_feasible
=
false
,
const
double
init_reg
=
1e-9
);
/**
* @copybrief SolverAbstract::expectedImprovement
...
...
src/core/solvers/ddp.cpp
View file @
786b3d6c
///////////////////////////////////////////////////////////////////////////////
// BSD 3-Clause License
//
// Copyright (C) 2019-2021, LAAS-CNRS, University of Edinburgh, University of Oxford
// Copyright (C) 2019-2022, LAAS-CNRS, University of Edinburgh,
// University of Oxford, Heriot-Watt University
// Copyright note valid unless otherwise stated in individual files.
// All rights reserved.
///////////////////////////////////////////////////////////////////////////////
...
...
@@ -40,7 +41,7 @@ SolverDDP::SolverDDP(boost::shared_ptr<ShootingProblem> problem)
SolverDDP
::~
SolverDDP
()
{}
bool
SolverDDP
::
solve
(
const
std
::
vector
<
Eigen
::
VectorXd
>&
init_xs
,
const
std
::
vector
<
Eigen
::
VectorXd
>&
init_us
,
const
std
::
size_t
maxiter
,
const
bool
is_feasible
,
const
double
reg
init
)
{
const
std
::
size_t
maxiter
,
const
bool
is_feasible
,
const
double
init
_reg
)
{
START_PROFILER
(
"SolverDDP::solve"
);
if
(
problem_
->
is_updated
())
{
resizeData
();
...
...
@@ -48,12 +49,12 @@ bool SolverDDP::solve(const std::vector<Eigen::VectorXd>& init_xs, const std::ve
xs_try_
[
0
]
=
problem_
->
get_x0
();
// it is needed in case that init_xs[0] is infeasible
setCandidate
(
init_xs
,
init_us
,
is_feasible
);
if
(
std
::
isnan
(
reg
init
))
{
if
(
std
::
isnan
(
init
_reg
))
{
xreg_
=
reg_min_
;
ureg_
=
reg_min_
;
}
else
{
xreg_
=
reg
init
;
ureg_
=
reg
init
;
xreg_
=
init
_reg
;
ureg_
=
init
_reg
;
}
was_feasible_
=
false
;
...
...
src/core/solvers/fddp.cpp
View file @
786b3d6c
///////////////////////////////////////////////////////////////////////////////
// BSD 3-Clause License
//
// Copyright (C) 2019-2021, LAAS-CNRS, University of Edinburgh
// Copyright (C) 2019-2022, LAAS-CNRS, University of Edinburgh
// Heriot-Watt University
// Copyright note valid unless otherwise stated in individual files.
// All rights reserved.
///////////////////////////////////////////////////////////////////////////////
...
...
@@ -21,7 +22,7 @@ SolverFDDP::SolverFDDP(boost::shared_ptr<ShootingProblem> problem)
SolverFDDP
::~
SolverFDDP
()
{}
bool
SolverFDDP
::
solve
(
const
std
::
vector
<
Eigen
::
VectorXd
>&
init_xs
,
const
std
::
vector
<
Eigen
::
VectorXd
>&
init_us
,
const
std
::
size_t
maxiter
,
const
bool
is_feasible
,
const
double
reg
init
)
{
const
std
::
size_t
maxiter
,
const
bool
is_feasible
,
const
double
init
_reg
)
{
START_PROFILER
(
"SolverFDDP::solve"
);
if
(
problem_
->
is_updated
())
{
resizeData
();
...
...
@@ -29,12 +30,12 @@ bool SolverFDDP::solve(const std::vector<Eigen::VectorXd>& init_xs, const std::v
xs_try_
[
0
]
=
problem_
->
get_x0
();
// it is needed in case that init_xs[0] is infeasible
setCandidate
(
init_xs
,
init_us
,
is_feasible
);
if
(
std
::
isnan
(
reg
init
))
{
if
(
std
::
isnan
(
init
_reg
))
{
xreg_
=
reg_min_
;
ureg_
=
reg_min_
;
}
else
{
xreg_
=
reg
init
;
ureg_
=
reg
init
;
xreg_
=
init
_reg
;
ureg_
=
init
_reg
;
}
was_feasible_
=
false
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment