Skip to content
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Re::Solve Changelog

## Changes to Re::Solve since release 0.99.4

- Refactored system solver: Added helper functions to check and fix conflicts in configuration options and to reduce code duplication.
- Code returns errors instead of warnings when encountering ambiguous erronneus inputs from the user.

## HyKKT Release changes

- Exported HyKKT libraries and fixed solver reuse by refreshing numerical data, reusing allocations, resizing GPU transpose workspaces, and handling zero residuals.
Expand Down
58 changes: 25 additions & 33 deletions resolve/SystemSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ namespace ReSolve
// LinSolverIterativeRandFGMRES) as public static methods.
namespace
{
/// Maps string ID to the sketching method enum, warns and defaults to count sketch.
LinSolverIterativeRandFGMRES::SketchingMethod sketchingMethodFromString(const std::string& method)
/// Maps string ID to the sketching method enum. Returns an error if the user inputs an unrecognized method.
LinSolverIterativeRandFGMRES::SketchingMethod sketchingMethodFromString(const std::string& method = "count")
{
if (method == "count")
{
Expand All @@ -64,13 +64,12 @@ namespace ReSolve
{
return LinSolverIterativeRandFGMRES::fwht;
}
out::warning() << "Sketching method " << method << " not recognized!\n"
<< "Using default (count sketch).\n";
out::error() << "Sketching method " << method << " not recognized! Valid arguments are \"count\" and \"fwht\".\n";
return LinSolverIterativeRandFGMRES::cs;
}

/// Maps string ID to the Gram-Schmidt variant enum, warns and defaults to CGS2.
GramSchmidt::GSVariant gsVariantFromString(const std::string& variant)
/// Maps string ID to the Gram-Schmidt variant enum. Returns an error if the user inputs an unrecognized method.
GramSchmidt::GSVariant gsVariantFromString(const std::string& variant = "cgs2")
{
if (variant == "cgs2")
{
Expand All @@ -92,8 +91,8 @@ namespace ReSolve
{
return GramSchmidt::CGS1;
}
out::warning() << "Gram-Schmidt variant " << variant << " not recognized.\n";
out::warning() << "Using default CGS2 Gram-Schmidt variant.\n";
out::error() << "Gram-Schmidt variant " << variant << " not recognized! Valid arguments are:\n"
"\"cgs2\", \"mgs\", \"mgs_two_sync\", \"mgs_pm\", and \"cgs1\".\n";
return GramSchmidt::CGS2;
}

Expand Down Expand Up @@ -750,10 +749,8 @@ namespace ReSolve
{
if (method != "none")
{
out::warning() << "Iterative refinement cannot be enabled together with an "
<< "iterative solve method ('randgmres' or 'fgmres'). "
<< "Keeping refinement method 'none'.\n";
ir_method_ = "none";
out::error() << "Iterative refinement cannot be enabled together with an "
<< "iterative solve method ('randgmres' or 'fgmres').\n";
return 1;
}
ir_method_ = "none";
Expand Down Expand Up @@ -964,8 +961,8 @@ namespace ReSolve
{
if (solve_method_ != "randgmres")
{
out::warning() << "Trying to set sketching method to an incompatible solver.\n";
out::warning() << "The setting will be ignored.\n";
out::error() << "Trying to set sketching method to an incompatible solver\n."
"Sketching can only be used with the \"randgmres\" solver.\n";
return 1;
}

Expand Down Expand Up @@ -994,8 +991,7 @@ namespace ReSolve
*
* Records the variant in `gs_method_` so that it survives re-creation of
* the Krylov solver, and applies it to the existing `GramSchmidt` object
* or creates one if none exists yet. An unrecognized string ID falls back
* to CGS2 with a warning, and `gs_method_` is set to "cgs2" accordingly.
* or creates one if none exists yet.
*
* @param[in] variant - string ID of the Gram-Schmidt variant
*
Expand Down Expand Up @@ -1064,7 +1060,7 @@ namespace ReSolve
* refactorization are set, iterative refinement is optional, and the
* preconditioner must be "none".
*
* Offending settings are reset to "none" with a warning.
* If the user selects incompatible methods, the program will terminate with an error message.
*/
void SystemSolver::validateConfiguration()
{
Expand All @@ -1074,34 +1070,30 @@ namespace ReSolve
{
if (factorization_method_ != "none")
{
out::warning() << "Incorrect input: factorization method '" << factorization_method_
<< "' cannot be used with iterative solve method '" << solve_method_
<< "'. Setting factorization to 'none' ...\n";
factorization_method_ = "none";
out::error() << "Incorrect input: factorization method '" << factorization_method_
<< "' cannot be used with iterative solve method '" << solve_method_
<< "\n";
}
if (refactorization_method_ != "none")
{
out::warning() << "Incorrect input: refactorization method '" << refactorization_method_
<< "' cannot be used with iterative solve method '" << solve_method_
<< "'. Setting refactorization to 'none' ...\n";
refactorization_method_ = "none";
out::error() << "Incorrect input: refactorization method '" << refactorization_method_
<< "' cannot be used with iterative solve method '" << solve_method_
<< "\n";
}
if (ir_method_ != "none")
{
out::warning() << "Incorrect input: iterative refinement cannot be enabled "
<< "together with iterative solve method '" << solve_method_
<< "'. Setting refinement method to 'none' ...\n";
ir_method_ = "none";
out::error() << "Incorrect input: iterative refinement cannot be enabled "
<< "together with iterative solve method '" << solve_method_
<< "\n";
}
}
else
{
if (precondition_method_ != "none")
{
out::warning() << "Incorrect input: preconditioner '" << precondition_method_
<< "' can only be used with an iterative solve method ('fgmres' or 'randgmres'). "
<< "Setting preconditioner to 'none' ...\n";
precondition_method_ = "none";
out::error() << "Incorrect input: preconditioner '" << precondition_method_
<< "' can only be used with an iterative solve method ('fgmres' or 'randgmres'). "
<< "\n";
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/hykkt/HykktSolverTests.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,13 +215,13 @@ namespace ReSolve
status *= validateResult(zero_rhs_error, tol);

// Check that the solver raises an error when trying to change J_d
// from nonempty to empty.
// from nonempty to empty.
matrix::Csr* J_d_empty = new matrix::Csr(J_d->getNumRows(),
J_d->getNumColumns(),
0);

io::Logger::Verbosity saved_verbosity = io::Logger::verbosity();
io::Logger::setVerbosity(io::Logger::NONE); //The error is expected, so mute the logger before triggering it.
io::Logger::setVerbosity(io::Logger::NONE); // The error is expected, so mute the logger before triggering it.
int structure_status = hykktSolver.setMatrixBlocks(H, D_s_reuse, J, J_d_empty);
io::Logger::setVerbosity(saved_verbosity);
status *= (structure_status != 0);
Expand Down
Loading