can pass debug flag as parameter.
parent
3e352f109e
commit
2476bbe8d7
|
|
@ -70,19 +70,21 @@ VectorValues LCNLPSolver::initializeDuals() const {
|
|||
}
|
||||
|
||||
/* ************************************************************************* */
|
||||
std::pair<Values, VectorValues> LCNLPSolver::optimize(const Values& initialValues) const {
|
||||
std::pair<Values, VectorValues> LCNLPSolver::optimize(const Values& initialValues, bool debug) const {
|
||||
LCNLPState state(initialValues);
|
||||
state.duals = initializeDuals();
|
||||
while (!state.converged && state.iterations < 100) {
|
||||
state = iterate(state);
|
||||
if (debug)
|
||||
std::cout << "state: iteration " << state.iterations << std::endl;
|
||||
state = iterate(state, debug);
|
||||
}
|
||||
if (debug)
|
||||
std::cout << "Number of iterations: " << state.iterations << std::endl;
|
||||
return std::make_pair(state.values, state.duals);
|
||||
}
|
||||
|
||||
/* ************************************************************************* */
|
||||
LCNLPState LCNLPSolver::iterate(const LCNLPState& state) const {
|
||||
static const bool debug = true;
|
||||
LCNLPState LCNLPSolver::iterate(const LCNLPState& state, bool debug) const {
|
||||
|
||||
// construct the qp subproblem
|
||||
QP qp;
|
||||
|
|
|
|||
|
|
@ -104,13 +104,13 @@ public:
|
|||
/**
|
||||
* Single iteration of SQP
|
||||
*/
|
||||
LCNLPState iterate(const LCNLPState& state) const;
|
||||
LCNLPState iterate(const LCNLPState& state, bool debug = false) const;
|
||||
|
||||
VectorValues initializeDuals() const;
|
||||
/**
|
||||
* Main optimization function.
|
||||
* Main optimization function. new
|
||||
*/
|
||||
std::pair<Values, VectorValues> optimize(const Values& initialValues) const;
|
||||
std::pair<Values, VectorValues> optimize(const Values& initialValues, bool debug = false) const;
|
||||
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue