Skip to content

Instantly share code, notes, and snippets.

@radzionc
Created March 25, 2019 08:49
Show Gist options
  • Save radzionc/52aa64b20d51f7b8755961c847e8b683 to your computer and use it in GitHub Desktop.
Save radzionc/52aa64b20d51f7b8755961c847e8b683 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Primal: 4.75\n"
]
}
],
"source": [
"c = [2, 3, 0, 0, 0]\n",
"A = [\n",
" [4, 8, 1, 0, 0],\n",
" [2, 1, 0, 1, 0],\n",
" [3, 2, 0, 0, 1]\n",
"]\n",
"b = [12, 3, 4]\n",
"\n",
"primal = to_objective_function_value(c, simplex(c, A, b))\n",
"print('Primal: ', primal)"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Dual: 4.75\n"
]
}
],
"source": [
"c = [12, 3, 4, 0, 0]\n",
"A = [\n",
" [-4, -2, -3, 1, 0],\n",
" [-8, -1, -2, 0, 1]\n",
"]\n",
"b = [-2, -3]\n",
"\n",
"dual = to_objective_function_value(c, dual_simplex(c, A, b))\n",
"print('Dual: ', dual)"
]
}
],
"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.7.2"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment