Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Aleph::Simplex< T > Class Template Reference

Linear program solver using the Simplex method. More...

#include <Simplex.H>

Collaboration diagram for Aleph::Simplex< T >:
[legend]

Public Types

enum  State {
  Not_Solved , Solving , Unbounded , Solved ,
  Unfeasible
}
 Solution states for the linear program. More...
 
enum class  PivotRule { Dantzig , Bland }
 Pivot selection rule. More...
 

Public Member Functions

 Simplex (const size_t n, OptimizationType type=OptimizationType::Maximize)
 Constructs a Simplex solver for n variables.
 
 ~Simplex ()
 Destructor.
 
 Simplex (const Simplex &)=delete
 
Simplex & operator= (const Simplex &)=delete
 
 Simplex (Simplex &&other) noexcept
 Takes the program of another solver, which is left as an empty program, without variables nor restrictions.
 
Simplex & operator= (Simplex &&other) noexcept
 Exchanges this solver with another, which is left with the previous program of this one.
 
void swap (Simplex &other) noexcept
 Exchanges in O(1) this solver and another.
 
void set_optimization_type (OptimizationType type) noexcept
 Sets the optimization type.
 
void set_minimize () noexcept
 Sets minimization mode.
 
void set_maximize () noexcept
 Sets maximization mode.
 
void set_pivot_rule (PivotRule rule) noexcept
 Sets the pivot selection rule.
 
void enable_bland_rule () noexcept
 Enables Bland's anti-cycling rule.
 
void set_epsilon (T epsilon) noexcept
 Sets the floating-point comparison tolerance.
 
OptimizationType get_optimization_type () const noexcept
 Gets the current optimization type.
 
void put_objetive_function_coef (size_t i, const T &coef)
 Sets a coefficient in the objective function.
 
const T & get_objetive_function_coef (size_t i) const
 Gets a coefficient from the objective function.
 
void put_objetive_function (const DynArray< T > &coefs)
 Sets all objective function coefficients from a DynArray.
 
void put_objetive_function (const T coefs[])
 Sets all objective function coefficients from a C array.
 
T * put_restriction (const T *coefs=nullptr, ConstraintType type=ConstraintType::LE)
 Adds a constraint to the linear program.
 
T * put_ge_restriction (const T *coefs)
 Adds a ≥ constraint.
 
T * put_eq_restriction (const T *coefs)
 Adds an = constraint.
 
T * put_restriction (const DynArray< T > &coefs, ConstraintType type=ConstraintType::LE)
 Adds a constraint from a DynArray.
 
T * get_restriction (const size_t rest_num)
 Gets a pointer to a constraint array.
 
size_t get_num_restrictions () const noexcept
 Gets the number of constraints.
 
size_t get_num_vars () const noexcept
 Gets the number of decision variables.
 
T * get_objetive_function () noexcept
 Gets the objective function coefficients array.
 
const T * get_objetive_function () const noexcept
 Gets the objective function coefficients array (const).
 
T & get_restriction_coef (const size_t rest_num, size_t idx)
 Gets a specific coefficient from a constraint.
 
void put_restriction_coef (const size_t rest_num, const size_t idx, const T &coef)
 Sets a specific coefficient in a constraint.
 
void prepare_linear_program ()
 Prepares the linear program for solving.
 
State solve ()
 Solves the linear program.
 
State get_state () const noexcept
 Gets the current state of the solver.
 
void load_solution () noexcept
 Loads the solution values into the solution array.
 
const T & get_solution (size_t i) const noexcept
 Gets the solution value for a specific variable.
 
T objetive_value () const noexcept
 Computes and returns the objective function value.
 
bool verify_solution () const
 Verifies that the solution satisfies all constraints.
 
void print_matrix () const
 Prints the simplex tableau to stdout.
 
void latex_matrix (const std::string &name, const int d=2, const int p=-1, const int q=-1) const
 Exports the simplex tableau to a LaTeX file.
 
void latex_linear_program (const std::string &name) const
 Exports the linear program to a LaTeX file.
 
State latex_solve (const char *name=nullptr)
 Solves with LaTeX output at each iteration.
 
const SimplexStats & get_stats () const noexcept
 Gets execution statistics.
 
size_t get_iteration_count () const noexcept
 Gets the number of iterations performed.
 
size_t get_pivot_count () const noexcept
 Gets the number of pivot operations.
 
size_t get_degenerate_pivot_count () const noexcept
 Gets the number of degenerate pivots.
 
double get_elapsed_time_ms () const noexcept
 Gets the elapsed solving time.
 
SensitivityRange< T > objective_sensitivity (size_t var_idx) const
 Computes sensitivity range for an objective coefficient.
 
SensitivityRange< T > rhs_sensitivity (size_t rest_idx) const
 Computes sensitivity range for a RHS value.
 
T shadow_price (size_t rest_idx) const
 Gets the shadow price (dual value) for a constraint.
 
T reduced_cost (size_t var_idx) const
 Gets the reduced cost for a variable.
 
bool is_basic_variable (size_t var_idx) const
 Checks if a variable is basic in the optimal solution.
 
std::vector< T > get_all_shadow_prices () const
 Gets all shadow prices as a vector.
 
std::vector< T > get_all_reduced_costs () const
 Gets all reduced costs as a vector.
 
State dual_solve ()
 Performs dual simplex iteration.
 
State update_rhs_and_reoptimize (size_t rest_idx, T new_rhs)
 Updates RHS value and re-optimizes using dual simplex.
 
void print_stats () const
 Prints a summary of statistics to stdout.
 
void print_sensitivity_analysis () const
 Prints sensitivity analysis to stdout.
 

Private Member Functions

size_t first_artificial () const noexcept
 
size_t rhs_col () const noexcept
 
bool is_artificial (const size_t j) const noexcept
 
bool bland_now () const noexcept
 
bool same_ratio (const T &a, const T &b) const noexcept
 
int compute_pivot_col (const T &tol) const noexcept
 
int compute_pivot_row (const size_t q) const noexcept
 
void to_pivot (size_t p, size_t q)
 
template<class Hook >
State iterate (const T &cost_tol, Hook &hook)
 
void load_phase1_costs ()
 
void load_phase2_costs ()
 
