File: TestICrash.cpp

package info (click to toggle)
scipy 1.16.3-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 236,092 kB
  • sloc: cpp: 503,720; python: 345,302; ansic: 195,677; javascript: 89,566; fortran: 56,210; cs: 3,081; f90: 1,150; sh: 857; makefile: 792; pascal: 284; csh: 135; lisp: 134; xml: 56; perl: 51
file content (44 lines) | stat: -rw-r--r-- 1,241 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <cstdio>

#include "HCheckConfig.h"
#include "Highs.h"
#include "catch.hpp"
#include "lp_data/HighsLpUtils.h"
#include "util/HighsUtils.h"

const bool dev_run = false;
const double kOptimalQap04 = 32;

// No commas in test case name.
TEST_CASE("icrash-qap04", "[highs_presolve]") {
  std::string filename = std::string(HIGHS_DIR) + "/check/instances/qap04.mps";

  Highs highs;
  highs.setOptionValue("output_flag", dev_run);
  HighsStatus highs_status = highs.readModel(filename);
  REQUIRE(highs_status == HighsStatus::kOk);

  HighsOptions options;

  options.icrash = true;
  options.icrash_starting_weight = 10;
  options.icrash_approx_iter = 100;
  options.simplex_strategy = kSimplexStrategyPrimal;
  options.output_flag = dev_run;

  highs_status = highs.passOptions(options);
  REQUIRE(highs_status == HighsStatus::kOk);

  HighsStatus run_status = highs.run();
  REQUIRE(run_status == HighsStatus::kOk);

  ICrashInfo info = highs.getICrashInfo();

  // assert objective is close enough to the optimal one
  // c'x
  REQUIRE(std::fabs(info.final_lp_objective - kOptimalQap04) < 0.18);

  // assert residual is below threshold
  REQUIRE(info.final_residual_norm_2 >= -1e08);
  REQUIRE(info.final_residual_norm_2 < 1e08);
}