MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / generate_col_titles

Method generate_col_titles

linear_programming/simplex.py:86–106  ·  view source on GitHub ↗

Generate column titles for tableau of specific dimensions >>> Tableau(np.array([[-1,-1,0,0,1],[1,3,1,0,4],[3,1,0,1,4.]]), ... 2, 0).generate_col_titles() ['x1', 'x2', 's1', 's2', 'RHS'] >>> Tableau(np.array([[-1,-1,0,0,1],[1,3,1,0,4],[3,1,0,1,4.]]), ... 2, 2

(self)

Source from the content-addressed store, hash-verified

84 self.stop_iter = False
85
86 def generate_col_titles(self) -> list[str]:
87 """Generate column titles for tableau of specific dimensions
88
89 >>> Tableau(np.array([[-1,-1,0,0,1],[1,3,1,0,4],[3,1,0,1,4.]]),
90 ... 2, 0).generate_col_titles()
91 ['x1', 'x2', 's1', 's2', 'RHS']
92
93 >>> Tableau(np.array([[-1,-1,0,0,1],[1,3,1,0,4],[3,1,0,1,4.]]),
94 ... 2, 2).generate_col_titles()
95 ['x1', 'x2', 'RHS']
96 """
97 args = (self.n_vars, self.n_slack)
98
99 # decision | slack
100 string_starts = ["x", "s"]
101 titles = []
102 for i in range(2):
103 for j in range(args[i]):
104 titles.append(string_starts[i] + str(j + 1))
105 titles.append("RHS")
106 return titles
107
108 def find_pivot(self) -> tuple[Any, Any]:
109 """Finds the pivot row and column.

Callers 1

__init__Method · 0.95

Calls 1

appendMethod · 0.45

Tested by

no test coverage detected