#do not forget to instal pulp
#python -m pip install pulp

# import the solver pulp
from pulp import *

# define the data
m = 4
n = 2
indexI = range(1,m+1)
indexJ = range(1,n+1)

A = [
    [6, 4],
    [1, 2],
    [-1, 1],
    [0, 1]
]

B = [24, 6, 1, 2]

C = [5, 4]

A = makeDict([indexI, indexJ], A)
B = makeDict([indexI], B)
C = makeDict([indexJ], C)


# Define the Model
model_RM = LpProblem("Reddy Mikks", LpMaximize)

#Define the variables
x = LpVariable.dicts("x", indexJ, 0, None)

#Objective function
model_RM += (
    lpSum([x[j] * C[j] for j in indexJ]),
    "FO",
)

for i in indexI:
    model_RM += (
            lpSum([A[i][j]*x[j] for j in indexJ]) <= B[i],
            f"constraint_{i}",
            )

model_RM.solve()
status=LpStatus[model_RM.status]
print("Status:", LpStatus[model_RM.status])

# write the model in a txt file
model_RM.writeLP("modelRM.lp")

# write the solution
print("OF value = ",
      value(model_RM.objective))

# Each of the variables is printed with it's resolved optimum value
for v in model_RM.variables():
       print(v.name, "=", v.varValue)


