Skip to content

Commit

Permalink
ENH: Use minimal exceptions
Browse files Browse the repository at this point in the history
No change in C-API, maps to existing errors
  • Loading branch information
HaoZeke committed Oct 21, 2023
1 parent 7264b18 commit 3a66980
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/Highs.h
Expand Up @@ -21,9 +21,9 @@
#include "lp_data/HighsRanging.h"
#include "lp_data/HighsSolutionDebug.h"
#include "model/HighsModel.h"
#include "util/HighsExceptions.h"
#include "presolve/ICrash.h"
#include "presolve/PresolveComponent.h"
#include "util/HighsExceptions.h"

/**
* @brief Return the version
Expand Down
16 changes: 12 additions & 4 deletions src/presolve/HPresolve.cpp
Expand Up @@ -3685,10 +3685,18 @@ HPresolve::Result HPresolve::rowPresolve(HighsPostsolveStack& postsolve_stack,
// assert(non_fractional);
if (!non_fractional) return Result::kPrimalInfeasible;
}
postsolve_stack.fixedColAtLower(nonzero.index(),
model->col_lower_[nonzero.index()],
model->col_cost_[nonzero.index()],
getColumnVector(nonzero.index()));
try {
postsolve_stack.fixedColAtLower(
nonzero.index(), model->col_lower_[nonzero.index()],
model->col_cost_[nonzero.index()],
getColumnVector(nonzero.index()));
} catch (const DataStackOverflow& e) {
highsLogUser(options->log_options, HighsLogType::kError,
"Problem too large for Presolve, try without\n");
highsLogUser(options->log_options, HighsLogType::kInfo,
"Specific error raised:\n%s\n", e.what());
return Result::kPrimalInfeasible;
}
if (model->col_upper_[nonzero.index()] >
model->col_lower_[nonzero.index()])
changeColUpper(nonzero.index(),
Expand Down
1 change: 1 addition & 0 deletions src/util/HighsDataStack.h
Expand Up @@ -52,6 +52,7 @@ class HighsDataStack {
}
std::memcpy(data.data() + dataSize, &r, sizeof(T));
}

template <typename T,
typename std::enable_if<IS_TRIVIALLY_COPYABLE(T), int>::type = 0>
void pop(T& r) {
Expand Down
6 changes: 3 additions & 3 deletions src/util/HighsExceptions.h
Expand Up @@ -2,7 +2,7 @@
#include <stdexcept>

class DataStackOverflow : public std::runtime_error {
public:
explicit DataStackOverflow(const std::string& msg)
: std::runtime_error(msg) {}
public:
explicit DataStackOverflow(const std::string& msg)
: std::runtime_error(msg) {}
};

0 comments on commit 3a66980

Please sign in to comment.