Skip to content

Commit 0f8af1c

Browse files
committed
Added Hipo tests and removed previous tests
1 parent a417d28 commit 0f8af1c

File tree

4 files changed

+75
-21
lines changed

4 files changed

+75
-21
lines changed

CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -808,9 +808,6 @@ else(FAST_BUILD)
808808
if(BUILD_CXX)
809809
add_subdirectory(app)
810810
add_subdirectory(examples)
811-
if (HIPO)
812-
add_subdirectory(highs/ipm/hipo)
813-
endif()
814811
endif()
815812

816813
if(BUILD_TESTING)

check/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ if ((NOT FAST_BUILD OR ALL_TESTS) AND NOT (BUILD_EXTRA_UNIT_ONLY))
4848
TestHighsRbTree.cpp
4949
TestHighsSparseMatrix.cpp
5050
TestHighsVersion.cpp
51+
TestHipo.cpp
5152
TestHSet.cpp
5253
TestICrash.cpp
5354
TestIis.cpp

check/TestHipo.cpp

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#include "HCheckConfig.h"
2+
#include "Highs.h"
3+
#include "catch.hpp"
4+
#include "io/Filereader.h"
5+
#include "ipm/hipo/ipm/Solver.h"
6+
#include "ipm/hipo/ipm/Status.h"
7+
#include "lp_data/HighsCallback.h"
8+
#include "parallel/HighsParallel.h"
9+
10+
// Example for using HiPO from its C++ interface. The program solves the Netlib
11+
// problem afiro.
12+
13+
#include <unistd.h>
14+
15+
#include <cmath>
16+
#include <iostream>
17+
#include <vector>
18+
19+
const bool dev_run = false;
20+
21+
TEST_CASE("test-hipo-afiro", "[highs_hipo]") {
22+
// Test that hipo runs and finds correct solution for afiro
23+
24+
std::string model = "afiro.mps";
25+
const double expected_obj = -464.753;
26+
27+
Highs highs;
28+
highs.setOptionValue("output_flag", dev_run);
29+
highs.setOptionValue("solver", kHipoString);
30+
highs.setOptionValue("timeless_log", kHighsOnString);
31+
32+
std::string filename = std::string(HIGHS_DIR) + "/check/instances/" + model;
33+
highs.readModel(filename);
34+
35+
HighsStatus status = highs.run();
36+
REQUIRE(status == HighsStatus::kOk);
37+
38+
const double actual_obj = highs.getObjectiveValue();
39+
REQUIRE(std::abs(actual_obj - expected_obj) < 0.001);
40+
41+
highs.resetGlobalScheduler(true);
42+
}
43+
44+
TEST_CASE("test-hipo-deterministic", "[highs_hipo]") {
45+
// Test that hipo finds the exact same solution if run twice
46+
47+
std::string model = "80bau3b.mps";
48+
49+
Highs highs;
50+
highs.setOptionValue("output_flag", dev_run);
51+
highs.setOptionValue(kSolverString, kHipoString);
52+
highs.setOptionValue(kParallelString, kHighsOnString);
53+
highs.setOptionValue(kRunCrossoverString, kHighsOffString);
54+
55+
std::string filename = std::string(HIGHS_DIR) + "/check/instances/" + model;
56+
highs.readModel(filename);
57+
58+
HighsStatus status = highs.run();
59+
REQUIRE(status == HighsStatus::kOk);
60+
61+
const HighsSolution solution_1 = highs.getSolution();
62+
63+
highs.run();
64+
const HighsSolution solution_2 = highs.getSolution();
65+
66+
REQUIRE(solution_1.value_valid == solution_2.value_valid);
67+
REQUIRE(solution_1.dual_valid == solution_2.dual_valid);
68+
REQUIRE(solution_1.col_value == solution_2.col_value);
69+
REQUIRE(solution_1.row_value == solution_2.row_value);
70+
REQUIRE(solution_1.col_dual == solution_2.col_dual);
71+
REQUIRE(solution_1.row_dual == solution_2.row_dual);
72+
73+
highs.resetGlobalScheduler(true);
74+
}

highs/ipm/hipo/CMakeLists.txt

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)