Skip to content
Permalink
98df406b54
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
326 lines (326 sloc) 9.78 KB
{
"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 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",
"id": "0366a3fc",
"metadata": {},
"source": [
"## Mathematical formulation"
]
},
{
"cell_type": "markdown",
"id": "06aeba09",
"metadata": {},
"source": [
"Decision variables:\n",
"\n",
"|Variable name| Description |\n",
"|-------------|------|\n",
"|Tool 1 |Variable for T1|\n",
"|Tool 2|Variable for T2|\n",
"|Tool 3|Variable for T3"
]
},
{
"cell_type": "markdown",
"id": "56ab5cbe",
"metadata": {},
"source": [
"\n",
"Profit formula (to be optimised):\n",
"$$\n",
"Z=0.13T1+0.1T2+120T3\n",
"$$"
]
},
{
"cell_type": "markdown",
"id": "9b2ca564",
"metadata": {},
"source": [
"Constraints:\n",
"\n",
"$$\n",
"\\begin{alignat*}{4}\n",
" &1T1+0.7T2+0.6T3 &\\leq 10000 \\\\\n",
" &1T1+1T2+1T3 &\\leq 20000 \\\\\n",
" &0.3T1+0.5T2+0.4T3 &\\leq 9000 \\\\\n",
"\\end{alignat*}\n",
"$$\n",
"\n",
"Demand limits:\n",
"\n",
"$$\n",
"\\begin{alignat*}{2}\n",
" & T1 &\\leq 15000 \\\\\n",
" & T2 &\\leq 16000 \\\\\n",
" & T3 &\\leq 12000 \\\\\n",
"\\end{alignat*}\n",
"$$\n",
"\n",
"Non-negativity constraints:\n",
"\n",
"$$\n",
"T1,T2,T3 \\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": [
{
"ename": "",
"evalue": "",
"output_type": "error",
"traceback": [
"\u001b[1;31mRunning cells with 'Python 3.11.0 64-bit' requires ipykernel package.\n",
"\u001b[1;31mRun the following command to install 'ipykernel' into the Python environment. \n",
"\u001b[1;31mCommand: '\"c:/Users/Ali Ibrahim/AppData/Local/Programs/Python/Python311/python.exe\" -m pip install ipykernel -U --user --force-reinstall'"
]
}
],
"source": [
"# Import all classes of PuLP module\n",
"from pulp import *\n",
"\n",
"# Create the problem variable to contain the problem data\n",
"model = LpProblem(\"ToolsProblem\", LpMaximize)\n",
"\n",
"# Create 3 variables Steel, Molding_machine, and Assembly_machine\n",
"\n",
"T1 = LpVariable(\"Tool1\", 0, None, LpInteger)\n",
"T2 = LpVariable(\"Tool2\", 0, None, LpInteger) \n",
"T3 = LpVariable(\"Tool3\", 0, None, LpInteger)\n",
"\n",
"# Create maximize objective function\n",
"model += 0.13 * T1 + 0.1 * T2 + 0.12 * T3 \n",
"\n",
"#Constraints:\n",
"\n",
"model += 1*T1 + 0.7 * T2 + 0.6 * T3 <= 10000, \"Steel\"\n",
"model += 1*T1 + 1 * T2 + 1 * T3 <= 20000, \"Molding_machine\"\n",
"model += 0.3*T1 + 0.5 * T2 + 0.4 * T3 <= 9000, \"Assembly_machine\"\n",
"\n",
"#Demand limits:\n",
"\n",
"model += T1 <= 15000, \"T1_DemandLimit\"\n",
"model += T2 <= 16000, \"T2_DemandLimit\"\n",
"model += T3 <= 12000, \"T3_DemandLimit\"\n",
"\n",
"#Non-Negativity constraints\n",
"model += T1 >= 0 \n",
"model += T2 >= 0 \n",
"model += T3 >= 0 \n",
"\n",
"model.solve()\n",
"\n",
"for v in model.variables():\n",
" print(v.name, \"=\", v.varValue)\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "0a67ab32",
"metadata": {},
"outputs": [
{
"ename": "",
"evalue": "",
"output_type": "error",
"traceback": [
"\u001b[1;31mRunning cells with 'Python 3.11.0 64-bit' requires ipykernel package.\n",
"\u001b[1;31mRun the following command to install 'ipykernel' into the Python environment. \n",
"\u001b[1;31mCommand: '\"c:/Users/Ali Ibrahim/AppData/Local/Programs/Python/Python311/python.exe\" -m pip install ipykernel -U --user --force-reinstall'"
]
}
],
"source": [
"Result - Optimal solution found\n",
"\n",
"Objective value: 1840.00000000\n",
"Enumerated nodes: 0\n",
"Total iterations: 0\n",
"Time (CPU seconds): 0.01\n",
"Time (Wallclock seconds): 0.01\n",
"\n",
"Option for printingOptions changed from normal to all\n",
"Total time (CPU seconds): 0.01 (Wallclock seconds): 0.01\n",
"\n",
"Tool1 = 0.0\n",
"Tool2 = 4000.0\n",
"Tool3 = 12000.0\n",
"PS C:\\Users\\Ali Ibrahim\\Downloads\\7159CEM-Portfolio-main>"
]
},
{
"cell_type": "markdown",
"id": "524021a2",
"metadata": {},
"source": [
"# Conclusion\n",
"By setting up the equations of optimized tools problem we have managed to set a program by usimg the pulp package. We were able to run optimization for the profit formula and the results where as follows: \n",
"\n",
"Maximum Profit : 1840\n",
"Tool1 : 0\n",
"Tool2 : 4000\n",
"Tool3: 12000\n",
"\n",
"The most critical resource in this problem is the steel as in the program it shows if you reduce the amount of steel available the profit reduces by more than it does for molding hours and assembly machine. \n",
"\n",
"As supported by the results below:\n",
"\n",
"Setting steal to 1000 instead of 10000:\n",
"model += 1*T1 + 0.7 * T2 + 0.6 * T3 <= 1000, \"Steel\"\n",
"model += 1*T1 + 1 * T2 + 1 * T3 <= 20000, \"Molding_machine\"\n",
"model += 0.3*T1 + 0.5 * T2 + 0.4 * T3 <= 9000, \"Assembly_machine\"\n",
"Objective value: 199.93000000\n",
"\n",
"Setting Molding_machine to 2000 instead of 20000:\n",
"model += 1*T1 + 0.7 * T2 + 0.6 * T3 <= 10000, \"Steel\"\n",
"model += 1*T1 + 1 * T2 + 1 * T3 <= 2000, \"Molding_machine\"\n",
"model += 0.3*T1 + 0.5 * T2 + 0.4 * T3 <= 9000, \"Assembly_machine\"\n",
"\n",
"Setting Assembly machine to 900 instead of 9000:\n",
"model += 1*T1 + 0.7 * T2 + 0.6 * T3 <= 10000, \"Steel\"\n",
"model += 1*T1 + 1 * T2 + 1 * T3 <= 20000, \"Molding_machine\"\n",
"model += 0.3*T1 + 0.5 * T2 + 0.4 * T3 <= 900, \"Assembly_machine\"\n",
"Objective value: 390.00000000\n",
"\n",
"Please refer LP.py for python code. "
]
},
{
"cell_type": "markdown",
"id": "57a444ba",
"metadata": {},
"source": [
"# List of references\n",
"\n",
"Tools options for solving optimization problems - Analytics Vidhya. (2021, December 12). Medium. https://medium.com/analytics-vidhya/tools-options-for-solving-optimization-problems-16b6ebde5d72\n",
"\n",
"Labonne, M. (2022, March 2). Introduction to Linear Programming in Python. Maxime Labonne. https://mlabonne.github.io/blog/linearoptimization/"
]
},
{
"cell_type": "markdown",
"id": "a681afb7",
"metadata": {},
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.11.0 64-bit",
"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.11.0"
},
"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": "7eadeba057ae704edbaf2a5d36e1a3c010b6c58c5e264dda84bd57b2200bd279"
}
}
},
"nbformat": 4,
"nbformat_minor": 5
}