N-W alg added
This commit is contained in:
@@ -26,12 +26,29 @@ class Result:
|
|||||||
self.solution = solution
|
self.solution = solution
|
||||||
|
|
||||||
|
|
||||||
def NorthwestCorner(
|
def NorthwestCorner(S: np.array,
|
||||||
S: np.array,
|
C: np.array,
|
||||||
C: np.array,
|
D: np.array) -> Result:
|
||||||
D: np.array) -> Result:
|
num_rows, num_cols = len(S), len(D)
|
||||||
# TODO Northwest corner method
|
solution = [[0] * num_cols for _ in range(num_rows)]
|
||||||
pass
|
|
||||||
|
i, j = 0, 0
|
||||||
|
while i < num_rows and j < num_cols:
|
||||||
|
quantity = min(S[i], D[j])
|
||||||
|
solution[i][j] = quantity
|
||||||
|
S[i] -= quantity
|
||||||
|
D[j] -= quantity
|
||||||
|
|
||||||
|
if S[i] == 0:
|
||||||
|
i += 1
|
||||||
|
elif D[j] == 0:
|
||||||
|
j += 1
|
||||||
|
|
||||||
|
if sum(S) == 0 and sum(D) == 0:
|
||||||
|
objective_function_value = np.sum(solution * C)
|
||||||
|
return Result(State.SOLVED, objective_function_value, solution)
|
||||||
|
else:
|
||||||
|
return Result(State.UNAPPLICABLE)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -272,4 +289,4 @@ def solve(
|
|||||||
])
|
])
|
||||||
|
|
||||||
print(Russell(S, C, D))
|
print(Russell(S, C, D))
|
||||||
'''
|
'''
|
||||||
|
|||||||
Reference in New Issue
Block a user