template<class Hook >
void drive_out_artificials (Hook &hook)
 
template<class Hook >
State run (Hook &hook)
 
void verify_var_index (const size_t i) const
 
void verify_rest_index (const size_t i) const
 
T * create_restriction (ConstraintType type=ConstraintType::LE)
 
void create_matrix ()
 
T * restriction (const size_t rest_idx) const
 
 Simplex () noexcept
 

Static Private Member Functions

static std::string format_entry (const T &value, const int d)
 
static T * allocate (const size_t n, const size_t spare=0)
 
static T scale_of (const T &magnitude) noexcept
 

Private Attributes

std::unique_ptr< DynMatrix< T > > m
 
std::unique_ptr< T[]> objetive
 
DynDlist< T * > rest_list
 
DynDlist< ConstraintType > rest_types
 
size_t num_var
 
size_t num_rest
 
size_t num_artificial
 
std::unique_ptr< T[]> solution
 
State state
 
OptimizationType opt_type
 
PivotRule pivot_rule
 
T eps
 
SimplexStats stats
 
std::vector< T > pivot_row_buffer
 
std::vector< T > pivot_col_buffer
 
std::vector< int > basic_vars
 
std::vector< int > row_sign
 
std::vector< size_t > unit_col
 
std::vector< T > phase2_cost
 
std::vector< T > row_scale
 
std::vector< T > col_scale
 
T obj_scale = T{1}
 
T tol_coef = T{0}
 
T tol_rhs = T{0}
 
T tol_cost = T{0}
 
size_t degenerate_run = 0
 
std::vector< T > tie_cost
 
bool in_phase1 = false
 

Detailed Description

template<typename T>
class Aleph::Simplex< T >

Linear program solver using the Simplex method.

Simplex<T> allows expressing linear programs in standard or non-standard forms, supporting both maximization and minimization, as well as ≤, ≥, and = constraints directly.

Standard Form

The standard form of a linear program is:

Maximize: Z = c₁x₁ + c₂x₂ + ... + cₙxₙ
Subject to: a₁₁x₁ + a₁₂x₂ + ... + a₁ₙxₙ ≤ b₁
a₂₁x₁ + a₂₂x₂ + ... + a₂ₙxₙ ≤ b₂
...
aₘ₁x₁ + aₘ₂x₂ + ... + aₘₙxₙ ≤ bₘ
x₁, x₂, ..., xₙ ≥ 0
@ Maximize
Larger objective values are better.

Non-Standard Constraints (Automatic Handling)

This implementation handles non-standard forms directly:

  1. Minimization: Use set_minimize() instead of negating coefficients
  2. ≥ constraints: Use put_restriction(coefs, ConstraintType::GE)
  3. **= constraints**: Use put_restriction(coefs, ConstraintType::EQ)
  4. Negative right-hand sides: allowed in any constraint
  5. Unrestricted variables: Replace xᵢ with (xᵢ⁺ - xᵢ⁻) where both ≥ 0

Method

prepare_linear_program() builds the tableau. A constraint whose right-hand side is negative is multiplied by -1, which swaps ≤ and ≥, so that every right-hand side is >= 0. A ≤ constraint gets a slack variable, a ≥ one a surplus variable and an artificial one, and an = one an artificial one.

solve() runs two phases. The first one minimizes the sum of the artificial variables: if it stays above zero, the problem is infeasible. Else the artificial variables that are still basic, at zero, leave the basis, but for those of constraints that are combinations of others, and the second phase optimizes the objective from that basis. An artificial variable never enters the basis again. The basic variable of each row is kept, and the solution is read from it.

With Dantzig's rule, a run of degenerate pivots switches to Bland's rule until a pivot improves the objective, so that the method always ends.

prepare_linear_program() scales the program: each constraint, each column and the objective are multiplied by a power of two, which changes no digit, so that their largest magnitudes are in [1/2, 1); one whose largest magnitude is subnormal stays as it is, below the tolerances. The solver works on the scaled program, so that its tolerances do not depend on the units of the data, and scales its results back: the solution, the shadow prices, the reduced costs and the ranges are those of the program as it was given. A value of the scaled program is taken as zero when its magnitude is below the tolerance of set_epsilon(); a right-hand side, when it is below that tolerance times the largest magnitude of the right-hand sides, if this one is above 1.

Complete Example: Production Planning Problem

A factory produces two products (A and B) with limited resources:

  • Product A: profit $40/unit, needs 1 hr labor, 2 hrs machine time
  • Product B: profit $30/unit, needs 1 hr labor, 1 hr machine time
  • Available: 40 labor hours, 60 machine hours per day

Mathematical formulation:

Maximize: Z = 40·xₐ + 30·xᵦ (daily profit)
Subject to: xₐ + xᵦ ≤ 40 (labor constraint)
2·xₐ + xᵦ ≤ 60 (machine constraint)
xₐ, xᵦ ≥ 0 (non-negativity)

Code:

#include <Simplex.H>
#include <iostream>
int main() {
using namespace Aleph;
// Create solver with 2 decision variables
Simplex<double> solver(2);
// Set objective function: maximize 40*x_A + 30*x_B
solver.put_objetive_function_coef(0, 40.0); // x_A coefficient
solver.put_objetive_function_coef(1, 30.0); // x_B coefficient
// Add constraints (format: {coef_xA, coef_xB, RHS})
double labor[] = {1.0, 1.0, 40.0}; // x_A + x_B <= 40
double machine[] = {2.0, 1.0, 60.0}; // 2*x_A + x_B <= 60
solver.put_restriction(labor);
solver.put_restriction(machine);
// Prepare tableau and solve
solver.prepare_linear_program();
auto state = solver.solve();
solver.load_solution();
std::cout << "Optimal solution found!\n";
std::cout << "Product A: " << solver.get_solution(0) << " units\n";
std::cout << "Product B: " << solver.get_solution(1) << " units\n";
std::cout << "Maximum profit: $" << solver.objetive_value() << "\n";
if (solver.verify_solution())
std::cout << "Solution verified: all constraints satisfied.\n";
}
std::cout << "Problem is unbounded (check constraints).\n";
}
std::cout << "No point satisfies all the constraints.\n";
}
return 0;
}
// Output:
// Optimal solution found!
// Product A: 20 units
// Product B: 20 units
// Maximum profit: $1400
// Solution verified: all constraints satisfied.
Simplex algorithm for linear programming.
int main()
Linear program solver using the Simplex method.
Definition Simplex.H:279
Main namespace for Aleph-w library functions.

