{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "![MOSEK ApS](https://www.mosek.com/static/images/branding/webgraphmoseklogocolor.png )" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Equilibrium of a system of weights connected by strings/springs\n", "\n", "In this notebook we show how to solve the following problem: Find the equlibrium of a system of masses connected by a system of strings, with some masses being assigned fixed coordinates (attached to the wall, say). See the next picture.\n", "\n", "![](basic.png)\n", "\n", "Suppose we have $n$ masses with weights $w_1,\\ldots,w_n$, and the length of the string between $i$ and $j$ is $\\ell_{ij}$ for some set $L$ of pairs of indices $(i,j)$ (we assume $\\ell_{ij}$ is not defined if there is no connection). The strings themselves have no mass. We also have a set $F$ of indices such that the $i$-th point is fixed to have coordinates $f_i$ if $i\\in F$. The equilibrium of the system is a configuration which minimizes potential energy. With this setup we can write our problem as:\n", "\n", "\$$\n", "\\begin{array}{ll}\n", "minimize & g\\cdot \\sum_i w_ix_i^{(2)} \\\\\n", "s.t. & \\|x_i-x_j\\|\\leq \\ell_{ij},\\ ij\\in L \\\\\n", " & x_i = f_i,\\ i\\in F\n", "\\end{array}\n", "\$$\n", "\n", "where $x\\in (\\mathbf{R}^n)^2$, $x_i^{(2)}$ denotes the second (vertical) coordinate of $x_i$ and $g$ is the gravitational constant.\n", "\n", "Here is a sample problem description." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "w = [0.0, 1.1, 2.2, 0.0, 2.1, 2.2, 0.2]\n", "l = {(0,1): 1.0, (1,2): 1.0, (2,3): 1.0, (1,4): 1.0, (4,5): 0.3, (5,2): 1.0, (5,6): 0.5, (1,3): 8.0}\n", "f = {0: (0.0,1.0), 3: (2.0,1.0)}\n", "g = 9.81" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now we can formulate the problem using Mosek Fusion:" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "from mosek.fusion import *\n", "\n", "# w - masses of points\n", "# l - lengths of strings\n", "# f - coordinates of fixed points\n", "# g - gravitational constant\n", "def stringModel(w, l, f, g):\n", " n, m = len(w), len(l)\n", " starts = [ lKey[0] for lKey in l.keys() ]\n", " ends = [ lKey[1] for lKey in l.keys() ]\n", "\n", " M = Model(\"strings\")\n", "\n", " # Coordinates of points\n", " x = M.variable(\"x\", [n, 2])\n", "\n", " # A is the signed incidence matrix of points and strings\n", " A = Matrix.sparse(m, n, list(range(m))+list(range(m)), starts+ends, [1.0]*m+[-1.0]*m)\n", "\n", " # ||x_i-x_j|| <= l_{i,j}\n", " c = M.constraint(\"c\", Expr.hstack(Expr.constTerm(list(l.values())), Expr.mul(A, x)), \n", " Domain.inQCone() )\n", "\n", " # x_i = f_i for fixed points\n", " for i in f:\n", " M.constraint(x.slice([i,0], [i+1,2]), Domain.equalsTo(list(f[i])).withShape([1,2]))\n", "\n", " # sum (g w_i x_i_2)\n", " M.objective(ObjectiveSense.Minimize, \n", " Expr.mul(g, Expr.dot(w, x.slice([0,1], [n,2]))))\n", "\n", " # Solve\n", " M.solve()\n", " if M.getProblemStatus(SolutionType.Interior) == ProblemStatus.PrimalAndDualFeasible:\n", " return x.level().reshape([n,2]), c.dual().reshape([m,3])\n", " else:\n", " return None, None\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Here is a quick description of how we use vectorization to deal with all the conic constraints in one go. The matrix $A$ is the incidence matrix between the masses and the strings, with coefficients $+1, -1$ for the two endpoints of each string. It is chosen so that the product $Ax$ has rows of the form\n", "\n", "$$\n", "(x_i^{(1)} - x_j^{(1)}, x_i^{(2)} - x_j^{(2)})\n", "$$\n", "\n", "for all pairs $i,j$ for which $\\ell_{ij}$ is bounded. Stacking the values of $\\ell$ in the left column produces a matrix with each row of the form\n", "\n", "$$\n", "(\\ell_{ij}, x_i^{(1)} - x_j^{(1)}, x_i^{(2)} - x_j^{(2)})\n", "$$\n", "\n", "and a conic constraint is imposed on all the rows, as required.\n", "\n", "The objective and linear constraints show examples of slicing the variable $x$.\n", "\n", "The function returns the coordinates of the masses and the values of the dual conic variables. A zero dual value indicates that a particular string is hanging loose, and a nonzero value means it is fully stretched. \n", "\n", "All we need now is to define a display function and we can look at some plots." ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "%matplotlib inline\n", "# x - coordinates of the points\n", "# c - dual values of string length constraints\n", "# d - pairs of points to connect\n", "def display(x, c, d):\n", " import matplotlib.pyplot as plt\n", " fig, ax = plt.subplots()\n", " # Plot points\n", " ax.scatter(x[:,0], x[:,1], color=\"r\")\n", " # Plot fully stretched strings (nonzero dual value) as solid lines, else dotted lines\n", " for i in range(len(c)):\n", " col = \"b\" if c[i][0] > 1e-4 else \"b--\"\n", " ax.plot([x[d[i][0]][0], x[d[i][1]][0]], [x[d[i][0]][1], x[d[i][1]][1]], col)\n", " ax.axis(\"equal\")\n", " plt.show()" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAX8AAAD8CAYAAACfF6SlAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAIABJREFUeJzt3Xt4VNW5x/Hvi9wMIlqxVRQIKBdRqVqO9yoVe2r1KCqgeKISL02tUuuxNy0FqxVrr9pWa8ULARqVijdUlKqI12INLQqoKCBBLireEAyCkHX+eCcSISGTzGTvmdm/z/PMMzN7trNfJuO796z1rrUshICIiCRLq7gDEBGR6Cn5i4gkkJK/iEgCKfmLiCSQkr+ISAIp+YuIJJCSv4hIAin5i4gkkJK/iEgCtY47gIZ07tw5FBcXxx2GiEhemT179nshhF0b2y9nk39xcTGVlZVxhyEiklfMrCqd/dTsIyKSQEr+IiIJpOQvIpJASv4iIgmk5C8ikkBK/iIiCZSV5G9mt5vZu2Y2r4HXzcz+ZGYLzexlMzs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jbLzKI6QewBvFXn+TK2/tJ+vk8IYSOwGtglkujqiSGlvjgBhqR++k8xs67RhNYk6f47csFhZvaSmT1iZvvGHUyqufFA4IUtXsqpz3QbcUKOfaZNpZW86mFmjwO71fPSqCa8TbcQwgoz6wnMMLO5IYRF2YmwQfVdwW9ZzpXOPi0tnRgeBO4MIaw3swvwXyvHtHhkTZMLn2U6/o0P+V9rZscD9wO94grGzHYA7gEuCSF8vOXL9fwnsXymjcSZU59pc+jKvx4hhGNDCPvVc3sAeKf2Z2jq/t0G3mNF6n4xMBO/emhpy4C6V8h7Aisa2sfMWgOdiL7JoNE4QwjvhxDWp57eAnwtotiaIp3PO3YhhI9DCGtTj6cBbcyscxyxmFkbPKFWhBDurWeXnPhMG4szlz7T5lLyb7qpwIjU4xHAA1vuYGY7m1m71OPOwBHAKxHE9iLQy8x6mFlbvEN3y0qjuvEPBWaEVA9WhBqNc4t23pPwdtdcMxU4O1WhciiwurZJMJeY2W61/TpmdjD+//37McRhwG3AqyGEPzSwW+yfaTpx5spnmgk1+zTdtcDfzew8YCkwDMDMBgAXhBDOB/YBbjazGvxLcW0IocWTfwhho5mNBKbjFTW3hxDmm9lVQGUIYSr+pZ5kZgvxK/7hLR1XM+O82MxOAjam4iyNOk4zuxOv6uhsZsuAK4A2qX/DX4FpeHXKQqAaOCfqGNOMcyjwPTPbCKwDhsdwwge/CDoLmGtmc1LbfgZ0qxNrLnym6cSZK59ps2mEr4hIAqnZR0QkgZT8RUQSSMlfRCSBlPxFRBJIyV9EJIGU/EVEEkjJX0QkgZT8RUQS6P8BtCToTxvdspMAAAAASUVORK5CYII=\n", "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "x,c = stringModel(w, l, f, g)\n", "\n", "if x is not None:\n", " display(x, c, list(l.keys()))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "How about we find a discrete approximation to the [catenary](#https://en.wikipedia.org/wiki/Catenary):" ] }, { "cell_type": "code", "execution_count": 8, "metadata":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LiVDhGhvazXIbsE9SWhelDY5o7UwXfW3rlcATCW1RdDG10xhznTHmfULBeX2S2ubVazuNMUcBo621jyWzYVHE+v/+QmdI7hFjzOgo1xMtk06Ci/nnyRneHA88k6jGZFK4x3IiVCw1iZYObYhVzG01xlwKVAA/S2iLooupndbae621BwL/Dfwg4a3qrsd2GmNygDuBbyetRbsXy2v6T2CctfYIoBb3r+Jk6utJcJcADxhjBie4XdH05Wf/YuARa21HohqTSeEe64lQowGMMXnAIGBzUloXpQ2OaO1MFzG11RhTBdwMnGut3ZWktnn19TV9GDg/oS2Krrd2lgCHAc8ZYz4EjgPmpmhStdfX1Fq7yfP/+7fApCS1zStuJ8ElQV/+nV5MAodkgIyaUM0jdLrTeNzJivKImuvwT6jOScd2empnkdoJ1Vhe06MITRJNSPN2TvC8/wWgLh3bGVH/HKmbUI3lNd3f8/4FwKI0bedZwIPO+8MIDY3sk45tdeomAh/i3GeUsPak4h/WXrx45wDvOmFzs/PYNEI9SoBC4C/ASuBV4IA0befRhH7L7wQ2AfVp/JrWAuuBpc7b3DRt511AvdPGZ3sK1VS2M6I2ZeEe42v6E+c1Xea8poekaTsN8EtgOfAmcHG6vqbOx7cAtye6LbpDVUQkgDJpzF1ERGKkcBcRCSCFu4hIACncRUQCSOEuIhJACncRkQBSuIuIBJDCXUQkgP4fR6bVmpXv/3sAAAAASUVORK5CYII=\n", "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "n = 1000\n", "w = [1.0]*n\n", "l = {(i,i+1): 1.0/n for i in range(n-1)}\n", "f = {0: (0.0,1.0), n-1: (0.7,1.0)}\n", "g = 9.81\n", "\n", "x,c = stringModel(w, l, f, g)\n", "if x is not None:\n", " display(x, c, list(l.keys()))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We can also have more suspension points and more complicated shapes:" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAD8C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c4MGxLF52BGH2lgkr3KNxU7hHzvLlzrVs6VynThX+40pKKC31PQOHDNn+Ops2Offssz7cwbk2bZx74ar3nWvSxDlwYznPgXN90v7lSp9Nze6FiSTccNcVqklgzz3hqafg00/91YSSOtau9U0qLVpsf50GDeCCC2DOHN88k50NTcaNhpISHqE/fXmWbkzjn6UXUG+IxmpJFgr3JHHaab6L8733wtSpQVcjsbJ6tb+vLtzLmfn5ed97D04ufpZnuIABPEIDNjOR02nEJo3VkkQU7knk/vthn32gb1/48cegq5FYWLPG3+9ei6tKNm6EK5o+TT+epROf8i7H04If/IsaqyVpKNyTSNOmMGYMLFvmez5I8isP93CO3MEfmB91FIxY35fr6z/Ix3TlcGb4FzVWS1JRuCeZrl391HzPP+9vktxq0yzz1lv+wrevvoJ//xvufTqdBpltNP9pklK4J6HBg+GII6B/fzWhJrtwmmXKyuD22317e+vWUFgIZ56JxmpJcgr3JFS/vh9crLTUt7+XlgZdkURLebjvumvVr69e7YcTuPVWOP98PwVpdnbs6pPgKNyTVIcO8I9/wPvvw99b3gX16mlS4SS0erUfKbR+/W1fmznTN8O89x48/jg884w/LyOpQeGexC6sX8BZaS9x84/XMdsdokmFk9CaNds2yTgHTzyxdfiB//wH/vpX37QuqUPhnsTs5nyeKL2EZqyjG/9hBemaVDjJrFnz25OpJSVw4YVw2WVw3HEwezYcdlhw9UlwFO7JbPFidmcN13I/JTThdF5mA410ljWJrF69NdwXLIA//MF3h73tNj9kb236v0tyUbgns9AFKfncxbP0ZTqH04exbGnXPuDCJFLKm2VefBFycvxEG2+8Abfc4k+zSOrSrz+ZVZhU+ALG8BBXMZEzyMt6W+O/J4nVq32/9bPO8kNAf/KJhusVT+GezHJz/YUpmZlgxlWZk7jljDn8c9re3HRT0MVJXS1dCj/84AeM698fpk3T6AGyVRUdqCSp5Ob+5uKUoQ5WXekHGGvZEm68McDaZIdNmwbnnOMfn3++JmuRbenIPcWY+f7vvXtvnWRbEodzfvat447b2mf9xBODrUnik8I9BdWr5y9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kJPpwNtY1xjpITzewW4A38QsyGWxUVYOPt6KfCoc+4HAOfcyhjXGEnh7K8Dmoce7wIsi2F9YQsy3Fs555YDhO73qG5lM+uK/0v6dQxqi5Q2wJIKz5eGllW5jnNuC7AW2D0m1UVWOPta0V+AN6JaUfTUuK9m1hlo55x7NZaFRUE4v9dsINvMPjSz6WbWI2bVRV44+zsUON/MlgKvAwNiU1rtRHWCbDN7F9izipfya7md1sBzwIXOubJI1BYjVR2BV+6eFM46iSDs/TCz84Ec4OioVhQ91e6rmdUDHgD6xaqgKArn91of3zRzDP7b2AdmdpBz7sco1xYN4exvH+Bp59zfzexw4LnQ/sZVNkU13J1z3bf3mpmtMLPWzrnlofCu8qucmTUHXgNuds5Nj1Kp0bIUaFfheVu2/QpXvs5SM6uP/5q3JjblRVQ4+4qZdcf/cT/aObcxRrVFWk372gw4CJgaamHbE5hkZqc55wpjVmVkhPsZnu6c2wx8a2bz8GE/MzYlRlQ4+/sXoAeAc+4jM2uMH3cmrpqjgmyWmQRcGHp8IfBy5RXMrCHwEvCsc25CDGuLlJlARzNrH9qX3vj9rqjiv8PZwHsudKYmwdS4r6GmiieA0xK8XbbafXXOrXXOtXTOZTnnsvDnFxIx2CG8z/BE/MlyzKwlvpnmm5hWGTnh7O9i4HgAM9sfaAwUx7TKcAR4Vnp3YDKwIHTfIrQ8BxgVenw+sBn4tMKtU9BnoWu5nz2B+fhzBfmhZbfj/7OD/2BMABYCHwMdgq45ivv6LrCiwu9yUtA1R2tfK607lQTtLRPm79WA+4Evgc+B3kHXHOX9PQD4EN+T5lPgxKBrruqmK1RFRJKQrlAVEUlCCncRkSSkcBcRSUIKdxGRJKRwFxFJQgp3EZEkpHAXEUlCCncRkST0/0DHejllrrA0AAAAAElFTkSuQmCC\n", "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "n = 20\n", "w = [1.0]*n\n", "l = {(i,i+1): 0.09 for i in range(n-1)}\n", "l.update({(5,14): 0.3})\n", "f = {0: (0.0,1.0), 13: (0.5,0.9), 17: (0.7,1.1)}\n", "g = 9.81\n", "\n", "x,c = stringModel(w, l, f, g)\n", "if x is not None:\n", " display(x, c, list(l.keys()))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Duality and feasibility\n", "\n", "The dual problem is as follows:\n", "\n", "\$$\n", "\\begin{array}{ll}\n", "maximize & -\\sum_{ij\\in L}\\ell_{ij}y_{ij} - \\sum_{i\\in F}f_i\\circ z_i\\\\\n", "s.t. & y_{ij}\\geq \\|v_{ij}\\|,\\ ij\\in L \\\\\n", " & \\sum_{j~:~ij\\in L} v_{ij}\\mathrm{sgn}_{ij} + \\left(\\begin{array}{c}0\\\\ gw_i\\end{array}\\right) +z_i = 0, \\ i=1,\\ldots,n\n", "\\end{array}\n", "\$$\n", "\n", "where $\\mathrm{sgn}_{ij}=+1$ if $i>j$ and $-1$ otherwise and $\\circ$ is the dot product. The variables are $(y_{ij},v_{ij})\\in \\mathbf{R}\\times\\mathbf{R}^2$ for $ij\\in L$ and $z_i\\in\\mathbf{R}^2$ for $i\\in F$ (we assume $z_i=0$ for $i\\not\\in F$).\n", "\n", "Obviously (!) the linear constraints describe the equilibrium of forces at every mass. The ingredients are: the vectors of forces applied through adjacent strings ($v_{ij}$), gravity, and the attaching force holding a fixed point in its position. By proper use of vectorization this is much easier to express in Fusion than it looks:" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [], "source": [ "def dualStringModel(w, l, f, g):\n", " n, m = len(w), len(l)\n", " starts = [ lKey[0] for lKey in l.keys() ]\n", " ends = [ lKey[1] for lKey in l.keys() ]\n", "\n", " M = Model(\"dual strings\")\n", "\n", " x = M.variable(Domain.inQCone(m,3)) #(y,v)\n", " y = x.slice([0,0],[m,1])\n", " v = x.slice([0,1],[m,3])\n", " z = M.variable([n,2])\n", "\n", " # z_i = 0 if i is not fixed\n", " for i in range(n):\n", " if i not in f:\n", " M.constraint(z.slice([i,0], [i+1,2]), Domain.equalsTo(0.0))\n", "\n", " B = Matrix.sparse(m, n, list(range(m))+list(range(m)), starts+ends, [1.0]*m+[-1.0]*m).transpose()\n", " w2 = Matrix.sparse(n, 2, range(n), [1]*n, [-wT*g for wT in w])\n", "\n", " # sum(v_ij *sgn(ij)) + z_i = -(0, gw_i) for all vertices i\n", " M.constraint(Expr.add( Expr.mul(B, v), z ), Domain.equalsTo(w2))\n", "\n", " # Objective -l*y -fM*z\n", " fM = Matrix.sparse(n, 2, list(f.keys())+list(f.keys()), [0]*len(f)+[1]*len(f), \n", " [pt[0] for pt in f.values()] + [pt[1] for pt in f.values()])\n", " \n", " M.objective(ObjectiveSense.Maximize, Expr.neg(Expr.add(Expr.dot(list(l.values()), y),Expr.dot(fM, z))))\n", " M.solve()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Let us quickly discuss the possible situations regarding feasibility:\n", "\n", "* The system has an equilibrium --- the problem is **primal feasible** and **dual feasible**.\n", "* The strings are too short and it is impossible to stretch the required distance between fixed points --- the problem is **primal infeasible**.\n", "* The system has a component that is not connected to any fixed point, hence some masses can keep falling down indefinitely, causing the problem **primal unbounded**. Clearly the forces within such component cannot be balanced, so the problem is **dual infeasible**." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Springs\n", "\n", "We can extend this to consider infinitely strechable springs instead of fixed-length strings connecting the masses. The next model appears in [Applications of SOCP](#http://stanford.edu/~boyd/papers/pdf/socp.pdf) by Lobo, Boyd, Vandenberghe, Lebret. We will now interpret $\\ell_{ij}$ as the base length of the spring and assume that the elastic potential energy stored in the spring at length $x$ is \n", "\n", "$$\n", "E_{ij}=\\left\\{\\begin{array}{ll}0 & x\\leq \\ell_{ij}\\\\ \\frac{k}{2}(x-\\ell_{ij})^2 & x>\\ell_{ij}\\end{array}\\right.\n", "$$\n", "\n", "That leads us to consider the following second order cone program minimizing the total potential energy:\n", "\n", "\$$\n", "\\begin{array}{ll}\n", "minimize & g\\cdot \\sum_i w_ix_i^{(2)} + \\frac{k}{2}\\sum_{ij\\in L} t_{ij}^2 \\\\\n", "s.t. & \\|x_i-x_j\\|\\leq \\ell_{ij}+t_{ij},\\ ij\\in L \\\\\n", " & 0\\leq t_{ij},\\ ij\\in L \\\\\n", " & x_i = f_i,\\ i\\in F\n", "\\end{array}\n", "\$$\n", "\n", "If $t$ denotes the vector of $t_{ij}$ then using a rotated quadratic cone for $(1,T,t)$:\n", "\n", "$$\n", "2\\cdot 1\\cdot T\\geq \\|t\\|^2\n", "$$\n", "\n", "will place a bound on $\\frac12\\sum t_{ij}^2$. We now have a simple extension of the first model." ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [], "source": [ "# w - masses of points\n", "# l - lengths of strings\n", "# f - coordinates of fixed points\n", "# g - gravitational constant\n", "# k - stiffness coefficient\n", "def elasticModel(w, l, f, g, k):\n", " n, m = len(w), len(l)\n", " starts = [ lKey[0] for lKey in l.keys() ]\n", " ends = [ lKey[1] for lKey in l.keys() ]\n", "\n", " M = Model(\"strings\")\n", " x = M.variable(\"x\", [n, 2]) # Coordinates\n", " t = M.variable(m, Domain.greaterThan(0.0)) # Streching\n", "\n", " T = M.variable(1) # Upper bound\n", " M.constraint(Expr.vstack(T, Expr.constTerm(1.0), t), Domain.inRotatedQCone())\n", "\n", " # A is the signed incidence matrix of points and strings\n", " A = Matrix.sparse(m, n, list(range(m))+list(range(m)), starts+ends, [1.0]*m+[-1.0]*m)\n", "\n", " # ||x_i-x_j|| <= l_{i,j} + t_{i,j}\n", " c = M.constraint(\"c\", Expr.hstack(Expr.add(t, Expr.constTerm(list(l.values()))), Expr.mul(A, x)), \n", " Domain.inQCone() )\n", "\n", " # x_i = f_i for fixed points\n", " for i in f:\n", " M.constraint(x.slice([i,0], [i+1,2]), Domain.equalsTo(list(f[i])).withShape([1,2]))\n", "\n", " # sum (g w_i x_i_2) + k*T\n", " M.objective(ObjectiveSense.Minimize, \n", " Expr.add(Expr.mul(k,T), Expr.mul(g, Expr.dot(w, x.slice([0,1], [n,2])))))\n", "\n", " # Solve\n", " M.solve()\n", " if M.getProblemStatus(SolutionType.Interior) == ProblemStatus.PrimalAndDualFeasible:\n", " return x.level().reshape([n,2]), c.dual().reshape([m,3])\n", " else:\n", " return None, None" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAD8CAYAAACMwORRAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAIABJREFUeJzt3Xl8VNXdx/HPj7CEAIIQqCyGoAKWqlVL1frUpUUUN2iBWmi01VJRsY/W3TaVIja2olZrH0Hjrk3dilbqVtxwaYslVlzYBJEERGVfZAiQcJ4/zgRCmCST5M7cycz3/XrlNTN3bu78yCt8c+65555jzjlERCS9tAq7ABERCZ7CXUQkDSncRUTSkMJdRCQNKdxFRNKQwl1EJA0p3EVE0pDCXUQkDSncRUTSUOuwPjg3N9fl5+eH9fEiIi3SO++8s8Y5172h/UIL9/z8fEpLS8P6eBGRFsnMyuLZT90yIiJpSOEuIpKGFO4iImlI4S4ikoYU7iIiaUjhLiKShhTuIiJpSOEuIpKGFO4iEpySEsjPh1at/GNJSdgVZazQ7lAVkTRTUgLjx0Mk4l+XlfnXAAUF4dWVodRyF5FgFBZCJMIonuRHRFvskYjfLkmnlruIBKO8HAe8yKm0Yuce2yX51HIXkWDk5fEmxxGhA735dI/tknxquYtIMIqKmPqTtmRV7aAHq/y2nBwoKgq3rgylcBeRQHw+pIDp7KRn1he0qtoJffv6YNfF1FAo3EUkEPfdB5VVreh1VE9o3xNmLQu7pIymcBeRZqushLvvhpNOgh07wq5GQBdURSQAzz0Hy5fDhAlhVyLVFO4i0mxTp0Lv3nDmmWFXItUU7iLSLIsXw8yZcMEF0FodvSlD4S4izXLXXT7Uf/azsCuRmhTu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{}, "output_type": "display_data" } ], "source": [ "n = 20\n", "w = [1.0]*n\n", "l = {(i,i+1): 0.09 for i in range(n-1)}\n", "l.update({(5,14): 0.3})\n", "f = {0: (0.0,1.0), 13: (0.5,0.9), 17: (0.7,1.1)}\n", "g = 9.81\n", "k = 800\n", "\n", "x, c = elasticModel(w, l, f, g, k)\n", "if x is not None:\n", " display(x, c, list(l.keys()))" ] }, { "cell_type": "markdown", "metadata": { "collapsed": true }, "source": [ "
This work is licensed under a Creative Commons Attribution 4.0 International License. The **MOSEK** logo and name are trademarks of Mosek ApS. The code is provided as-is. Compatibility with future release of **MOSEK** or the Fusion API are not guaranteed. For more information contact our [support](mailto:support@mosek.com). " ] } ], "metadata": { "anaconda-cloud": {}, "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.4" } }, "nbformat": 4, "nbformat_minor": 1 }