Created
April 7, 2019 11:29
-
-
Save radzionc/845033eb8ceae194b640fa6cb75a22dc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 44, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"def get_entering_variable_position(ws):\n", | |
" ws_copy = ws.copy()\n", | |
" ws_copy.sort(key=lambda w: w[1])\n", | |
" return ws_copy[-1][0]" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 45, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"(2, 0)" | |
] | |
}, | |
"execution_count": 45, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"costs = [\n", | |
" [ 2, 2, 2, 1],\n", | |
" [10, 8, 5, 4],\n", | |
" [ 7, 6, 6, 8]\n", | |
"]\n", | |
"supply = [30, 70, 50]\n", | |
"demand = [40, 30, 40, 40]\n", | |
"bfs = north_west_corner(supply, demand)\n", | |
"us, vs = get_us_and_vs(bfs, costs)\n", | |
"ws = get_ws(bfs, costs, us, vs)\n", | |
"can_be_improved(ws)\n", | |
"\n", | |
"get_entering_variable_position(ws)" | |
] | |
} | |
], | |
"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.6.5" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment