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+ }
0 commit comments