Algorithm Complexity

  • Time: O(2ⁿ) worst case, but typically polynomial in practice
  • Space: O((m+1) × (n+m+a+1)) for the tableau matrix, where a is the number of artificial variables

Where n = number of variables, m = number of constraints.

Template Parameters
TNumeric type for coefficients and values (typically double).
See also
DynMatrix

Definition at line 278 of file Simplex.H.

Member Enumeration Documentation

◆ PivotRule

template<typename T >
enum class Aleph::Simplex::PivotRule
strong

Pivot selection rule.

  • Dantzig: Most negative reduced cost; a run of degenerate pivots switches to Bland's rule until a pivot improves the objective.
  • Bland: Least index (guaranteed termination, slower).
Enumerator
Dantzig 
Bland 

Definition at line 298 of file Simplex.H.

◆ State

template<typename T >
enum Aleph::Simplex::State

Solution states for the linear program.

  • Not_Solved: Initial state, solve() has not been called yet.
  • Solving: Algorithm is in progress (internal state).
  • Unbounded: The objective improves without limit over the feasible points.
  • Solved: An optimal solution has been found.
  • Unfeasible: No point satisfies all the constraints.
Enumerator
Not_Solved 
Solving 
Unbounded 
Solved 
Unfeasible 

Definition at line 290 of file Simplex.H.

Constructor & Destructor Documentation

◆ Simplex() [1/4]

template<typename T >
Aleph::Simplex< T >::Simplex ( )
inlineprivatenoexcept

Definition at line 875 of file Simplex.H.

◆ Simplex() [2/4]

template<typename T >
Aleph::Simplex< T >::Simplex ( const size_t  n,
OptimizationType  type = OptimizationType::Maximize 
)
inlineexplicit

Constructs a Simplex solver for n variables.

Initializes a linear program in standard form without constraints and with all objective function coefficients set to zero.

Parameters
[in]nNumber of decision variables in the system.
[in]typeOptimization type: Maximize (default) or Minimize.
Exceptions
std::overflow_errorIf the bytes of a restriction of n variables, n + 1 coefficients, do not fit in a size_t.
std::bad_allocIf memory allocation fails.
std::invalid_argumentIf n is zero.

Definition at line 895 of file Simplex.H.

References ah_invalid_argument_if.

◆ ~Simplex()

template<typename T >
Aleph::Simplex< T >::~Simplex ( )
inline

Destructor.

Frees all allocated restriction arrays.

Definition at line 914 of file Simplex.H.

◆ Simplex() [3/4]

template<typename T >
Aleph::Simplex< T >::Simplex ( const Simplex< T > &  )
delete

◆ Simplex() [4/4]

template<typename T >
Aleph::Simplex< T >::Simplex ( Simplex< T > &&  other)
inlinenoexcept

Takes the program of another solver, which is left as an empty program, without variables nor restrictions.

The defaulted move took the arrays and the lists but copied their sizes: the moved-from solver then passed its index checks and wrote through arrays that it no longer had.

Parameters
[in,out]othersolver to move from.

Definition at line 933 of file Simplex.H.

References Aleph::swap().

Member Function Documentation

◆ allocate()

template<typename T >
static T * Aleph::Simplex< T >::allocate ( const size_t  n,
const size_t  spare = 0 
)
inlinestaticprivate

Definition at line 698 of file Simplex.H.

References ah_overflow_error_if.

◆ bland_now()

◆ compute_pivot_col()

template<typename T >
int Aleph::Simplex< T >::compute_pivot_col ( const T &  tol) const
inlineprivatenoexcept

◆ compute_pivot_row()

◆ create_matrix()

template<typename T >
void Aleph::Simplex< T >::create_matrix ( )
inlineprivate

Definition at line 737 of file Simplex.H.

References Aleph::EQ, Aleph::GE, Aleph::LE, m, Aleph::Maximize, and row.

◆ create_restriction()

template<typename T >
T * Aleph::Simplex< T >::create_restriction ( ConstraintType  type = ConstraintType::LE)
inlineprivate

Definition at line 708 of file Simplex.H.

References ah_logic_error_if, Aleph::allocate(), and m.

◆ drive_out_artificials()

◆ dual_solve()

template<typename T >
State Aleph::Simplex< T >::dual_solve ( )
inline

Performs dual simplex iteration.

Used for re-optimization when the RHS values change. The current basis must be optimal for the objective (no cost of row 0 below zero), as after solve(); each iteration takes out of the basis a variable whose value is negative. An artificial variable never enters the basis, and one that stays basic, of a constraint that is a combination of others, must stay at zero.

Returns
New solution state after re-optimization: Solved, or Unfeasible if no point satisfies the constraints.
Precondition
solve() must have been called and returned Solved.
Exceptions
std::logic_errorIf the problem is not solved.

Definition at line 1921 of file Simplex.H.

References ah_logic_error_if, Aleph::and, and m.

Referenced by TEST(), and TEST().

◆ enable_bland_rule()

template<typename T >
void Aleph::Simplex< T >::enable_bland_rule ( )
inlinenoexcept

Enables Bland's anti-cycling rule.

Use this when dealing with potentially degenerate problems.

Definition at line 1032 of file Simplex.H.

Referenced by TEST(), TEST(), TEST_F(), and TEST_F().

◆ first_artificial()

template<typename T >
size_t Aleph::Simplex< T >::first_artificial ( ) const
inlineprivatenoexcept

◆ format_entry()

template<typename T >
static std::string Aleph::Simplex< T >::format_entry ( const T &  value,
const int  d 
)
inlinestaticprivate

Definition at line 672 of file Simplex.H.

References value.

◆ get_all_reduced_costs()

template<typename T >
std::vector< T > Aleph::Simplex< T >::get_all_reduced_costs ( ) const
inline

Gets all reduced costs as a vector.

Returns
Vector of reduced costs for all variables.
Precondition
solve() must have been called and returned Solved.

Definition at line 1895 of file Simplex.H.

References ah_logic_error_if, and Aleph::reduced_cost().

