Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved WarmstartInformation object #132

Merged
merged 1 commit into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading