In: Computer Science
Solve the linear program below with python.
OBJECTIVE FUNCTION::
Maximize Contribution Z=40X+26Y+66Z
CONSTRAINTS:
Cutting Capacity =1800min.
4X+8Y+4Z< or =1800
Stitching Capacity =2100 min
6X+6Y+4Z< or=2100
Pressing Capacity=1500 min.
6X+8Y+6Z< or =1500
Maximize : Z=40X+26Y+66Z
Constraints:
4X+8Y+4Z< or =1800
6X+6Y+4Z< or=2100
6X+8Y+6Z< or =1500
import numpy as np
A = np.array([[4, 8, 4], [6, 6, 4], [6, 8, 6]])#array A as a 3 by 3
array of the coefficients
b = np.array([1800, 2100, 1500])#array b as the right-hand side of
the equations
r = np.linalg.solve(A, b)#Solve for the values of x, y and z using
np.linalg.solve(A, b)
print("The result set is",r)
x=r[0]#storing the value of x from the result set to variable
x
y=r[1]#storing the value of y from the result set to variable
y
z=r[2]#storing the value of z from the result set to variable
z
Z=(40*x)+(26*y)+(66*z)
print("Z is equal to ",Z)
The below photo shows the execution of this problem in jupyter notebook.