Referenced by TEST_F().

◆ get_all_shadow_prices()

template<typename T >
std::vector< T > Aleph::Simplex< T >::get_all_shadow_prices ( ) const
inline

Gets all shadow prices as a vector.

Returns
Vector of shadow prices for all constraints.
Precondition
solve() must have been called and returned Solved.

Definition at line 1880 of file Simplex.H.

References ah_logic_error_if.

Referenced by TEST_F().

◆ get_degenerate_pivot_count()

template<typename T >
size_t Aleph::Simplex< T >::get_degenerate_pivot_count ( ) const
inlinenoexcept

Gets the number of degenerate pivots.

A degenerate pivot is one that doesn't improve the objective.

Returns
Number of degenerate pivots in the last solve.

Definition at line 1647 of file Simplex.H.

Referenced by TEST().

◆ get_elapsed_time_ms()

template<typename T >
double Aleph::Simplex< T >::get_elapsed_time_ms ( ) const
inlinenoexcept

Gets the elapsed solving time.

Returns
Elapsed time in milliseconds.

Definition at line 1656 of file Simplex.H.

Referenced by TEST().

◆ get_iteration_count()

template<typename T >
size_t Aleph::Simplex< T >::get_iteration_count ( ) const
inlinenoexcept

Gets the number of iterations performed.

Returns
Number of simplex iterations in the last solve.

Definition at line 1627 of file Simplex.H.

Referenced by TEST().

◆ get_num_restrictions()

template<typename T >
size_t Aleph::Simplex< T >::get_num_restrictions ( ) const
inlinenoexcept

Gets the number of constraints.

Returns
Number of constraints added to the linear program.

Definition at line 1216 of file Simplex.H.

Referenced by Moved_From_Case< Simplex< double > >::is_empty(), TEST(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), and Moved_From_Case< Simplex< double > >::use().

◆ get_num_vars()

template<typename T >
size_t Aleph::Simplex< T >::get_num_vars ( ) const
inlinenoexcept

◆ get_objetive_function() [1/2]

template<typename T >
const T * Aleph::Simplex< T >::get_objetive_function ( ) const
inlinenoexcept

Gets the objective function coefficients array (const).

Returns
Const pointer to the objective function coefficients.

Definition at line 1243 of file Simplex.H.

◆ get_objetive_function() [2/2]

template<typename T >
T * Aleph::Simplex< T >::get_objetive_function ( )
inlinenoexcept

Gets the objective function coefficients array.

Returns
Pointer to the objective function coefficients.

Definition at line 1234 of file Simplex.H.

Referenced by TEST_F().

◆ get_objetive_function_coef()

template<typename T >
const T & Aleph::Simplex< T >::get_objetive_function_coef ( size_t  i) const
inline

Gets a coefficient from the objective function.

Parameters
[in]iVariable index (0-based).
Returns
The coefficient value.
Exceptions
std::out_of_rangeIf i >= number of variables.

Definition at line 1085 of file Simplex.H.

Referenced by TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), and Moved_From_Case< Simplex< double > >::use().

◆ get_optimization_type()

template<typename T >
OptimizationType Aleph::Simplex< T >::get_optimization_type ( ) const
inlinenoexcept

Gets the current optimization type.

Returns
Maximize or Minimize.

Definition at line 1058 of file Simplex.H.

Referenced by TEST(), TEST_F(), TEST_F(), and TEST_F().

◆ get_pivot_count()

template<typename T >
size_t Aleph::Simplex< T >::get_pivot_count ( ) const
inlinenoexcept

Gets the number of pivot operations.

Returns
Number of pivots performed in the last solve.

Definition at line 1636 of file Simplex.H.

Referenced by TEST(), and TEST().

◆ get_restriction()

template<typename T >
T * Aleph::Simplex< T >::get_restriction ( const size_t  rest_num)
inline

Gets a pointer to a constraint array.

Parameters
[in]rest_numConstraint index (0-based).
Returns
Pointer to the constraint coefficients array.
Exceptions
std::out_of_rangeIf rest_num >= number of constraints.

Definition at line 1206 of file Simplex.H.

Referenced by TEST_F(), TEST_F(), and TEST_F().

◆ get_restriction_coef()

template<typename T >
T & Aleph::Simplex< T >::get_restriction_coef ( const size_t  rest_num,
size_t  idx 
)
inline

Gets a specific coefficient from a constraint.

Parameters
[in]rest_numConstraint index.
[in]idxVariable index within the constraint.
Returns
Reference to the coefficient.
Exceptions
std::out_of_rangeIf indices are out of range.

Definition at line 1256 of file Simplex.H.

Referenced by TEST_F(), TEST_F(), TEST_F(), and Moved_From_Case< Simplex< double > >::use().

◆ get_solution()

template<typename T >
const T & Aleph::Simplex< T >::get_solution ( size_t  i) const
inlinenoexcept

Gets the solution value for a specific variable.

Parameters
[in]iVariable index (0-based).
Returns
The optimal value of variable x_i.
Precondition
load_solution() must have been called first.
Note
Does not validate index for performance. Use with valid indices.

Definition at line 1360 of file Simplex.H.

Referenced by demo_algorithm_steps(), demo_diet_problem(), demo_production_planning(), demo_resource_allocation(), Aleph::MCF_LP_Solver< Net >::solve(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), and TEST_F().

◆ get_state()

template<typename T >
State Aleph::Simplex< T >::get_state ( ) const
inlinenoexcept

Gets the current state of the solver.

Returns
Current solution state.

Definition at line 1324 of file Simplex.H.

Referenced by Moved_From_Case< Simplex< double > >::is_empty(), TEST(), TEST_F(), TEST_F(), and Moved_From_Case< Simplex< double > >::use().

◆ get_stats()

template<typename T >
const SimplexStats & Aleph::Simplex< T >::get_stats ( ) const
inlinenoexcept

Gets execution statistics.

Returns statistics about the most recent solve() call.

Returns
Const reference to SimplexStats structure.

Definition at line 1618 of file Simplex.H.

Referenced by Aleph::MCF_LP_Solver< Net >::solve(), TEST(), TEST(), TEST_F(), TEST_F(), and TEST_F().

◆ is_artificial()

