diff --git a/solvers/BUILD.bazel b/solvers/BUILD.bazel index a172bc0dc894..47bbabe6c38d 100644 --- a/solvers/BUILD.bazel +++ b/solvers/BUILD.bazel @@ -2098,4 +2098,4 @@ drake_cc_googletest( ], ) -add_lint_tests(enable_clang_format_lint = False) +add_lint_tests() diff --git a/solvers/create_constraint.cc b/solvers/create_constraint.cc index cd22078f3237..1112601dedc9 100644 --- a/solvers/create_constraint.cc +++ b/solvers/create_constraint.cc @@ -346,8 +346,8 @@ std::unique_ptr> MaybeParseLorentzConeConstraint( // deprecation because of the way it is bound in pydrake. if (!greater.is_polynomial() || symbolic::Polynomial(greater).TotalDegree() > 1) { - return nullptr; - } + return nullptr; + } } symbolic::DecomposeAffineExpressions(Vector1{greater}, &A, &b, &greater_vars); @@ -412,12 +412,14 @@ Binding ParseConstraint( if (is_constant(lhs, kInf)) { throw std::runtime_error( fmt::format("ParseConstraint is called with a formula ({}) with " - "a lower bound of +inf.", f)); + "a lower bound of +inf.", + f)); } if (is_constant(rhs, -kInf)) { throw std::runtime_error( fmt::format("ParseConstraint is called with a formula ({}) with " - "an upper bound of -inf.", f)); + "an upper bound of -inf.", + f)); } if (is_constant(lhs, -kInf)) { // The constraint is trivial, but valid. @@ -442,12 +444,14 @@ Binding ParseConstraint( if (is_constant(rhs, kInf)) { throw std::runtime_error( fmt::format("ParseConstraint is called with a formula ({}) with " - "a lower bound of +inf.", f)); + "a lower bound of +inf.", + f)); } if (is_constant(lhs, -kInf)) { throw std::runtime_error( fmt::format("ParseConstraint is called with a formula ({}) with " - "an upper bound of -inf.", f)); + "an upper bound of -inf.", + f)); } if (is_constant(rhs, -kInf)) { // The constraint is trivial, but valid. @@ -703,8 +707,7 @@ shared_ptr MakePolynomialConstraint( } Binding ParseLorentzConeConstraint( - const symbolic::Formula& f, - LorentzConeConstraint::EvalType eval_type, + const symbolic::Formula& f, LorentzConeConstraint::EvalType eval_type, double psd_tol, double coefficient_tol) { auto lorentz_cone_binding = MaybeParseLorentzConeConstraint( f, diff --git a/solvers/create_cost.h b/solvers/create_cost.h index 78ee64393143..f8f7d999a308 100644 --- a/solvers/create_cost.h +++ b/solvers/create_cost.h @@ -42,7 +42,6 @@ Binding ParseL2NormCost(const symbolic::Expression& e, */ Binding ParseCost(const symbolic::Expression& e); - // TODO(eric.cousineau): Remove this when functor cost is no longer exposed // externally, and must be explicitly called. diff --git a/solvers/evaluator_base.cc b/solvers/evaluator_base.cc index 550279fa622e..de1f03f27bfa 100644 --- a/solvers/evaluator_base.cc +++ b/solvers/evaluator_base.cc @@ -73,7 +73,9 @@ std::string EvaluatorBase::DoToLatex(const VectorX& vars, ss << "\\text{" << NiceTypeName::RemoveNamespaces(NiceTypeName::Get(*this)) << "}("; for (int i = 0; i < vars_rows; ++i) { - if (i > 0) { ss << ", "; } + if (i > 0) { + ss << ", "; + } ss << symbolic::ToLatex(vars(i)); } ss << ")"; diff --git a/solvers/mathematical_program.h b/solvers/mathematical_program.h index e6f01d92a2e0..347ce8e892cd 100644 --- a/solvers/mathematical_program.h +++ b/solvers/mathematical_program.h @@ -2111,8 +2111,8 @@ class MathematicalProgram { Binding AddLorentzConeConstraint( const symbolic::Formula& f, LorentzConeConstraint::EvalType eval_type = - LorentzConeConstraint::EvalType::kConvexSmooth, double psd_tol = 1e-8, - double coefficient_tol = 1e-8); + LorentzConeConstraint::EvalType::kConvexSmooth, + double psd_tol = 1e-8, double coefficient_tol = 1e-8); /** * Adds Lorentz cone constraint referencing potentially a subset of the diff --git a/solvers/solver_base.h b/solvers/solver_base.h index 2e62abd8ec85..fc3c1f2b0c49 100644 --- a/solvers/solver_base.h +++ b/solvers/solver_base.h @@ -37,9 +37,7 @@ class SolverBase : public SolverInterface { MathematicalProgramResult*) const override; bool available() const override; bool enabled() const override; - SolverId solver_id() const final { - return solver_id_; - } + SolverId solver_id() const final { return solver_id_; } bool AreProgramAttributesSatisfied(const MathematicalProgram&) const override; std::string ExplainUnsatisfiedProgramAttributes( const MathematicalProgram&) const override; diff --git a/solvers/test/clarabel_solver_test.cc b/solvers/test/clarabel_solver_test.cc index c07b741580aa..ca18c02859b7 100644 --- a/solvers/test/clarabel_solver_test.cc +++ b/solvers/test/clarabel_solver_test.cc @@ -469,8 +469,7 @@ GTEST_TEST(TestOptions, StandaloneReproduction) { ClarabelSolver solver; if (solver.available()) { SolverOptions solver_options; - const std::string repro_file_name = - temp_directory() + "/reproduction.py"; + const std::string repro_file_name = temp_directory() + "/reproduction.py"; solver_options.SetOption( CommonSolverOption::kStandaloneReproductionFileName, repro_file_name); solver.Solve(prog, std::nullopt, solver_options); @@ -506,8 +505,7 @@ GTEST_TEST(TestOptions, EmptyCones) { ClarabelSolver solver; if (solver.available()) { SolverOptions solver_options; - const std::string repro_file_name = - temp_directory() + "/reproduction.py"; + const std::string repro_file_name = temp_directory() + "/reproduction.py"; solver_options.SetOption( CommonSolverOption::kStandaloneReproductionFileName, repro_file_name); solver.Solve(prog, std::nullopt, solver_options); diff --git a/solvers/test/cost_test.cc b/solvers/test/cost_test.cc index b9bd968544e9..4c0810830b09 100644 --- a/solvers/test/cost_test.cc +++ b/solvers/test/cost_test.cc @@ -759,8 +759,8 @@ GTEST_TEST(EvaluatorCost, Eval) { } GTEST_TEST(ExpressionCost, Basic) { - using std::sin; using std::cos; + using std::sin; Variable x("x"), y("y"); symbolic::Expression e = x * sin(y); ExpressionCost cost(e); @@ -779,7 +779,7 @@ GTEST_TEST(ExpressionCost, Basic) { AutoDiffVecXd x_ad = math::InitializeAutoDiff(x_d); AutoDiffVecXd y_ad; - RowVector2d y_deriv_expected(sin(3.5), 1.2*cos(3.5)); + RowVector2d y_deriv_expected(sin(3.5), 1.2 * cos(3.5)); cost.Eval(x_ad, &y_ad); EXPECT_TRUE(CompareMatrices(math::ExtractValue(y_ad), y_expected)); EXPECT_TRUE(CompareMatrices(math::ExtractGradient(y_ad), y_deriv_expected)); diff --git a/solvers/test/create_constraint_test.cc b/solvers/test/create_constraint_test.cc index 811286bf8282..fa677a62f049 100644 --- a/solvers/test/create_constraint_test.cc +++ b/solvers/test/create_constraint_test.cc @@ -112,8 +112,7 @@ void CheckParseLorentzConeConstraint( lesser = get_lhs_expression(f); } EXPECT_TRUE(symbolic::test::PolynomialEqual( - symbolic::Polynomial(z(0)), symbolic::Polynomial(greater), - 1E-10)); + symbolic::Polynomial(z(0)), symbolic::Polynomial(greater), 1E-10)); ASSERT_TRUE(is_sqrt(lesser)); EXPECT_TRUE(symbolic::test::PolynomialEqual( symbolic::Polynomial(z.tail(z.rows() - 1).squaredNorm()), @@ -620,8 +619,7 @@ GTEST_TEST(ParseConstraintTest, FormulaWithInfiniteLowerOrUpperBounds) { Variable x0("x0"), x1("x1"); Vector2 x(x0, x1); Vector2d b(0.12, kInf); - Binding binding = - internal::ParseConstraint(x <= b); + Binding binding = internal::ParseConstraint(x <= b); EXPECT_TRUE(CompareMatrices(binding.evaluator()->upper_bound(), b)); binding = internal::ParseConstraint(-b <= x); // Note: The constraints are sorted via get_operands(f) which returns a diff --git a/solvers/test/osqp_solver_test.cc b/solvers/test/osqp_solver_test.cc index a8a91983ca31..6891381b1738 100644 --- a/solvers/test/osqp_solver_test.cc +++ b/solvers/test/osqp_solver_test.cc @@ -167,9 +167,8 @@ GTEST_TEST(OsqpSolverTest, EqualityConstrainedQPDualSolution2) { TestEqualityConstrainedQPDualSolution2(solver); } -void AddTestProgram( - MathematicalProgram* prog, - const MatrixDecisionVariable<3, 1>& x) { +void AddTestProgram(MathematicalProgram* prog, + const MatrixDecisionVariable<3, 1>& x) { prog->AddLinearConstraint(x(0) + 2 * x(1) - 3 * x(2) <= 3); prog->AddLinearConstraint(4 * x(0) - 2 * x(1) - 6 * x(2) >= -3); prog->AddQuadraticCost(x(0) * x(0) + 2 * x(1) * x(1) + 5 * x(2) * x(2) + @@ -360,8 +359,8 @@ GTEST_TEST(OsqpSolverTest, WarmStartPrimalOnly) { const int half_iterations = result.get_solver_details().iter / 2; SolverOptions solver_options; - solver_options.SetOption( - osqp_solver.solver_id(), "max_iter", half_iterations); + solver_options.SetOption(osqp_solver.solver_id(), "max_iter", + half_iterations); const Eigen::VectorXd x_sol = result.get_x_val(); osqp_solver.Solve(prog, x_sol, solver_options, &result); EXPECT_EQ(result.get_solver_details().status_val, OSQP_SOLVED); diff --git a/solvers/test/semidefinite_relaxation_internal_test.cc b/solvers/test/semidefinite_relaxation_internal_test.cc index 3cc9131f24d7..a54ed060e4e7 100644 --- a/solvers/test/semidefinite_relaxation_internal_test.cc +++ b/solvers/test/semidefinite_relaxation_internal_test.cc @@ -496,7 +496,7 @@ TEST_F(MakeSemidefiniteRelaxationTestFixture, ReinitializeRelaxation(); DoAddImpliedLinearEqualityConstraints(prog_, X_, variables_to_sorted_indices_, - relaxation_.get()); + relaxation_.get()); EXPECT_EQ(relaxation_->num_vars(), 6); EXPECT_EQ(relaxation_->positive_semidefinite_constraints().size(), 1); diff --git a/solvers/test/snopt_solver_test.cc b/solvers/test/snopt_solver_test.cc index ab97f39d18f2..dc33c2fb30ba 100644 --- a/solvers/test/snopt_solver_test.cc +++ b/solvers/test/snopt_solver_test.cc @@ -387,11 +387,11 @@ GTEST_TEST(SnoptTest, MultiThreadTest) { *contents = std::regex_replace( *contents, std::regex(".Printer........................\\d"), "(Printer).............. ####"); + } + EXPECT_EQ(contents_single, contents_multi); } - EXPECT_EQ(contents_single, contents_multi); } } -} class AutoDiffOnlyCost final : public drake::solvers::Cost { public: