42# include <gtest/gtest.h>
57TEST(SimplexAllocation, AFailedPreparationStillTakesRestrictions)
60 GTEST_SKIP() <<
"ThreadSanitizer replaces the global operator new";
63 for (
size_t n = 1; n < 10000; ++n)
65 SCOPED_TRACE(
"the allocation " + std::to_string(n) +
" fails");
69 double sum[] = {1.0, 1.0, 4.0};
74 const Fail_At failing(n);
79 catch (
const std::bad_alloc &)
87 EXPECT_EQ(refused_allocations, 0u) <<
"no std::bad_alloc reached the caller";
92 double y[] = {0.0, 1.0, 3.0};
102 EXPECT_GT(failures, 0u);
Simplex algorithm for linear programming.
A global operator new that a test can make fail.
#define ALEPH_ALLOCATION_FAILURE_UNDER_TSAN
Linear program solver using the Simplex method.
T objetive_value() const noexcept
Computes and returns the objective function value.
T * put_restriction(const T *coefs=nullptr, ConstraintType type=ConstraintType::LE)
Adds a constraint to the linear program.
void prepare_linear_program()
Prepares the linear program for solving.
size_t get_num_restrictions() const noexcept
Gets the number of constraints.
const T & get_solution(size_t i) const noexcept
Gets the solution value for a specific variable.
void put_objetive_function_coef(size_t i, const T &coef)
Sets a coefficient in the objective function.
void load_solution() noexcept
Loads the solution values into the solution array.
State solve()
Solves the linear program.
Main namespace for Aleph-w library functions.
T sum(const Container &container, const T &init=T{})
Compute sum of all elements.