template<typename T >
bool Aleph::Simplex< T >::is_artificial ( const size_t  j) const
inlineprivatenoexcept

◆ is_basic_variable()

template<typename T >
bool Aleph::Simplex< T >::is_basic_variable ( size_t  var_idx) const
inline

Checks if a variable is basic in the optimal solution.

Parameters
[in]var_idxVariable index (0-based).
Returns
true if variable is in the basis, false otherwise.
Precondition
solve() must have been called and returned Solved.

Definition at line 1865 of file Simplex.H.

Referenced by TEST(), TEST(), TEST_F(), and TEST_F().

◆ iterate()

◆ latex_linear_program()

template<typename T >
void Aleph::Simplex< T >::latex_linear_program ( const std::string &  name) const
inline

Exports the linear program to a LaTeX file.

Generates a LaTeX representation of the objective function and all constraints.

Parameters
[in]nameOutput file name.

Definition at line 1508 of file Simplex.H.

References Aleph::EQ, Aleph::GE, Aleph::LE, Aleph::Maximize, and out.

Referenced by TEST().

◆ latex_matrix()

template<typename T >
void Aleph::Simplex< T >::latex_matrix ( const std::string &  name,
const int  d = 2,
const int  p = -1,
const int  q = -1 
) const
inline

Exports the simplex tableau to a LaTeX file.

Parameters
[in]nameOutput file name.
[in]dNumber of decimal places (default 2).
[in]pPivot row to highlight (-1 for none).
[in]qPivot column to highlight (-1 for none).
Exceptions
std::logic_errorIf prepare_linear_program() was not called.

Definition at line 1467 of file Simplex.H.

References ah_logic_error_if, Aleph::and, cols, m, and out.

Referenced by TEST().

◆ latex_solve()

template<typename T >
State Aleph::Simplex< T >::latex_solve ( const char *  name = nullptr)
inline

Solves with LaTeX output at each iteration.

As solve(), but it writes the tableau to LaTeX files for educational purposes: name-0.tex before the first phase, name-k.tex with the pivot of the pivot k circled, name-k-after.tex after it, and name-k.tex, for the next k, at the end.

Parameters
[in]nameBase name for output files.
Returns
Solution state.
Exceptions
std::logic_errorAs solve().

Definition at line 1586 of file Simplex.H.

References ah_logic_error_if, k, and m.

Referenced by TEST(), and TEST().

◆ load_phase1_costs()

◆ load_phase2_costs()

template<typename T >
void Aleph::Simplex< T >::load_phase2_costs ( )
inlineprivate

◆ load_solution()

template<typename T >
void Aleph::Simplex< T >::load_solution ( )
inlinenoexcept

Loads the solution values into the solution array.

Each decision variable takes the value of its row if it is basic, and zero if not. After solve() returns Solved, it is an optimal solution; after Unbounded, the vertex from which the objective improves without limit. After this, individual variable values can be retrieved with get_solution().

Definition at line 1337 of file Simplex.H.

References m.

Referenced by demo_algorithm_steps(), demo_diet_problem(), demo_production_planning(), demo_resource_allocation(), demo_special_cases(), Aleph::MCF_LP_Solver< Net >::solve(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), and Moved_From_Case< Simplex< double > >::use().

◆ objective_sensitivity()

template<typename T >
SensitivityRange< T > Aleph::Simplex< T >::objective_sensitivity ( size_t  var_idx) const
inline

Computes sensitivity range for an objective coefficient.

Determines the range [lower, upper] within which the objective coefficient c_j can vary, the others fixed, while the optimal basis stays optimal, and so the solution too.

Parameters
[in]var_idxVariable index (0-based).
Returns
SensitivityRange structure with bounds and current value; an infinite bound means no limit.
Precondition
solve() must have been called and returned Solved.
Exceptions
std::out_of_rangeIf var_idx is out of range.
std::logic_errorIf not solved yet.

Definition at line 1677 of file Simplex.H.

References ah_logic_error_if, Aleph::SensitivityRange< T >::current_value, k, Aleph::SensitivityRange< T >::lower_bound, m, Aleph::Maximize, row, and Aleph::SensitivityRange< T >::upper_bound.

Referenced by TEST(), TEST(), TEST(), and TEST_F().

◆ objetive_value()

template<typename T >
T Aleph::Simplex< T >::objetive_value ( ) const
inlinenoexcept

Computes and returns the objective function value.

Calculates Z = sum(c_i * x_i) using the current solution.

Returns
The optimal value of the objective function.
Precondition
load_solution() must have been called first.

Definition at line 1374 of file Simplex.H.

References Aleph::sum().

Referenced by demo_algorithm_steps(), demo_diet_problem(), demo_production_planning(), demo_resource_allocation(), demo_special_cases(), Aleph::MCF_LP_Solver< Net >::solve(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), and TEST_F().

◆ operator=() [1/2]

template<typename T >
Simplex & Aleph::Simplex< T >::operator= ( const Simplex< T > &  )
delete

◆ operator=() [2/2]

template<typename T >
Simplex & Aleph::Simplex< T >::operator= ( Simplex< T > &&  other)
inlinenoexcept

Exchanges this solver with another, which is left with the previous program of this one.

Parameters
[in,out]othersolver to move from.
Returns
this solver.

Definition at line 944 of file Simplex.H.

References Aleph::swap().

◆ prepare_linear_program()

template<typename T >
void Aleph::Simplex< T >::prepare_linear_program ( )
inline

Prepares the linear program for solving.

Must be called after all objective function coefficients and constraints have been set, and before calling solve().

Creates the internal simplex tableau matrix, with the slack, surplus and artificial variables, after multiplying by -1 each constraint whose right-hand side is negative.

Exceptions
std::bad_allocIf memory allocation fails.
std::logic_errorIf no constraints have been added.

Definition at line 1287 of file Simplex.H.

References ah_logic_error_if.

Referenced by demo_algorithm_steps(), demo_diet_problem(), demo_production_planning(), demo_resource_allocation(), demo_special_cases(), Aleph::MCF_LP_Solver< Net >::solve(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), and Moved_From_Case< Simplex< double > >::use().

◆ print_matrix()

template<typename T >
void Aleph::Simplex< T >::print_matrix ( ) const
inline

Prints the simplex tableau to stdout.

