Skip to content
Permalink
main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
{
"cells": [
{
"cell_type": "markdown",
"id": "5937b132",
"metadata": {},
"source": [
"# Tools making optimisation problem"
]
},
{
"cell_type": "markdown",
"id": "cbca808d",
"metadata": {},
"source": [
"AAA is a company that produces tools T1, T2 and T3. These are made from steel, and the process involves molding the tools and then assembling them.\n",
"\n",
"The following table summarises the requirements and constraints:\n",
"\n",
"| | T1 | T2 | T3 | Availability |\n",
"|--------------------------|--------|--------|--------|--------------|\n",
"| Steel (kg) | 1 | 0.7 | 0.6 | 10,000 |\n",
"| Molding machine (hr) | 1 | 1 | 1 | 20,000 |\n",
"| Assembly machine (hr) | 0.3 | 0.5 | 0.4 | 9,000 |\n",
"| Demand limit (tools/day) | 15,000 | 16,000 | 12,000 | |\n",
"| Profit (£/1000 units) | 130 | 100 | 120 | |\n",
"\n",
"AAA would like to plan for the daily production of tools to maximise its profit.\n",
"In particular, we have the following questions:\n",
"\n",
"- How many of each type of the tools should AAA plan to produce per day?\n",
"- What is the expected total profit from this plan?\n",
"- Which resources are expected to be most critical in this plan?"
]
},
{
"cell_type": "markdown",
"id": "5f8a3431",
"metadata": {},
"source": [
"### Marking scheme\n",
"\n",
"|Item|Mark|\n",
"|:----|---:|\n",
"|**Mathematical formulation**:||\n",
"|Decision variables|/1|\n",
"|Profit formula|/1|\n",
"|Constraints|/2|\n",
"|Demand limits|/2|\n",
"|Non-negativity constraints|/1|\n",
"|**Solution**:||\n",
"|PuLP solution|/4|\n",
"|**Answers to AAA's questions**:||\n",
"|How many of each type of the tools should AAA plan to produce per day?|/3|\n",
"|What is the expected total profit from this plan?|/3|\n",
"|Which resources are expected to be most critical in this plan?|/3|\n",
"|||\n",
"|**Total**: |/20|\n"
]
},
{
"cell_type": "markdown",
"source": [
"## Mathematical formulation"
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "markdown",
"id": "06aeba09",
"metadata": {},
"source": [
"Decision variables:\n",
"\n",
"X_T1 -- Daily Production of Tool 1\n",
"X_T2 -- Daily Production of Tool 2\n",
"X_T3 -- Daily Production of Tool 3"
]
},
{
"cell_type": "markdown",
"id": "56ab5cbe",
"metadata": {},
"source": [
"\n",
"Profit formula (to be optimised):\n",
"$$\n",
"Maximise Z = (130/1000)*X_T_1 + (100/1000)*X_T_2 + (120/1000)*X_T_3 = 0.13X_T_1 + 0.1X_T_2 + 0.12X_T_3\n",
"$$"
]
},
{
"cell_type": "markdown",
"id": "9b2ca564",
"metadata": {},
"source": [
"Constraints:\n",
"\n",
"$$\n",
"\\begin{alignat*}\n",
" Steel Material Constraint (KG):\n",
" & 1*X_T_1 + 0.7*X_T_2 + 0.6*X_T_3 &\\leq 10,000 \\\\\n",
" Molding Machine Time Constraint (HR):\n",
" & 1*X_T_1 + 1*X_T_2 + 1*X_T_3 &\\leq 20,000 \\\\\n",
" Assembly Machine Time Constraint (HR):\n",
" & 0.3*X_T_1 + 0.5*X_T_2 + 0.4*X_T_3 &\\leq 9,000 \\\\\n",
"\\end{alignat*}\n",
"$$\n",
"\n",
"Demand limits:\n",
"\n",
"$$\n",
"\\begin{alignat*}\n",
" & X_T_1 &\\leq 15,000 \\\\\n",
" & X_T_2 &\\leq 16,000 \\\\\n",
" & X_T_1 &\\leq 12,000 \\\\\n",
"\\end{alignat*}\n",
"$$\n",
"\n",
"Non-negativity constraints:\n",
"\n",
"$$\n",
"X_T_1, X_T_2, X_T_3 \\geq 0\n",
"$$"
]
},
{
"cell_type": "markdown",
"id": "94561b9d",
"metadata": {},
"source": [
"## Solution"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1a5ec9b7",
"metadata": {
"ExecuteTime": {
"end_time": "2022-10-25T11:37:42.147735Z",
"start_time": "2022-10-25T11:37:42.007094Z"
}
},
"outputs": [],
"source": [
"import pulp"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "0a67ab32",
"metadata": {},
"outputs": [],
"source": [
"#Create Problem\n",
"AAA_lp_problem = pulp.LpProblem(\"AAA_LP_Problem\", pulp.LpMaximize)"
]
},
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
"source": [
"#Add Variables (non-negative constraint set to lower bound, demand limits set to higher bound)\n",
"X_T1 = pulp.LpVariable('X_T1', lowBound=0, upBound=15000, cat='Integer')\n",
"X_T2 = pulp.LpVariable('X_T2', lowBound=0, upBound=16000, cat='Integer')\n",
"X_T3 = pulp.LpVariable('X_T3', lowBound=0, upBound=12000, cat='Integer')"
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
"source": [
"#Add Profit Formula\n",
"AAA_lp_problem += (130/1000)*X_T1 + (100/1000)*X_T2 + (120/1000)*X_T3, \"Z\"\n",
"\n",
"#Add Constraints\n",
"AAA_lp_problem += 1*X_T1 + 0.7*X_T2 + 0.6*X_T3 <=10000\n",
"AAA_lp_problem += 1*X_T1 + 1*X_T2 + 1*X_T3 <=20000\n",
"AAA_lp_problem += 0.3*X_T1 + 0.5*X_T2 + 0.4*X_T3 <=9000"
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
"source": [
"#Show Problem Summary\n",
"AAA_lp_problem"
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
"source": [
"#Solve LP Problem\n",
"AAA_lp_problem.solve()"
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
"source": [
"#Show Output Status (Optimal = The solver has found an optimal solution to our problem)\n",
"print(\"LP Solver Status:\")\n",
"pulp.LpStatus[AAA_lp_problem.status]"
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
"source": [
"#Print Variable Values\n",
"print(\"Total daily production for each tool:\")\n",
"for variable in AAA_lp_problem.variables():\n",
" print(variable.name, variable.varValue)"
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
"source": [
"#Print Final Profit Output\n",
"print(\"Total daily profit:\")\n",
"print(pulp.value(AAA_lp_problem.objective))"
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
"source": [
"#Daily Resource cost\n",
"print(\"Total daily resource cost:\")\n",
"print(\"Steel (KG)\", X_T1.varValue*1 + X_T2.varValue*0.7 + X_T3.varValue*0.6)\n",
"print(\"Molding Machine Time (HR)\", X_T1.varValue*1 + X_T2.varValue*1 + X_T3.varValue*1)\n",
"print(\"Assembly Machine Time (HR)\", X_T1.varValue*0.3 + X_T2.varValue*0.5 + X_T3.varValue*0.4)\n",
"print(\"Total Production Time (HR)\", X_T1.varValue*1 + X_T2.varValue*1 + X_T3.varValue*1 + X_T1.varValue*0.3 + X_T2.varValue*0.5 + X_T3.varValue*0.4)"
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "markdown",
"id": "524021a2",
"metadata": {},
"source": [
"# Conclusion"
]
},
{
"cell_type": "markdown",
"source": [
"- How many of each type of the tools should AAA plan to produce per day?\n",
"According to the lp solver, the optimal production solution would be to produce 0 T1 tools, 4000 T2 tools and 12000 tools each day.\n",
"|\n",
"- What is the expected total profit from this plan?\n",
"The expected total profit, when working at an optimal level is £1840 per day.\n",
"|\n",
"- Which resources are expected to be most critical in this plan?\n",
"For the plan to work as required, all resources can be considered critical as neither are in abundant supply when comparing amount used to amount available (production time: 22800 hours used per day out of 29000 available/steel: 10000kg used per day out of 10000kg available). More specifically, our most critical resource is steel, as there are no leftover available resources left at the end of the day. There is no excess in steel supply."
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "markdown",
"id": "57a444ba",
"metadata": {},
"source": [
"# List of references\n",
"\n",
"Ben Alex Keen.(2016). Linear Programming with Python and PuLP. http://benalexkeen.com/linear-programming-with-python-and-pulp-part-2/"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.3"
},
"toc": {
"base_numbering": 1,
"nav_menu": {},
"number_sections": false,
"sideBar": true,
"skip_h1_title": false,
"title_cell": "Table of Contents",
"title_sidebar": "Contents",
"toc_cell": false,
"toc_position": {},
"toc_section_display": true,
"toc_window_display": false
},
"vscode": {
"interpreter": {
"hash": "6d1e45cadc3597bb8b6600530fbdf8c3eefe919a24ef54d9d32b318795b772e0"
}
}
},
"nbformat": 4,
"nbformat_minor": 5
}