Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions t9_dual_approximation_prob1.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Dual Approximation"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Problem 1"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Assume that you are the project manger of a software development project, which has been estimeted for \\\\$40,000 salary + operational cost and you are going to come up with a team of 12 which consisists of interns, engineers, senior engineers and team leaders. Project has been budgeted for 1000 engineering hours and you can assume that as a thumb rule, an intern would take 1h 15min for a work completed by and engineer and senior engineer, team leader would take 45 and 30 mins respectively. So, the operational cost of the project is propotional to the norm of the group. It is expected to pay \\\\$25, \\\\$35, \\\\$45, \\\\$55 per hour for intern, engineer, senior engineer and team leader respectively. using dual approximation come up with a suitable team structure to minimize the operational cost of the project."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.5"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
187 changes: 187 additions & 0 deletions t9_dual_approximation_prob1_solution.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#Dual Approximation"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Dual Approximation"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Problem1 - solution"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"According to the description, company could pay $$ \\frac{$40,000}{1000} = $40 $$ per engineering hour."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Lets, assume that the number of interns, engineers, senior engineers and team leaders are x1, x2, x3, x4 respectively. "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"As per the description, completed project hours per hour would be 1/1.25 = 0.8, 1/1 = 1, 1/0.75 = 4/3 and 1/0.5 = 2 for intern, engineer, senior engineer and team leader respectively."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"So, the number of project hours completed by the team per hour would be, $$ x1\\times 0.8 + x2\\times1 + x3\\times\\frac{4}{3} + x4\\times2$$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"So, the company can allocate following amount to pay for the team per an hour$$ $30\\times(1\\times 0.8 + x2\\times1 + x3\\times\\frac{4}{3} + x4\\times2) = x1\\times 24 + x2\\times30 + x3\\times40 + x4\\times60 $$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"According to salary rates, company would have to pay, $$ x1\\times25 + x2\\times35 + x3\\times45 + x4\\times55 $$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"These two values, should be Equal, then the first constraint should be,"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$ \\begin{align}\n",
" x1\\times 24 + x2\\times30 + x3\\times 40 + x4\\times60 &= x1\\times25 + x2\\times35 + x3\\times45 + x4\\times55 \\nonumber \\\\\n",
" x1\\times 1 + x2\\times5 + x3\\times5 + x4\\times-5 &= 0\n",
"\\end{align}\n",
"$$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The second constraint of the problem should be, $$ x1 + x2 + x3 + x4 = 12 $$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"from the constrains, we can come up with below equations,"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$$\n",
"\\langle x, y_1 \\rangle = 0\\\\\n",
"\\langle x, y_2 \\rangle = 12\n",
"$$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"According to the dual approximation theorm,\n",
"$$\n",
"\\begin{equation*}\n",
"\\begin{bmatrix} \\langle y1,y1\\rangle & \\langle y1,y2\\rangle \\\\ \\langle y2,y1\\rangle & \\langle y2,y2\\rangle \\end{bmatrix}\n",
"\\begin{bmatrix} c1 \\\\ c2 \\end{bmatrix}\n",
"= \\begin{bmatrix} \\langle x, y_1 \\rangle \\\\ \\langle x, y_2 \\rangle \\end{bmatrix}\n",
"\\end{equation*}\n",
"$$"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[3.13432836 2.05970149 2.05970149 4.74626866]\n"
]
}
],
"source": [
"#python implementation of this problem would be like this\n",
"import numpy as np\n",
"\n",
"c1 = np.array([1, 1, 1, 1])\n",
"\n",
"projHrscompletedbyteamPerHr = np.array([ 1./1.25, 1./1., 1/0.75, 1/0.5 ])\n",
"affordableHourlyCost = 30 * projHrscompletedbyteamPerHr\n",
"actualTeamHourLyCost = np.array([25, 35, 45, 55])\n",
"c2 = affordableHourlyCost - actualTeamHourLyCost\n",
"\n",
"grammian = np.array([[c1 @ c1, c1 @ c2], \n",
" [c2 @ c1, c2 @ c2]])\n",
"\n",
"b = np.array([[12], [0]])\n",
"\n",
"c = np.linalg.inv(grammian) @ b\n",
"\n",
"x = c[0,0]*c1 + c[1,0]*c2\n",
"\n",
"print(x)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"So, in order to not to exceed the limit, I would go with a team of 4 interns, 2 Engineers, 2 Senior Engineers and 4 Project Managers to minimize the overall operation cost of the project."
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.5"
}
},
"nbformat": 4,
"nbformat_minor": 4
}