It is the tableau of the scaled program that the solver works on (see the class documentation). Row 0 holds the costs that the current phase minimizes, and the last column the right-hand sides. Useful for debugging and understanding the algorithm's progress.

Exceptions
std::logic_errorIf prepare_linear_program() was not called.

Definition at line 1445 of file Simplex.H.

References ah_logic_error_if, and m.

Referenced by TEST().

◆ print_sensitivity_analysis()

template<typename T >
void Aleph::Simplex< T >::print_sensitivity_analysis ( ) const
inline

Prints sensitivity analysis to stdout.

Precondition
solve() must have been called and returned Solved.

Definition at line 2076 of file Simplex.H.

References ah_logic_error_if, Aleph::range(), and Aleph::reduced_cost().

Referenced by TEST(), and TEST().

◆ print_stats()

template<typename T >
void Aleph::Simplex< T >::print_stats ( ) const
inline

Prints a summary of statistics to stdout.

Definition at line 2062 of file Simplex.H.

Referenced by TEST().

◆ put_eq_restriction()

template<typename T >
T * Aleph::Simplex< T >::put_eq_restriction ( const T *  coefs)
inline

Adds an = constraint.

Convenience method for adding equality constraints.

Parameters
[in]coefsArray of n+1 coefficients.
Returns
Pointer to the internal constraint array.
Exceptions
std::bad_allocIf memory allocation fails.
std::logic_errorIf prepare_linear_program() already built the tableau, as put_restriction() explains.

Definition at line 1173 of file Simplex.H.

References Aleph::EQ.

Referenced by Aleph::MCF_LP_Solver< Net >::solve(), TEST(), and TEST_F().

◆ put_ge_restriction()

template<typename T >
T * Aleph::Simplex< T >::put_ge_restriction ( const T *  coefs)
inline

Adds a ≥ constraint.

Convenience method for adding greater-than-or-equal constraints.

Parameters
[in]coefsArray of n+1 coefficients.
Returns
Pointer to the internal constraint array.
Exceptions
std::bad_allocIf memory allocation fails.
std::logic_errorIf prepare_linear_program() already built the tableau, as put_restriction() explains.

Definition at line 1157 of file Simplex.H.

References Aleph::GE.

Referenced by TEST(), and TEST_F().

◆ put_objetive_function() [1/2]

template<typename T >
void Aleph::Simplex< T >::put_objetive_function ( const DynArray< T > &  coefs)
inline

Sets all objective function coefficients from a DynArray.

Parameters
[in]coefsArray of coefficients. Must have at least num_var elements.

Definition at line 1095 of file Simplex.H.

Referenced by TEST_F(), and TEST_F().

◆ put_objetive_function() [2/2]

template<typename T >
void Aleph::Simplex< T >::put_objetive_function ( const T  coefs[])
inline

Sets all objective function coefficients from a C array.

Parameters
[in]coefsArray of coefficients. Must have at least num_var elements.

Definition at line 1105 of file Simplex.H.

◆ put_objetive_function_coef()

template<typename T >
void Aleph::Simplex< T >::put_objetive_function_coef ( size_t  i,
const T &  coef 
)
inline

◆ put_restriction() [1/2]

template<typename T >
T * Aleph::Simplex< T >::put_restriction ( const DynArray< T > &  coefs,
ConstraintType  type = ConstraintType::LE 
)
inline

Adds a constraint from a DynArray.

Parameters
[in]coefsArray of n+1 coefficients.
[in]typeConstraint type: LE (≤), GE (≥), or EQ (=). Default is LE.
Returns
Pointer to the internal constraint array.
Exceptions
std::bad_allocIf memory allocation fails.
std::logic_errorIf prepare_linear_program() already built the tableau, as put_restriction() explains.

Definition at line 1188 of file Simplex.H.

◆ put_restriction() [2/2]

template<typename T >
T * Aleph::Simplex< T >::put_restriction ( const T *  coefs = nullptr,
ConstraintType  type = ConstraintType::LE 
)
inline

Adds a constraint to the linear program.

Adds a constraint of the form: c[0]*x_0 + c[1]*x_1 + ... + c[n-1]*x_{n-1} [op] c[n]

where c[n] is the RHS (right-hand side) bound and [op] is determined by the constraint type (≤, ≥, or =). The RHS may be negative.

Parameters
[in]coefsArray of n+1 coefficients (n variable coefficients + RHS). If nullptr, creates a zero-initialized constraint.
[in]typeConstraint type: LE (≤), GE (≥), or EQ (=). Default is LE.
Returns
Pointer to the internal constraint array (can be modified).
Exceptions
std::bad_allocIf memory allocation fails.
std::logic_errorIf prepare_linear_program() already built the tableau: it does not grow, and the solver would read past it. The program is left as it was. A preparation that threw, as std::bad_alloc, built none, so the program still takes restrictions.

Definition at line 1132 of file Simplex.H.

Referenced by Moved_From_Case< Simplex< double > >::add_sum_restriction(), demo_algorithm_steps(), demo_diet_problem(), demo_production_planning(), demo_resource_allocation(), demo_special_cases(), Aleph::MCF_LP_Solver< Net >::solve(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), and TEST_F().

◆ put_restriction_coef()

template<typename T >
void Aleph::Simplex< T >::put_restriction_coef ( const size_t  rest_num,
const size_t  idx,
const T &  coef 
)
inline

Sets a specific coefficient in a constraint.

Parameters
[in]rest_numConstraint index.
[in]idxVariable index within the constraint.
[in]coefNew coefficient value.
Exceptions
std::out_of_rangeIf indices are out of range.

Definition at line 1270 of file Simplex.H.

Referenced by TEST_F().

◆ reduced_cost()

template<typename T >
T Aleph::Simplex< T >::reduced_cost ( size_t  var_idx) const
inline

Gets the reduced cost for a variable.

The reduced cost is the change of the objective per unit increase of a non-basic variable, the others non-basic at zero: c_j - sum_i shadow_price(i) * a_ij. At the optimum it is <= 0 when maximizing and >= 0 when minimizing, and 0 for a basic variable.

Parameters
[in]var_idxVariable index (0-based).
Returns
Reduced cost value.
Precondition
solve() must have been called and returned Solved.
Exceptions
std::out_of_rangeIf var_idx is out of range.
std::logic_errorIf not solved yet.

