Skip to content

Commit

Permalink
chore: remove unused headers and and a few consts
Browse files Browse the repository at this point in the history
  • Loading branch information
mimizh2418 committed Nov 1, 2024
1 parent 2f98dce commit 6d1e0d6
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/LinearProblem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
using namespace suboptimal;
using namespace Eigen;

LinearProblem::LinearProblem(const VectorXd& objective_coeffs, bool is_minimization)
LinearProblem::LinearProblem(const VectorXd& objective_coeffs, const bool is_minimization)
: is_minimization(is_minimization),
objective_coeffs(is_minimization ? -objective_coeffs : objective_coeffs),
num_decision_vars(objective_coeffs.size()) {
Expand Down
1 change: 0 additions & 1 deletion src/solvers/linear/simplex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include <algorithm>
#include <iostream>
#include <limits>
#include <stdexcept>

#include <Eigen/Core>
#include <gsl/util>
Expand Down
7 changes: 4 additions & 3 deletions test/solvers/linear/simplex_fail_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include <catch2/catch_test_macros.hpp>
#include <catch2/generators/catch_generators.hpp>
#include <catch2/matchers/catch_matchers.hpp>
#include <catch2/matchers/catch_matchers_floating_point.hpp>

using namespace Eigen;
using namespace suboptimal;
Expand Down Expand Up @@ -45,7 +44,8 @@ TEST_CASE("Simplex failure mode - Degenerate cycling", "[simplex]") {
}

TEST_CASE("Simplex falure mode - Unbounded problem", "[simplex]") {
auto pivot_rule = GENERATE(SimplexPivotRule::kLexicographic, SimplexPivotRule::kDantzig, SimplexPivotRule::kBland);
const auto pivot_rule =
GENERATE(SimplexPivotRule::kLexicographic, SimplexPivotRule::kDantzig, SimplexPivotRule::kBland);

auto problem = LinearProblem::maximizationProblem(Vector3d{{0, 2, 1}});
problem.addLessThanConstraint(Vector3d{{1, -1, 1}}, 5);
Expand All @@ -62,7 +62,8 @@ TEST_CASE("Simplex falure mode - Unbounded problem", "[simplex]") {
}

TEST_CASE("Simplex failure mode - Infeasible problem", "[simplex]") {
auto pivot_rule = GENERATE(SimplexPivotRule::kLexicographic, SimplexPivotRule::kDantzig, SimplexPivotRule::kBland);
const auto pivot_rule =
GENERATE(SimplexPivotRule::kLexicographic, SimplexPivotRule::kDantzig, SimplexPivotRule::kBland);

auto problem = LinearProblem::maximizationProblem(Vector3d{{1, -1, 1}});
problem.addLessThanConstraint(Vector3d{{2, -1, -2}}, 4);
Expand Down
17 changes: 10 additions & 7 deletions test/solvers/linear/simplex_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ TEST_CASE("Simplex - Basic 1-phase maximization problem", "[simplex]") {
constexpr double expected_objective = 400;
const Vector2d expected_solution{{4, 8}};

auto pivot_rule = GENERATE(SimplexPivotRule::kLexicographic, SimplexPivotRule::kBland, SimplexPivotRule::kDantzig);
const auto pivot_rule =
GENERATE(SimplexPivotRule::kLexicographic, SimplexPivotRule::kBland, SimplexPivotRule::kDantzig);

auto problem = LinearProblem::maximizationProblem(Vector2d{{40, 30}});
problem.addLessThanConstraint(Vector2d{{1, 1}}, 12);
Expand All @@ -43,8 +44,9 @@ TEST_CASE("Simplex - Basic 1-phase minimization problem", "[simplex]") {
constexpr double expected_objective = -20;
const Vector3d expected_solution{{0, 0, 5}};

auto pivot_rule = GENERATE(SimplexPivotRule::kLexicographic, SimplexPivotRule::kBland, SimplexPivotRule::kDantzig);

const auto pivot_rule =
GENERATE(SimplexPivotRule::kLexicographic, SimplexPivotRule::kBland, SimplexPivotRule::kDantzig);

auto problem = LinearProblem::minimizationProblem(Vector3d{{-2, -3, -4}});
problem.addLessThanConstraint(Vector3d{{3, 2, 1}}, 10);
problem.addLessThanConstraint(Vector3d{{2, 5, 3}}, 15);
Expand All @@ -67,7 +69,7 @@ TEST_CASE("Simplex - Degenerate 1-phase problem", "[simplex]") {
constexpr double expected_objective = 0.5;
const Vector4d expected_solution{{0.5, 0, 0.5, 0}};

auto pivot_rule = GENERATE(SimplexPivotRule::kLexicographic, SimplexPivotRule::kBland);
const auto pivot_rule = GENERATE(SimplexPivotRule::kLexicographic, SimplexPivotRule::kBland);

auto problem = LinearProblem::maximizationProblem(Vector4d{{10, -57, -9, -24}});
problem.addLessThanConstraint(Vector4d{{0.5, -5.5, -2.5, 9}}, 0);
Expand All @@ -92,8 +94,9 @@ TEST_CASE("Simplex - Basic 2-phase problem", "[simplex]") {
constexpr double expected_objective = -130.0 / 7.0;
const Vector3d expected_solution{{15.0 / 7.0, 0.0, 25.0 / 7.0}};

auto pivot_rule = GENERATE(SimplexPivotRule::kLexicographic, SimplexPivotRule::kBland, SimplexPivotRule::kDantzig);

const auto pivot_rule =
GENERATE(SimplexPivotRule::kLexicographic, SimplexPivotRule::kBland, SimplexPivotRule::kDantzig);

auto problem = LinearProblem::minimizationProblem(Vector3d{{-2, -3, -4}});
problem.addEqualityConstraint(Vector3d{{3, 2, 1}}, 10);
problem.addEqualityConstraint(Vector3d{{2, 5, 3}}, 15);
Expand All @@ -116,7 +119,7 @@ TEST_CASE("Simplex - Degenerate 2-phase problem", "[simplex]") {
constexpr double expected_objective = 11;
const Vector4d expected_solution{{4, 0, 1, 2}};

auto pivot_rule = GENERATE(SimplexPivotRule::kLexicographic, SimplexPivotRule::kBland);
const auto pivot_rule = GENERATE(SimplexPivotRule::kLexicographic, SimplexPivotRule::kBland);

auto problem = LinearProblem::minimizationProblem(Vector4d{{2, 6, 1, 1}});
problem.addEqualityConstraint(Vector4d{{1, 2, 0, 1}}, 6);
Expand Down

0 comments on commit 6d1e0d6

Please sign in to comment.