|
| 1 | +// #include "catch2/catch_test_macros.hpp" |
| 2 | +// #include "catch2/catch_approx.hpp" |
| 3 | +// #include "catch2/generators/catch_generators.hpp" |
| 4 | + |
| 5 | +#include <cassert> |
| 6 | +#include "coek/coek.hpp" |
| 7 | +#include "test/solver/TestModel.hpp" |
| 8 | + |
| 9 | +coek::Solver test_solver() |
| 10 | +{ |
| 11 | + coek::Solver solver("gurobi"); |
| 12 | + solver.set_option("OutputFlag", 0); |
| 13 | + return solver; |
| 14 | +} |
| 15 | + |
| 16 | +int main() |
| 17 | +{ |
| 18 | + // |
| 19 | + // Gurobi Checks |
| 20 | + // |
| 21 | + |
| 22 | + auto solver = test_solver(); |
| 23 | + if (solver.available()) { |
| 24 | + // SECTION("empty") |
| 25 | + { |
| 26 | + std::cout << "empty" << std::endl; |
| 27 | + auto solver = test_solver(); |
| 28 | + auto test = test::model("empty"); |
| 29 | + auto m = test->model; |
| 30 | + assert(m.name() == "empty"); |
| 31 | + auto res = solver.solve(m); |
| 32 | + assert(res->termination_condition == coek::TerminationCondition::empty_model); |
| 33 | + } |
| 34 | + // SECTION("rosenbr") |
| 35 | + { |
| 36 | + std::cout << "rosenbr" << std::endl; |
| 37 | + auto solver = test_solver(); |
| 38 | + auto test = test::model("rosenbr"); |
| 39 | + auto m = test->model; |
| 40 | + assert(m.name() == "rosenbr"); |
| 41 | + auto res = solver.solve(m); |
| 42 | + assert(res->termination_condition |
| 43 | + == coek::TerminationCondition::invalid_model_for_solver); |
| 44 | + } |
| 45 | + // SECTION("simplelp1") |
| 46 | + { |
| 47 | + std::cout << "simplelp1" << std::endl; |
| 48 | + auto solver = test_solver(); |
| 49 | + auto test = test::model("simplelp1"); |
| 50 | + auto m = test->model; |
| 51 | + assert(m.name() == "simplelp1"); |
| 52 | + auto res = solver.solve(m); |
| 53 | + assert(test->check_results(m, res) == true); |
| 54 | + } |
| 55 | + // SECTION("simpleqp1") |
| 56 | + { |
| 57 | + std::cout << "simpleqp1" << std::endl; |
| 58 | + auto solver = test_solver(); |
| 59 | + auto test = test::model("simpleqp1"); |
| 60 | + auto m = test->model; |
| 61 | + assert(m.name() == "simpleqp1"); |
| 62 | + auto res = solver.solve(m); |
| 63 | + assert(test->check_results(m, res) == true); |
| 64 | + } |
| 65 | + // SECTION("simpleqp2") |
| 66 | + { |
| 67 | + std::cout << "simpleqp2" << std::endl; |
| 68 | + auto solver = test_solver(); |
| 69 | + auto test = test::model("simpleqp2"); |
| 70 | + auto m = test->model; |
| 71 | + assert(m.name() == "simpleqp2"); |
| 72 | + auto res = solver.solve(m); |
| 73 | + assert(test->check_results(m, res) == true); |
| 74 | + } |
| 75 | + // SECTION("simpleqp3") |
| 76 | + { |
| 77 | + std::cout << "simpleqp3" << std::endl; |
| 78 | + auto solver = test_solver(); |
| 79 | + auto test = test::model("simpleqp3"); |
| 80 | + auto m = test->model; |
| 81 | + assert(m.name() == "simpleqp3"); |
| 82 | + auto res = solver.solve(m); |
| 83 | + assert(test->check_results(m, res) == true); |
| 84 | + } |
| 85 | + // SECTION("simpleqp4") |
| 86 | + { |
| 87 | + std::cout << "simpleqp4" << std::endl; |
| 88 | + auto solver = test_solver(); |
| 89 | + auto test = test::model("simpleqp4"); |
| 90 | + auto m = test->model; |
| 91 | + assert(m.name() == "simpleqp4"); |
| 92 | + auto res = solver.solve(m); |
| 93 | + assert(test->check_results(m, res) == true); |
| 94 | + } |
| 95 | + // SECTION("lp_bounds1") |
| 96 | + { |
| 97 | + std::cout << "lp_bounds" << std::endl; |
| 98 | + auto solver = test_solver(); |
| 99 | + auto test = test::model("lp_bounds1"); |
| 100 | + auto m = test->model; |
| 101 | + assert(m.name() == "lp_bounds1"); |
| 102 | + auto res = solver.solve(m); |
| 103 | + assert(test->check_results(m, res) == true); |
| 104 | + } |
| 105 | + // SECTION("lp_bounds2") |
| 106 | + { |
| 107 | + std::cout << "lp_bounds2" << std::endl; |
| 108 | + auto solver = test_solver(); |
| 109 | + auto test = test::model("lp_bounds2"); |
| 110 | + auto m = test->model; |
| 111 | + assert(m.name() == "lp_bounds2"); |
| 112 | + auto res = solver.solve(m); |
| 113 | + assert(test->check_results(m, res) == true); |
| 114 | + } |
| 115 | + // SECTION("qp_bounds") |
| 116 | + { |
| 117 | + std::cout << "qp_bounds" << std::endl; |
| 118 | + auto solver = test_solver(); |
| 119 | + auto test = test::model("qp_bounds"); |
| 120 | + auto m = test->model; |
| 121 | + assert(m.name() == "qp_bounds"); |
| 122 | + auto res = solver.solve(m); |
| 123 | + assert(test->check_results(m, res) == true); |
| 124 | + } |
| 125 | + } |
| 126 | + else { |
| 127 | + // SECTION("simplelp1") |
| 128 | + { |
| 129 | + std::cout << "simplelp1" << std::endl; |
| 130 | + auto solver = test_solver(); |
| 131 | + auto test = test::model("simplelp1"); |
| 132 | + auto m = test->model; |
| 133 | + assert(m.name() == "simplelp1"); |
| 134 | + auto res = solver.solve(m); |
| 135 | + assert((res->termination_condition == coek::TerminationCondition::solver_not_available) |
| 136 | + or (res->termination_condition == coek::TerminationCondition::license_problems)); |
| 137 | + } |
| 138 | + } |
| 139 | +} |
0 commit comments