Definition at line 1843 of file Simplex.H.

References ah_logic_error_if, m, and Aleph::Maximize.

Referenced by TEST().

◆ restriction()

template<typename T >
T * Aleph::Simplex< T >::restriction ( const size_t  rest_idx) const
inlineprivate

Definition at line 864 of file Simplex.H.

◆ rhs_col()

◆ rhs_sensitivity()

template<typename T >
SensitivityRange< T > Aleph::Simplex< T >::rhs_sensitivity ( size_t  rest_idx) const
inline

Computes sensitivity range for a RHS value.

Determines the range within which the right-hand side value b_i can vary, the others fixed, while the optimal basis stays feasible, and so optimal: over it, the optimal value changes by shadow_price() per unit.

Parameters
[in]rest_idxConstraint index (0-based).
Returns
SensitivityRange structure with bounds and current value; an infinite bound means no limit.
Precondition
solve() must have been called and returned Solved.
Exceptions
std::out_of_rangeIf rest_idx is out of range.
std::logic_errorIf not solved yet.

Definition at line 1744 of file Simplex.H.

References ah_logic_error_if, col, Aleph::SensitivityRange< T >::current_value, Aleph::SensitivityRange< T >::lower_bound, m, and Aleph::SensitivityRange< T >::upper_bound.

Referenced by TEST(), TEST(), TEST(), and TEST_F().

◆ run()

template<typename T >
template<class Hook >
State Aleph::Simplex< T >::run ( Hook &  hook)
inlineprivate

Definition at line 635 of file Simplex.H.

References m.

◆ same_ratio()

template<typename T >
bool Aleph::Simplex< T >::same_ratio ( const T &  a,
const T &  b 
) const
inlineprivatenoexcept

◆ scale_of()

template<typename T >
static T Aleph::Simplex< T >::scale_of ( const T &  magnitude)
inlinestaticprivatenoexcept

Definition at line 725 of file Simplex.H.

◆ set_epsilon()

template<typename T >
void Aleph::Simplex< T >::set_epsilon ( T  epsilon)
inlinenoexcept

Sets the floating-point comparison tolerance.

A value of the scaled program (see the class documentation) is taken as zero when its magnitude is below epsilon; a right-hand side, when it is below epsilon times the largest magnitude of the right-hand sides, if this one is above 1.

Parameters
[in]epsilonTolerance for comparing values to zero.
Note
Must be called before prepare_linear_program().

Definition at line 1049 of file Simplex.H.

Referenced by TEST().

◆ set_maximize()

template<typename T >
void Aleph::Simplex< T >::set_maximize ( )
inlinenoexcept

Sets maximization mode.

Convenience method equivalent to set_optimization_type(Maximize).

Definition at line 1010 of file Simplex.H.

References Aleph::Maximize.

Referenced by TEST_F().

◆ set_minimize()

template<typename T >
void Aleph::Simplex< T >::set_minimize ( )
inlinenoexcept

Sets minimization mode.

Convenience method equivalent to set_optimization_type(Minimize).

Definition at line 1001 of file Simplex.H.

References Aleph::Minimize.

Referenced by Aleph::MCF_LP_Solver< Net >::solve(), TEST_F(), and TEST_F().

◆ set_optimization_type()

template<typename T >
void Aleph::Simplex< T >::set_optimization_type ( OptimizationType  type)
inlinenoexcept

Sets the optimization type.

Parameters
[in]typeMaximize or Minimize.
Note
Must be called before prepare_linear_program().

Definition at line 992 of file Simplex.H.

Referenced by TEST().

◆ set_pivot_rule()

template<typename T >
void Aleph::Simplex< T >::set_pivot_rule ( PivotRule  rule)
inlinenoexcept

Sets the pivot selection rule.

Parameters
[in]ruleDantzig (default, faster) or Bland (anti-cycling).

Bland's rule guarantees termination on degenerate problems but may be slower on non-degenerate problems. Dantzig's rule switches to it after a run of degenerate pivots, so that it ends too.

Definition at line 1023 of file Simplex.H.

Referenced by TEST().

◆ shadow_price()

template<typename T >
T Aleph::Simplex< T >::shadow_price ( size_t  rest_idx) const
inline

Gets the shadow price (dual value) for a constraint.

The shadow price is the change of the optimal value of the objective per unit increase of the right-hand side b_i, over the range of rhs_sensitivity(): when maximizing, >= 0 for a ≤ constraint and <= 0 for a ≥ one; when minimizing, the other way. The shadow prices are an optimal solution of the dual program.

Parameters
[in]rest_idxConstraint index (0-based).
Returns
Shadow price (dual variable value).
Precondition
solve() must have been called and returned Solved.
Exceptions
std::out_of_rangeIf rest_idx is out of range.
std::logic_errorIf not solved yet.

Definition at line 1812 of file Simplex.H.

References ah_logic_error_if, m, and Aleph::Minimize.

Referenced by TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), and TEST().

◆ solve()

template<typename T >
State Aleph::Simplex< T >::solve ( )
inline

Solves the linear program.

Solves a correctly and completely specified linear program using the two-phase simplex method.

Returns
Solution state:
  • Unbounded: The objective improves without limit.
  • Solved: Optimal solution found.
  • Unfeasible: No feasible solution exists.
Note
After solving, call load_solution() to retrieve variable values.
Exceptions
std::logic_errorIf solve() has already been called.
std::logic_errorIf no constraints have been added.
std::logic_errorIf prepare_linear_program() was not called.

Definition at line 1310 of file Simplex.H.

References ah_logic_error_if, and m.

Referenced by demo_algorithm_steps(), demo_diet_problem(), demo_production_planning(), demo_resource_allocation(), demo_special_cases(), Aleph::MCF_LP_Solver< Net >::solve(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), and Moved_From_Case< Simplex< double > >::use().

◆ swap()

template<typename T >
void Aleph::Simplex< T >::swap ( Simplex< T > &  other)
inlinenoexcept

Exchanges in O(1) this solver and another.

Parameters
[in,out]othersolver to exchange with.

Definition at line 954 of file Simplex.H.

References m.

◆ to_pivot()

