Skip to content

Commit

Permalink
Replaced WarmstartInformation.problem_structure_changed with two flag…
Browse files Browse the repository at this point in the history
…s: hessian_sparsity_changed and jacobian_sparsity_changed. This should allow a finer control in the subproblem solvers.
  • Loading branch information
cvanaret committed Dec 9, 2024
1 parent cdcf8c3 commit 2a2b105
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
4 changes: 2 additions & 2 deletions uno/linear_algebra/SymmetricIndefiniteLinearSystem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ namespace uno {
template <typename ElementType>
void SymmetricIndefiniteLinearSystem<ElementType>::factorize_matrix(DirectSymmetricIndefiniteLinearSolver<size_t, ElementType>& linear_solver,
WarmstartInformation& warmstart_information) {
if (warmstart_information.problem_structure_changed) {
if (warmstart_information.hessian_sparsity_changed || warmstart_information.jacobian_sparsity_changed) {
DEBUG << "Performing symbolic analysis of the indefinite system\n";
linear_solver.do_symbolic_analysis(this->matrix);
warmstart_information.problem_structure_changed = false;
warmstart_information.hessian_sparsity_changed = warmstart_information.jacobian_sparsity_changed = false;
}
DEBUG << "Performing numerical factorization of the indefinite system\n";
linear_solver.do_numerical_factorization(this->matrix);
Expand Down
20 changes: 12 additions & 8 deletions uno/optimization/WarmstartInformation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,21 @@

namespace uno {
void WarmstartInformation::display() const {
std::cout << "Objective: " << std::boolalpha << this->objective_changed << '\n';
std::cout << "Constraints: " << std::boolalpha << this->constraints_changed << '\n';
std::cout << "Constraint bounds: " << std::boolalpha << this->constraint_bounds_changed << '\n';
std::cout << "Variable bounds: " << std::boolalpha << this->variable_bounds_changed << '\n';
std::cout << "Problem structure: " << std::boolalpha << this->problem_structure_changed << '\n';
std::cout << "Objective changed: " << std::boolalpha << this->objective_changed << '\n';
std::cout << "Constraints changed: " << std::boolalpha << this->constraints_changed << '\n';
std::cout << "Constraint bounds changed: " << std::boolalpha << this->constraint_bounds_changed << '\n';
std::cout << "Variable bounds changed: " << std::boolalpha << this->variable_bounds_changed << '\n';
std::cout << "Hessian sparsity changed: " << std::boolalpha << this->hessian_sparsity_changed << '\n';
std::cout << "Jacobian sparsity changed: " << std::boolalpha << this->jacobian_sparsity_changed << '\n';
}

void WarmstartInformation::no_changes() {
this->objective_changed = false;
this->constraints_changed = false;
this->constraint_bounds_changed = false;
this->variable_bounds_changed = false;
this->problem_structure_changed = false;
this->hessian_sparsity_changed = false;
this->jacobian_sparsity_changed = false;
}

void WarmstartInformation::iterate_changed() {
Expand All @@ -33,14 +35,16 @@ namespace uno {
this->constraints_changed = true;
this->constraint_bounds_changed = true;
this->variable_bounds_changed = true;
this->problem_structure_changed = true;
this->hessian_sparsity_changed = true;
this->jacobian_sparsity_changed = true;
}

void WarmstartInformation::only_objective_changed() {
this->objective_changed = true;
this->constraints_changed = false;
this->constraint_bounds_changed = false;
this->variable_bounds_changed = false;
this->problem_structure_changed = false;
this->hessian_sparsity_changed = false;
this->jacobian_sparsity_changed = false;
}
} // namespace
4 changes: 3 additions & 1 deletion uno/optimization/WarmstartInformation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ namespace uno {
bool constraints_changed{true};
bool constraint_bounds_changed{true};
bool variable_bounds_changed{true};
bool problem_structure_changed{true};
// bool problem_structure_changed{true};
bool hessian_sparsity_changed{true};
bool jacobian_sparsity_changed{true};

void display() const;
void no_changes();
Expand Down
2 changes: 1 addition & 1 deletion uno/solvers/BQPD/BQPDSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ namespace uno {
BQPDMode BQPDSolver::determine_mode(const WarmstartInformation& warmstart_information) const {
BQPDMode mode = (this->number_calls == 0) ? BQPDMode::ACTIVE_SET_EQUALITIES : BQPDMode::USER_DEFINED;
// if problem structure changed, use cold start
if (warmstart_information.problem_structure_changed) {
if (warmstart_information.hessian_sparsity_changed || warmstart_information.jacobian_sparsity_changed) {
mode = BQPDMode::ACTIVE_SET_EQUALITIES;
}
// if only the variable bounds changed, reuse the active set estimate and the Jacobian information
Expand Down

0 comments on commit 2a2b105

Please sign in to comment.