Skip to content

Commit

Permalink
PR [solvers] Flag unsupported clarabel options in the header
Browse files Browse the repository at this point in the history
This simplifies the code necessary for the Visit operation.
  • Loading branch information
jwnimmer-tri committed Sep 13, 2024
1 parent 2ed7bed commit 79aa37e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
11 changes: 0 additions & 11 deletions solvers/clarabel_solver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -215,17 +215,6 @@ class SettingsConverter {
}
this->SetFromIntMap(x.name(), x.value());
}
void Visit(const NameValue<clarabel::ClarabelDirectSolveMethods>& x) {
DRAKE_THROW_UNLESS(x.name() == std::string{"direct_solve_method"});
// TODO(jwnimmer-tri) Add support for this option.
// For now it is unsupported and will throw (as an unknown name, below).
}
void Visit(const NameValue<clarabel::ClarabelCliqueMergeMethods>& x) {
DRAKE_THROW_UNLESS(x.name() ==
std::string{"chordal_decomposition_merge_method"});
// TODO(jwnimmer-tri) Add support for this option.
// For now it is unsupported and will throw (as an unknown name, below).
}

private:
void SetFromDoubleMap(const char* name, double* clarabel_value) {
Expand Down
11 changes: 10 additions & 1 deletion tools/workspace/clarabel_cpp_internal/gen_serialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@

from python import runfiles

_FIELDS_TO_SKIP = {
# These are enums, which we don't support yet.
"chordal_decomposition_merge_method",
"direct_solve_method",
}

_PROLOGUE = """\
#pragma once
Expand Down Expand Up @@ -75,7 +81,10 @@ def _settings_names():
def _create_header_text():
result = _PROLOGUE
for name in _settings_names():
result += f" DRAKE_VISIT({name});\n"
if name in _FIELDS_TO_SKIP:
result += f" // skipped: {name}\n"
else:
result += f" DRAKE_VISIT({name});\n"
result += _EPILOGUE
return result

Expand Down
4 changes: 2 additions & 2 deletions tools/workspace/clarabel_cpp_internal/serialize.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void Serialize(Archive* a, DefaultSettings<double>& settings) {
DRAKE_VISIT(min_switch_step_length);
DRAKE_VISIT(min_terminate_step_length);
DRAKE_VISIT(direct_kkt_solver);
DRAKE_VISIT(direct_solve_method);
// skipped: direct_solve_method
DRAKE_VISIT(static_regularization_enable);
DRAKE_VISIT(static_regularization_constant);
DRAKE_VISIT(static_regularization_proportional);
Expand All @@ -52,7 +52,7 @@ void Serialize(Archive* a, DefaultSettings<double>& settings) {
DRAKE_VISIT(iterative_refinement_stop_ratio);
DRAKE_VISIT(presolve_enable);
DRAKE_VISIT(chordal_decomposition_enable);
DRAKE_VISIT(chordal_decomposition_merge_method);
// skipped: chordal_decomposition_merge_method
DRAKE_VISIT(chordal_decomposition_compact);
DRAKE_VISIT(chordal_decomposition_complete_dual);
#undef DRAKE_VISIT
Expand Down

0 comments on commit 79aa37e

Please sign in to comment.