◆ update_rhs_and_reoptimize()

template<typename T >
State Aleph::Simplex< T >::update_rhs_and_reoptimize ( size_t  rest_idx,
T  new_rhs 
)
inline

Updates RHS value and re-optimizes using dual simplex.

Efficiently re-solves the problem when only RHS values change: the right-hand sides of the tableau change by the column of the inverse of the basis of the constraint, and dual_solve() restores their feasibility.

Parameters
[in]rest_idxConstraint index to update.
[in]new_rhsNew right-hand side value.
Returns
Solution state after re-optimization.
Precondition
solve() must have been called and returned Solved.
Exceptions
std::out_of_rangeIf rest_idx is out of range.
std::logic_errorIf the problem is not solved.

Definition at line 2042 of file Simplex.H.

References ah_logic_error_if, col, m, and row.

Referenced by TEST(), TEST(), TEST(), TEST(), and TEST_F().

◆ verify_rest_index()

template<typename T >
void Aleph::Simplex< T >::verify_rest_index ( const size_t  i) const
inlineprivate

Definition at line 689 of file Simplex.H.

References ah_out_of_range_error_if.

◆ verify_solution()

template<typename T >
bool Aleph::Simplex< T >::verify_solution ( ) const
inline

Verifies that the solution satisfies all constraints.

Checks that every variable is >= 0 and that every constraint holds, up to a tolerance relative to the magnitude of its terms: the largest of the tolerance of set_epsilon() and 10000 times the epsilon of T.

Returns
true if all constraints are satisfied, false otherwise.
Precondition
load_solution() must have been called first.

Definition at line 1393 of file Simplex.H.

References Aleph::EQ, Aleph::GE, Aleph::LE, Aleph::size(), and Aleph::sum().

Referenced by demo_production_planning(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), and Moved_From_Case< Simplex< double > >::use().

◆ verify_var_index()

template<typename T >
void Aleph::Simplex< T >::verify_var_index ( const size_t  i) const
inlineprivate

Definition at line 681 of file Simplex.H.

References ah_out_of_range_error_if.

Member Data Documentation

◆ basic_vars

template<typename T >
std::vector<int> Aleph::Simplex< T >::basic_vars
mutableprivate

◆ col_scale

template<typename T >
std::vector<T> Aleph::Simplex< T >::col_scale
private

Definition at line 344 of file Simplex.H.

◆ degenerate_run

template<typename T >
size_t Aleph::Simplex< T >::degenerate_run = 0
private

Definition at line 355 of file Simplex.H.

Referenced by Aleph::Simplex< T >::bland_now(), and Aleph::Simplex< T >::iterate().

◆ eps

template<typename T >
T Aleph::Simplex< T >::eps
private

Definition at line 312 of file Simplex.H.

Referenced by Aleph::Simplex< T >::same_ratio().

◆ in_phase1

template<typename T >
bool Aleph::Simplex< T >::in_phase1 = false
private

◆ m

◆ num_artificial

template<typename T >
size_t Aleph::Simplex< T >::num_artificial
private

Definition at line 307 of file Simplex.H.

Referenced by Aleph::Simplex< T >::rhs_col().

◆ num_rest

◆ num_var

◆ obj_scale

template<typename T >
T Aleph::Simplex< T >::obj_scale = T{1}
private

Definition at line 345 of file Simplex.H.

◆ objetive

template<typename T >
std::unique_ptr<T[]> Aleph::Simplex< T >::objetive
private

Definition at line 302 of file Simplex.H.

◆ opt_type

template<typename T >
OptimizationType Aleph::Simplex< T >::opt_type
private

Definition at line 310 of file Simplex.H.

◆ phase2_cost

template<typename T >
std::vector<T> Aleph::Simplex< T >::phase2_cost
private

Definition at line 336 of file Simplex.H.

Referenced by Aleph::Simplex< T >::load_phase1_costs().

◆ pivot_col_buffer

template<typename T >
std::vector<T> Aleph::Simplex< T >::pivot_col_buffer
mutableprivate

Definition at line 319 of file Simplex.H.

Referenced by Aleph::Simplex< T >::to_pivot().

◆ pivot_row_buffer

template<typename T >
std::vector<T> Aleph::Simplex< T >::pivot_row_buffer
mutableprivate

Definition at line 318 of file Simplex.H.

Referenced by Aleph::Simplex< T >::to_pivot().

◆ pivot_rule

template<typename T >
PivotRule Aleph::Simplex< T >::pivot_rule
private

Definition at line 311 of file Simplex.H.

Referenced by Aleph::Simplex< T >::bland_now().

◆ rest_list

template<typename T >
DynDlist<T *> Aleph::Simplex< T >::rest_list
private

Definition at line 303 of file Simplex.H.

◆ rest_types

template<typename T >
DynDlist<ConstraintType> Aleph::Simplex< T >::rest_types
private

Definition at line 304 of file Simplex.H.

◆ row_scale

template<typename T >
std::vector<T> Aleph::Simplex< T >::row_scale
private

Definition at line 343 of file Simplex.H.

◆ row_sign

template<typename T >
std::vector<int> Aleph::Simplex< T >::row_sign
private

Definition at line 327 of file Simplex.H.

◆ solution

template<typename T >
std::unique_ptr<T[]> Aleph::Simplex< T >::solution
private

Definition at line 308 of file Simplex.H.

◆ state

template<typename T >
State Aleph::Simplex< T >::state
private

Definition at line 309 of file Simplex.H.

◆ stats

template<typename T >
SimplexStats Aleph::Simplex< T >::stats
mutableprivate

◆ tie_cost

◆ tol_coef

template<typename T >
T Aleph::Simplex< T >::tol_coef = T{0}
private

◆ tol_cost

template<typename T >
T Aleph::Simplex< T >::tol_cost = T{0}
private

Definition at line 352 of file Simplex.H.

◆ tol_rhs

template<typename T >
T Aleph::Simplex< T >::tol_rhs = T{0}
private

Definition at line 351 of file Simplex.H.

Referenced by Aleph::Simplex< T >::iterate().

◆ unit_col

template<typename T >
std::vector<size_t> Aleph::Simplex< T >::unit_col
private

Definition at line 332 of file Simplex.H.


The documentation for this class was generated from the following file: