Skip to content

Commit e9baa57

Browse files
author
Benjamin Chrétien
committed
Add support for ReOptimizeTNLP
1 parent e8018f4 commit e9baa57

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

include/roboptim/core/plugin/ipopt/ipopt-common.hh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ namespace roboptim
123123
/// \brief Intermediate callback (called at each end
124124
/// of iteration).
125125
callback_t callback_;
126+
127+
/// \brief Number of times the solve method was called.
128+
int solveCounter_;
126129
};
127130

128131
/// @}

src/ipopt-common.hxx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ namespace roboptim
4747
: parent_t (pb),
4848
nlp_ (tnlp),
4949
app_ (IpoptApplicationFactory ()),
50-
callback_ ()
50+
callback_ (),
51+
solveCounter_ (0)
5152
{
5253
app_->Jnlst()->DeleteAllJournals();
5354

@@ -80,7 +81,12 @@ namespace roboptim
8081
#define SWITCH_OK(NAME, CASES) \
8182
case NAME: \
8283
{ \
83-
int status = app_->OptimizeTNLP (nlp_); \
84+
int status; \
85+
if (solveCounter_ == 0) \
86+
status = app_->OptimizeTNLP (nlp_); \
87+
else \
88+
status = app_->ReOptimizeTNLP (nlp_); \
89+
solveCounter_++; \
8490
switch (status) \
8591
{ \
8692
CASES; \

0 commit comments

Comments
 (0)