Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 9 additions & 40 deletions check/TestBasisSolves.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,6 @@

#include <algorithm>

#if defined(__linux__) or defined(__APPLE__)
#include <unistd.h>
#elif defined(_WIN32)
#define NOGDI
#define NOMINMAX
#include <windows.h>
#else

#endif

std::string GetBasisSolvesCurrentWorkingDir(void) {
char buff[FILENAME_MAX];

#if defined(__linux__) or defined(__APPLE__)
auto result = getcwd(buff, FILENAME_MAX);
if (result) {
std::string current_working_dir(buff);
return current_working_dir;
}
#elif defined(_WIN32)
GetModuleFileName( NULL, buff, FILENAME_MAX );
string::size_type pos = string( buff ).find_last_of( "\\/" );
return string( buff ).substr( 0, pos);
#else

#endif

return "";
}

bool GetBasisSolvesSolutionNzOk(int numRow, double* pass_solution_vector, int* solution_num_nz, int* solution_indices) {
double* solution_vector = (double*)malloc(sizeof(double) * numRow);
if (solution_num_nz == NULL) return true;
Expand Down Expand Up @@ -147,22 +117,21 @@ void GetBasisSolvesFormRHS(HighsLp& lp, int* basic_variables, double* solution,

// No commas in test case name.
TEST_CASE("Basis-solves", "[highs_basis_solves]") {

std::string dir = GetBasisSolvesCurrentWorkingDir();

std::cout << dir << std::endl;
std::cout << std::string(HIGHS_DIR) << std::endl;

// For debugging use the latter.
std::string filename;
filename = dir + "/../../check/instances/chip.mps";
// filename = dir + "/../../check/instances/blending.mps";
filename = dir + "/../../check/instances/avgas.mps";
filename = dir + "/../../check/instances/adlittle.mps";
// filename = dir + "/../../check/instances/25fv47.mps";
filename = std::string(HIGHS_DIR) + "/check/instances/chip.mps";
// filename = std::string(HIGHS_DIR) + "/../../check/instances/blending.mps";
filename = std::string(HIGHS_DIR) + "/check/instances/avgas.mps";
filename = std::string(HIGHS_DIR) + "/check/instances/adlittle.mps";

// printf("CMAKE %s\n", HIGHS_DIR);
// filename = std::string(HIGHS_DIR) + "/check/instances/25fv47.mps";

//For debugging

// filename = dir + "/check/instances/adlittle.mps";
// filename = std::string(HIGHS_DIR) + "/check/instances/adlittle.mps";

Highs highs;

Expand Down
49 changes: 6 additions & 43 deletions check/TestFilereader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,43 +9,12 @@
#include "LoadProblem.h"
#include "catch.hpp"

#if defined(__linux__) or defined(__APPLE__)
#include <unistd.h>
#elif defined(_WIN32)
#define NOGDI
#include <windows.h>
#else

#endif

std::string GetCurrentWorkingDir(void) {
char buff[FILENAME_MAX];

#if defined(__linux__) or defined(__APPLE__)
auto result = getcwd(buff, FILENAME_MAX);
if (result) {
std::string current_working_dir(buff);
return current_working_dir;
}
#elif defined(_WIN32)
GetModuleFileName( NULL, buff, FILENAME_MAX );
string::size_type pos = string( buff ).find_last_of( "\\/" );
return string( buff ).substr( 0, pos);
#else

#endif

return "";
}

TEST_CASE("free-format-parser", "[highs_filereader]") {
std::string dir = GetCurrentWorkingDir();

std::cout << dir << std::endl;
std::cout << std::string(HIGHS_DIR) << std::endl;

// For debugging use the latter.
std::string filename;
filename = dir + "/../../check/instances/adlittle.mps";
filename = std::string(HIGHS_DIR) + "/check/instances/adlittle.mps";
// filename = dir + "/check/instances/adlittle.mps";

// Read mps.
Expand Down Expand Up @@ -82,12 +51,11 @@ TEST_CASE("free-format-parser", "[highs_filereader]") {
// No commas in test case name.
TEST_CASE("read-mps-ems", "[highs_filereader]") {
HighsOptions options;
std::string dir = GetCurrentWorkingDir();

std::cout << dir << std::endl;
std::cout << std::string(HIGHS_DIR) << std::endl;

// For debugging use the latter.
options.model_file = dir + "/../../check/instances/adlittle.mps";
options.model_file = std::string(HIGHS_DIR) + "/check/instances/adlittle.mps";
// options.model_file = dir + "/check/instances/adlittle.mps";

// Read mps.
Expand All @@ -113,10 +81,8 @@ TEST_CASE("read-mps-ems", "[highs_filereader]") {
}

TEST_CASE("integrality-constraints", "[highs_filereader]") {
std::string dir = GetCurrentWorkingDir();

// For debugging use the latter.
std::string filename = dir + "/../../check/instances/small_mip.mps";
std::string filename = std::string(HIGHS_DIR) + "/check/instances/small_mip.mps";
// std::string filename = dir + "/check/instances/small_mip.mps";

HighsOptions options;
Expand Down Expand Up @@ -144,11 +110,8 @@ TEST_CASE("integrality-constraints", "[highs_filereader]") {
}

TEST_CASE("dualize", "[highs_data]") {

std::string dir = GetCurrentWorkingDir();

// For debugging use the latter.
std::string filename = dir + "/../../check/instances/adlittle.mps";
std::string filename = std::string(HIGHS_DIR) + "/check/instances/adlittle.mps";
//std::string filename = dir + "/check/instances/adlittle.mps";
//std::string filename = "/home/s1131817/test-problems/qaps/qap04";

Expand Down
33 changes: 1 addition & 32 deletions check/TestOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,44 +9,13 @@
#include "LoadOptions.h"
#include "catch.hpp"

#if defined(__linux__) or defined(__APPLE__)
#include <unistd.h>
#elif defined(_WIN32)
#define NOGDI
#include <windows.h>
#else

#endif

std::string GetCurrentWorkingDirOptions(void) {
char buff[FILENAME_MAX];

#if defined(__linux__) or defined(__APPLE__)
auto result = getcwd(buff, FILENAME_MAX);
if (result) {
std::string current_working_dir(buff);
return current_working_dir;
}
#elif defined(_WIN32)
GetModuleFileName( NULL, buff, FILENAME_MAX );
string::size_type pos = string( buff ).find_last_of( "\\/" );
return string( buff ).substr( 0, pos);
#else

#endif

return "";
}

TEST_CASE("options", "[highs_options]") {
std::string dir = GetCurrentWorkingDirOptions();

HighsOptions options;
OptionStatus return_status = checkOptions(options.records);
REQUIRE(return_status == OptionStatus::OK);

// For debugging use the latter.
options.options_file= dir + "/../../check/sample_options_file";
options.options_file= std::string(HIGHS_DIR) + "/check/sample_options_file";
// options.options_file = dir + "/check/sample_options_file";

bool success = loadOptionsFromFile(options);
Expand Down
1 change: 1 addition & 0 deletions src/HConfig.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@
#define HIGHS_VERSION_MAJOR @HIGHS_VERSION_MAJOR@
#define HIGHS_VERSION_MINOR @HIGHS_VERSION_MINOR@
#define HIGHS_VERSION_PATCH @HIGHS_VERSION_PATCH@
#define HIGHS_DIR "@CMAKE_SOURCE_DIR@"

#endif /* HCONFIG_H_ */