library(simplexR)

Arbitrary Linear Programs

--- Werners, Brigitte - Grundlagen des Operations Research (page 79)

$$ \begin{array}{rrcrcr} \max & 3x_1 & + & 2x_2 & \ s.t. & 2x_1 & + & 1x_2 & \leq & 22 \ & 1x_1 & + & 2x_2 & \leq & 23 \ & 4x_1 & + & 1x_2 & \leq & 40 \ & 1x_1 & + & 1x_2 & \geq & 5 \ & 1x_1 & - & 1/3x_2 & = & 6 \ & x_1,& & x_2 & \geq & 0 \end{array} $$

# See:  Werners Brigitte,  page 79
# optimal solution: x = (8, 6), z = 36

A <- matrix(c(
  2, 1,
  1, 2,
  4, 1,
  1, 1,
  1, -1/3
), nrow = 5, ncol = 2, byrow = TRUE, dimnames = list(c("R1", "R2", "R3", "R4", "R5"), c("x1", "x2")))

b <- c(22, 23, 40, 5, 6)
c <- c(3, 2)
sense <- 1
relation <- c("<=", "<=", "<=", ">=", "=")
canonical_tableau <- construct_tableau(A, b, c, sense, relation)
canonical_tableau
simplex(tableau = canonical_tableau)

Primal Degeneracy --- Stalling and Cycling

--- Examples from: Operations Research - Deterministische Modelle und Methoden - Stephan Dempe, Heiner Schreier, 1. Auflage September 2006, Wiesbaden

# See: Dempe/Schreier,  page 34
# primal degeneracy: stalling and cycling
# based on Beale (1955)

A <- matrix(c(
  1/4, -8, -1, 9,
  1/2, -12, -1/2, 3,
  0, 0, 1, 0
), nrow = 3, ncol = 4, byrow = TRUE, dimnames = list(c("R1", "R2", "R3"), c("x1", "x2", "x3", "x4")))

b <- c(0, 0, 1)
c <- c(3/4, -20, 1/2, -6)
sense <- 1
relation <- c("<=", "<=", "<=")
cycling_case <- construct_tableau(A, b, c, sense, relation)
cycling_case
simplex(tableau = cycling_case, max_iter = 7)


dirkdegel/simplexR documentation built on Feb. 22, 2020, 11:25 a.m.