diff --git a/solvers/baronmp/baronmpcommon.cc b/solvers/baronmp/baronmpcommon.cc index 331e20c6e..f5f25da54 100644 --- a/solvers/baronmp/baronmpcommon.cc +++ b/solvers/baronmp/baronmpcommon.cc @@ -36,6 +36,7 @@ namespace mp { #ifdef WIN32 constexpr const char* EXENAME = "baronin.exe"; char SEP = '\\'; + volatile DWORD BaronmpCommon::pid; #else constexpr const char* EXENAME = "baronin"; char SEP = '/'; @@ -167,6 +168,20 @@ int BaronmpCommon::run(const std::vector& args) { return 0; } +std::filesystem::path resolveTilde(const std::filesystem::path& p) { + std::string pathStr = p.string(); + + // Check if the path starts with a tilde (~) + if (!pathStr.empty() && pathStr[0] == '~') { + const char* home = std::getenv("HOME"); // Get the HOME environment variable + if (home) { + // Replace tilde with the home directory + pathStr.replace(0, 1, home); + } + } + + return std::filesystem::path(pathStr); +} /** * Initialize baronDir and nlFilePath @@ -183,6 +198,9 @@ void BaronmpCommon::initDirectories(const std::string& stub, // Check if scratch directory is valid or create it if possible if (!scratch.empty()) { fs::path scratch_path(scratch); + #ifndef WIN32 + scratch_path = resolveTilde(scratch_path); + #endif if (overwrite) { if (fs::exists(scratch_path)) diff --git a/solvers/baronmp/baronmpcommon.h b/solvers/baronmp/baronmpcommon.h index f284be440..017686246 100644 --- a/solvers/baronmp/baronmpcommon.h +++ b/solvers/baronmp/baronmpcommon.h @@ -301,7 +301,7 @@ class BaronmpCommon : #ifndef WIN32 static volatile pid_t pid; #else - DWORD pid; + static volatile DWORD pid; #endif static constexpr double Infinity() { return INFINITY; } static constexpr double MinusInfinity() { return -INFINITY; } diff --git a/solvers/baronmp/baronmpmodelapi.cc b/solvers/baronmp/baronmpmodelapi.cc index 55b1fd882..68a854573 100644 --- a/solvers/baronmp/baronmpmodelapi.cc +++ b/solvers/baronmp/baronmpmodelapi.cc @@ -25,7 +25,7 @@ namespace mp { { if (vtypes[i] == VTYPE::BIN) continue; - if (lower && vtypes[i] == VTYPE::POS) + if (lower && bounds[i]==0 && vtypes[i] == VTYPE::POS) continue; if (bounds[i] != bnd) {