0% found this document useful (0 votes)
16 views1 page

Main Ipynb

Mathematics Answer

Uploaded by

alazerasegd
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views1 page

Main Ipynb

Mathematics Answer

Uploaded by

alazerasegd
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

{"cells":[{"cell_type":"code","source":["# Import PuLP library\n","from pulp import

LpMaximize, LpProblem, LpVariable, value\n","\n","# Define the linear programming


problem\n","problem = LpProblem(\"Maximize_Profit\", LpMaximize)\n","\n","# Define
the decision variables (non-negative)\n","x1 = LpVariable(\"Cotton_Fabric\",
lowBound=0) # Units of cotton fabric\n","x2 = LpVariable(\"Polyester_Fabric\",
lowBound=0) # Units of polyester fabric\n","x3 =
LpVariable(\"Mixed_Fiber_Fabric\", lowBound=0) # Units of mixed-fiber fabric\n","\
n","# Objective function: Maximize profit\n","problem += 5 * x1 + 4 * x2 + 6 *
x3, \"Total_Profit\"\n","\n","# Constraints\n","problem += 2 * x1 + x3 <=
50, \"Cotton_Constraint\" # Cotton availability\n","problem += 3 * x2 + x3 <=
70, \"Polyester_Constraint\" # Polyester availability\n","problem += 2 * x3 <= 60,
\"Mixed_Fiber_Constraint\" # Mixed fibers availability\n","problem += 3 * x1 + 2 *
x2 + 4 * x3 <= 500, \"Labor_Hours_Constraint\" # Labor hours\n","problem += 2 * x1
+ 3 * x2 + 3 * x3 <= 400, \"Machine_Hours_Constraint\" # Machine hours\n","\n","#
Solve the problem\n","problem.solve()\n","\n","# Display results\
n","print(\"Optimal Production Plan:\")\n","print(f\"Cotton Fabric: {x1.varValue}
units\")\n","print(f\"Polyester Fabric: {x2.varValue} units\")\n","print(f\"Mixed-
Fiber Fabric: {x3.varValue} units\")\n","print(f\"Maximum Profit: $
{value(problem.objective):.2f}\")"],"metadata":{"fiddle":
{"running":false,"focus":false,"success":false}},"id":"8d3949be-d7eb-47ec-83fa-
d067bf678074","outputs":[{"output_type":"error","name":"stderr","traceback":["line
23, in <module>"," problem.solve()"," File
\"/lib/python3.12/site-packages/pulp/pulp.py\", line 1867, in solve"," status =
solver.actualSolve(self, **kwargs)","
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"," File
\"/lib/python3.12/site-packages/pulp/apis/coin_api.py\", line 112, in
actualSolve"," return self.solve_CBC(lp, **kwargs)","
^^^^^^^^^^^^^^^^^^^^^^^^^^^^"," File
\"/lib/python3.12/site-packages/pulp/apis/coin_api.py\", line 177, in solve_CBC","
cbc = subprocess.Popen(args, stdout=pipe, stderr=pipe, stdin=devnull)","
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"," File
\"/lib/python312.zip/subprocess.py\", line 818, in __init__"," raise
OSError(","OSError: [Errno 138] emscripten does not support
processes."],"metadata":{}}]}],"metadata":{"kernelspec":
{"name":"pyodide","display_name":"Python","language":"python","ext":"py"}},"nbforma
t":4,"nbformat_minor":5,"id":"295be17e-fc50-4f87-bc95-77841c5105f9"}

You might also like