From 1b135f8fda91c47be88273ea4a87c90a92cf0e35 Mon Sep 17 00:00:00 2001 From: Alvin Zhang <41vin2h4n9@gmail.com> Date: Fri, 6 Dec 2024 14:35:45 -0800 Subject: [PATCH] fix: run formatter --- examples/derivatives/main.cpp | 2 +- examples/elevatorMPC/main.cpp | 2 +- include/suboptimal/NonlinearProblem.h | 6 ++++-- src/NonlinearProblem.cpp | 4 ++++ src/autodiff/Variable.cpp | 1 - src/solvers/linear/Simplex.cpp | 4 ++-- test/autodiff/GradientTest.cpp | 6 +++++- test/autodiff/HessianTest.cpp | 2 +- test/autodiff/JacobianTest.cpp | 2 +- test/solvers/linear/SimplexFailureTest.cpp | 2 +- test/solvers/linear/SimplexTest.cpp | 2 +- 11 files changed, 21 insertions(+), 12 deletions(-) diff --git a/examples/derivatives/main.cpp b/examples/derivatives/main.cpp index 7469610..15b5160 100644 --- a/examples/derivatives/main.cpp +++ b/examples/derivatives/main.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2024 Alvin Zhang. -#include #include +#include #include #include diff --git a/examples/elevatorMPC/main.cpp b/examples/elevatorMPC/main.cpp index 8522d42..222ccce 100644 --- a/examples/elevatorMPC/main.cpp +++ b/examples/elevatorMPC/main.cpp @@ -7,8 +7,8 @@ #include -#include "ElevatorMPC.h" #include "Dynamics.h" +#include "ElevatorMPC.h" int main() { using namespace std::chrono_literals; diff --git a/include/suboptimal/NonlinearProblem.h b/include/suboptimal/NonlinearProblem.h index 7500a2f..7c0e0be 100644 --- a/include/suboptimal/NonlinearProblem.h +++ b/include/suboptimal/NonlinearProblem.h @@ -1,8 +1,10 @@ +// Copyright (c) 2024 Alvin Zhang. + #pragma once #include -#include #include +#include #include "suboptimal/autodiff/Variable.h" @@ -79,7 +81,7 @@ class NonlinearProblem { * @param objective the function to maximize */ void maximize(Variable&& objective); - + /** * Adds a constraint to the optimization problem * @param constraint the constraint to add diff --git a/src/NonlinearProblem.cpp b/src/NonlinearProblem.cpp index eb207c7..ae7b6eb 100644 --- a/src/NonlinearProblem.cpp +++ b/src/NonlinearProblem.cpp @@ -1,5 +1,9 @@ +// Copyright (c) 2024 Alvin Zhang. + #include "suboptimal/NonlinearProblem.h" +#include + namespace suboptimal { NonlinearProblem::NonlinearProblem() = default; diff --git a/src/autodiff/Variable.cpp b/src/autodiff/Variable.cpp index c54a6ea..8ce677f 100644 --- a/src/autodiff/Variable.cpp +++ b/src/autodiff/Variable.cpp @@ -106,7 +106,6 @@ Variable asinh(const Variable& x) { Variable acosh(const Variable& x) { return acosh(x.expr); - } Variable atanh(const Variable& x) { diff --git a/src/solvers/linear/Simplex.cpp b/src/solvers/linear/Simplex.cpp index 54cf86f..3d4d880 100644 --- a/src/solvers/linear/Simplex.cpp +++ b/src/solvers/linear/Simplex.cpp @@ -14,10 +14,10 @@ #include "suboptimal/solvers/SolverExitStatus.h" #include "suboptimal/solvers/linear/SimplexPivotRule.h" #include "suboptimal/solvers/linear/SimplexSolverConfig.h" -#include "util/FinalAction.h" -#include "util/SolverProfiler.h" #include "util/Assert.h" #include "util/ComparisonUtil.h" +#include "util/FinalAction.h" +#include "util/SolverProfiler.h" using namespace Eigen; diff --git a/test/autodiff/GradientTest.cpp b/test/autodiff/GradientTest.cpp index 93c0ad2..1f61a4b 100644 --- a/test/autodiff/GradientTest.cpp +++ b/test/autodiff/GradientTest.cpp @@ -2,8 +2,8 @@ #define CATCH_CONFIG_FAST_COMPILE -#include #include +#include #include #include @@ -31,6 +31,10 @@ TEST_CASE("Autodiff - Basic gradient", "[autodiff]") { const Eigen::Vector2d grad_val{(x_val * x_val - y_val * y_val) / (5 * x_val * x_val), // (2 * y_val - 2 * x_val) / (5 * x_val)}; + + + std::cout << grad.getValue() << std::endl; + std::cout << grad_val << std::endl; CHECK(grad.getValue().isApprox(grad_val)); CHECK(suboptimal::getValues(grad.getExpr()).isApprox(grad_val)); } diff --git a/test/autodiff/HessianTest.cpp b/test/autodiff/HessianTest.cpp index 0ee62c8..c6bb14f 100644 --- a/test/autodiff/HessianTest.cpp +++ b/test/autodiff/HessianTest.cpp @@ -2,8 +2,8 @@ #define CATCH_CONFIG_FAST_COMPILE -#include #include +#include #include diff --git a/test/autodiff/JacobianTest.cpp b/test/autodiff/JacobianTest.cpp index 890c4e7..6904100 100644 --- a/test/autodiff/JacobianTest.cpp +++ b/test/autodiff/JacobianTest.cpp @@ -2,8 +2,8 @@ #define CATCH_CONFIG_FAST_COMPILE -#include #include +#include #include #include diff --git a/test/solvers/linear/SimplexFailureTest.cpp b/test/solvers/linear/SimplexFailureTest.cpp index 312e828..20e7643 100644 --- a/test/solvers/linear/SimplexFailureTest.cpp +++ b/test/solvers/linear/SimplexFailureTest.cpp @@ -4,9 +4,9 @@ #include #include +#include #include #include -#include #include diff --git a/test/solvers/linear/SimplexTest.cpp b/test/solvers/linear/SimplexTest.cpp index 2a78367..d33a7e3 100644 --- a/test/solvers/linear/SimplexTest.cpp +++ b/test/solvers/linear/SimplexTest.cpp @@ -4,9 +4,9 @@ #include #include +#include #include #include -#include #include #include