{"id":279874,"date":"2016-10-25T10:05:02","date_gmt":"2016-10-25T06:05:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=279874"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=279874","title":{"rendered":"\u041c\u043e\u0434\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u0438\u043d\u0435\u043c\u0430\u0442\u0438\u043a\u0438 \u2014 \u044d\u0442\u043e \u043d\u0435 \u0441\u043b\u043e\u0436\u043d\u043e"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/16b\/d26\/958\/16bd269583c3465c8c35adf6e56edcf2.PNG\" width=\"320\" align=\"left\"\/>\u041c\u043d\u0435 \u0434\u0430\u0432\u043d\u043e \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0437\u0430\u043d\u044f\u0442\u044c\u0441\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435\u043c \u0440\u043e\u0431\u043e\u0442\u043e\u0432, \u043d\u043e \u0432\u0441\u0435\u0433\u0434\u0430 \u043d\u0435 \u0445\u0432\u0430\u0442\u0430\u0435\u0442 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u044b\u0445 \u0434\u0435\u043d\u0435\u0433, \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0438\u043b\u0438 \u043c\u0435\u0441\u0442\u0430. \u041f\u043e \u044d\u0442\u043e\u043c\u0443 \u044f \u0441\u043e\u0431\u0440\u0430\u043b\u0441\u044f \u043f\u0438\u0441\u0430\u0442\u044c \u0438\u0445 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0435 \u043c\u043e\u0434\u0435\u043b\u0438!<br \/>  \u041c\u043e\u0449\u043d\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0435 \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c, \u043b\u0438\u0431\u043e \u0441\u043b\u043e\u0436\u043d\u043e \u0441\u0442\u044b\u043a\u0443\u044e\u0442\u0441\u044f \u0441\u043e \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u043c\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430\u043c\u0438 (<a href=\"https:\/\/habrahabr.ru\/search\/?q=%5BModelica%5D\">Modelica<\/a>), \u043b\u0438\u0431\u043e \u043f\u0440\u043e\u043f\u0440\u0438\u0435\u0442\u0430\u0440\u043d\u044b (Wolfram Mathematica, \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0421\u0410\u041f\u0420), \u0438 \u044f \u0440\u0435\u0448\u0438\u043b \u0434\u0435\u043b\u0430\u0442\u044c \u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434 \u043d\u0430 <a href=\"http:\/\/julialang.org\/\">Julia<\/a>. \u041f\u043e\u0442\u043e\u043c \u0432\u0441\u0435 \u043d\u0430\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0441\u0442\u044b\u043a\u043e\u0432\u0430\u0442\u044c \u0441 \u0441\u0435\u0440\u0432\u0438\u0441\u0430\u043c\u0438 <a href=\"https:\/\/github.com\/jdlangs\/RobotOS.jl\">ROS<\/a>.<br \/>  \u0411\u0443\u0434\u0435\u043c \u0441\u0447\u0438\u0442\u0430\u0442\u044c, \u0447\u0442\u043e \u043d\u0430\u0448\u0438 \u0440\u043e\u0431\u043e\u0442\u044b \u0434\u0432\u0438\u0433\u0430\u044e\u0442\u0441\u044f \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u043e \u0438 \u0438\u0445 \u043c\u0435\u0445\u0430\u043d\u0438\u043a\u0430 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438 \u0441 \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0435\u0439 \u044d\u043d\u0435\u0440\u0433\u0438\u0435\u0439, \u043f\u0440\u0438 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f\u0445, \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0445 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0435\u0439 \u0438 \u0441\u0435\u0440\u0432\u043e\u043f\u0440\u0438\u0432\u043e\u0434\u0430\u043c\u0438. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043d\u0430\u043c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0440\u0435\u0448\u0438\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0443 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0432 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f\u0445, \u0434\u043b\u044f \u0447\u0435\u0433\u043e \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u044f\u0442\u0441\u044f \u043f\u0430\u043a\u0435\u0442\u044b &quot;<a href=\"https:\/\/github.com\/JuliaOpt\/JuMP.jl\">JuMP<\/a>&quot; (\u0434\u043b\u044f \u043d\u0435\u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0435\u043c\u0443 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u043f\u0430\u043a\u0435\u0442 &quot;<a href=\"https:\/\/github.com\/JuliaOpt\/Ipopt.jl\">Ipopt<\/a>&quot;, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0435 \u0443\u043a\u0430\u0437\u0430\u043d \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044f\u0445 (\u0432\u043c\u0435\u0441\u0442\u043e \u043d\u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u043f\u0440\u0438\u0435\u0442\u0430\u0440\u043d\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438, \u043d\u043e \u044f \u0445\u043e\u0447\u0443 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0442\u0441\u044f \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u044b\u043c\u0438) \u0438 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e). \u0420\u0435\u0448\u0430\u0442\u044c \u0434\u0438\u0444\u0444\u0435\u0440\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f, \u043a\u0430\u043a \u0432 Modelica, \u043c\u044b \u043d\u0435 \u0431\u0443\u0434\u0435\u043c, \u0445\u043e\u0442\u044f \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0435\u0441\u0442\u044c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0440\u0430\u0437\u0432\u0438\u0442\u044b\u0435 \u043f\u0430\u043a\u0435\u0442\u044b, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 &quot;<a href=\"https:\/\/github.com\/pwl\/DASSL.jl\">DASSL<\/a>&quot;.<br \/>  \u0423\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u043e\u0439 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0440\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 (\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 &quot;<a href=\"https:\/\/github.com\/JuliaLang\/Reactive.jl\">Reactive<\/a>&quot;). \u0420\u0438\u0441\u043e\u0432\u0430\u0442\u044c \u0432 \u00ab\u0431\u043b\u043e\u043a\u043d\u043e\u0442\u0435\u00bb (Jupyter), \u0434\u043b\u044f \u0447\u0435\u0433\u043e \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u044e\u0442\u0441\u044f &quot;<a href=\"https:\/\/github.com\/JuliaLang\/IJulia.jl\">IJulia<\/a>&quot;, &quot;<a href=\"https:\/\/github.com\/JuliaLang\/Interact.jl\">Interact<\/a>&quot; \u0438 &quot;<a href=\"https:\/\/github.com\/GiovineItalia\/Compose.jl\">Compose<\/a>&quot;. \u0414\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u0435\u0449\u0435 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f &quot;<a href=\"http:\/\/github.com\/MikeInnes\/MacroTools.jl\">MacroTools<\/a>&quot;.<br \/>  <a name=\"habracut\"><\/a><br \/>  \u0414\u043b\u044f \u0438\u043d\u0441\u0442\u0430\u043b\u043b\u044f\u0446\u0438\u0438 \u043f\u0430\u043a\u0435\u0442\u043e\u0432 \u043d\u0430\u0434\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0432 Julia REPL \u043a\u043e\u043c\u0430\u043d\u0434\u0443  <\/p>\n<pre><code>foreach(Pkg.add, [&quot;IJulia&quot;, &quot;Ipopt&quot;, &quot;Interact&quot;, &quot;Reactive&quot;, &quot;JuMP&quot;, &quot;Compose&quot;, &quot;MacroTools&quot;]) <\/code><\/pre>\n<p>  \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u0434\u0432\u0443\u043c\u0435\u0440\u043d\u0443\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443, \u0441\u0445\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u043d\u0443\u044e \u043d\u0430 \u0440\u0438\u0441\u0443\u043d\u043a\u0435.<br \/>  \u041a\u0440\u0430\u0441\u043d\u044b\u043c\u0438 \u043b\u0438\u043d\u0438\u044f\u043c\u0438 \u0442\u0430\u043c \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0435\u043d\u044b \u043f\u0440\u0443\u0436\u0438\u043d\u044b, \u0447\u0435\u0440\u043d\u044b\u043c\u0438 \u2014 \u043d\u0435\u0440\u0430\u0441\u0442\u044f\u0436\u0438\u043c\u044b\u0435 \u0432\u0435\u0440\u0435\u0432\u043a\u0438, \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0439 \u043a\u0440\u0443\u0436\u0435\u0447\u0435\u043a \u2014 \u043d\u0435\u0432\u0435\u0441\u043e\u043c\u044b\u0439 \u0431\u043b\u043e\u043a, \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u2014 \u0433\u0440\u0443\u0437. \u0423 \u0432\u0435\u0440\u0435\u0432\u043e\u043a \u0435\u0441\u0442\u044c \u0434\u043b\u0438\u043d\u0430, \u0443 \u043f\u0440\u0443\u0436\u0438\u043d\u044b \u2014 \u0434\u043b\u0438\u043d\u0430 \u0438 \u0436\u0435\u0441\u0442\u043a\u043e\u0441\u0442\u044c. \u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u043d\u0430\u0437\u043e\u0432\u0435\u043c<br \/>  (x,y) \u2014 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u0433\u0440\u0443\u0437\u0430 (\u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u043a\u0440\u0443\u0433\u0430)<br \/>  (xctl, yctl) \u2014 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u00ab\u0443\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0449\u0435\u0433\u043e \u043a\u043e\u043d\u0446\u0430\u00bb \u0432\u0435\u0440\u0435\u0432\u043a\u0438, \u0434\u043b\u0438\u043d\u043e\u0439 1.7 \u043f\u0440\u0438\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u0439 \u043a \u0433\u0440\u0443\u0437\u0443.<br \/>  (xp, yp) \u2014 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u043d\u0435\u0432\u0435\u0441\u043e\u043c\u043e\u0433\u043e \u0442\u043e\u0447\u0435\u0447\u043d\u043e\u0433\u043e \u0431\u043b\u043e\u043a\u0430, \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0433\u043e \u0441\u043a\u043e\u043b\u044c\u0437\u0438\u0442\u044c \u043f\u043e \u0432\u0435\u0440\u0435\u0432\u043a\u0435.<br \/>  \u041e\u0434\u043d\u0430 \u043f\u0440\u0443\u0436\u0438\u043d\u0430 \u0434\u043b\u0438\u043d\u044b 0.1 \u0438 \u0436\u0435\u0441\u0442\u043a\u043e\u0441\u0442\u0438 1 \u0437\u0430\u043a\u0440\u0435\u043f\u043b\u0435\u043d\u0430 \u0432 \u0442\u043e\u0447\u043a\u0435 (0,3) \u0438 \u043f\u0440\u0438\u0446\u0435\u043f\u043b\u0435\u043d\u0430 \u043a \u0433\u0440\u0443\u0437\u0443.<br \/>  \u0412\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u0443\u0436\u0438\u043d\u0430 \u0434\u043b\u0438\u043d\u043e\u0439 0.15 \u0438 \u0436\u0435\u0441\u0442\u043a\u043e\u0441\u0442\u044c\u044e 5 \u0441\u043e\u0435\u0434\u0438\u043d\u044f\u0435\u0442 \u0433\u0440\u0443\u0437 \u0438 \u0431\u043b\u043e\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043a\u043e\u043b\u044c\u0437\u0438\u0442 \u043f\u043e \u0432\u0435\u0440\u0435\u0432\u043a\u0435 \u0434\u043b\u0438\u043d\u043e\u0439 6 \u0437\u0430\u043a\u0440\u0435\u043f\u043b\u0435\u043d\u043d\u043e\u0439 \u0432 \u0442\u043e\u0447\u043a\u0430\u0445 (5,1) \u0438 (4.5,5).<br \/>  (\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043f\u043e\u0434\u0431\u0438\u0440\u0430\u043b\u0438\u0441\u044c \u044d\u0432\u043e\u043b\u044e\u0446\u0438\u043e\u043d\u043d\u043e, \u0447\u0442\u043e \u0431\u044b \u043c\u043d\u0435 \u0431\u044b\u043b\u043e \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e \u0438 \u043f\u043e\u043d\u044f\u0442\u043d\u043e \u043a\u0430\u043a \u043e\u043d\u0430 \u0441\u0435\u0431\u044f \u0432\u0435\u0434\u0435\u0442 \u043f\u0440\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u043d\u043e\u0432\u044b\u0445 \u0444\u0438\u0447)  <\/p>\n<pre><code>    @wire(x,y, xctl,yctl, 1.7)     @wire(xp, yp, 5.0,1.0, 4.5,5.0, 6.0)     @energy([w(x,y, 0,3, 1, 0.1), w(x,y, xp,yp, 5, 0.15), 0.4*y]) <\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u043f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0440\u0435\u0448\u0430\u044e\u0449\u0435\u0439 \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code>function myModel(xctl, yctl)     m = Model()     @variable(m, y &gt;= 0)     @variable(m, x)     @variable(m, yp)     @variable(m, xp)      @wire(x,y, xctl,yctl, 1.7)     @wire(xp, yp, 5.0,1.0, 4.5,5.0, 6.0)      @energy([w(x,y, 0,3, 1, 0.1), w(x,y, xp,yp, 5, 0.15), 0.4*y])      status = solve(m)      xval = getvalue(x)     yval = getvalue(y)     xpval = getvalue(xp)     ypval = getvalue(yp)  #    print(&quot;calculate $status $xval $yval for $xctl, $yctl\\n&quot;)     (status, xval, yval, xpval, ypval) end <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u041c\u0430\u043a\u0440\u043e\u0441 wire \u0437\u0430\u0434\u0430\u0435\u0442 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u00ab\u0441\u0432\u044f\u0437\u044b\u0432\u0430\u043d\u0438\u0435 \u043d\u0435\u0440\u0430\u0441\u0442\u044f\u0436\u0438\u043c\u043e\u0439 \u0432\u0435\u0440\u0435\u0432\u043a\u043e\u0439\u00bb \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0439 \u0434\u043b\u0438\u043d\u044b \u0434\u0432\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0438\u043b\u0438 \u0434\u0432\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0438 \u0431\u043b\u043e\u043a.<br \/>  \u041c\u0430\u043a\u0440\u043e\u0441 energy \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u043c\u0438\u043d\u0438\u043c\u0438\u0437\u0438\u0440\u0443\u0435\u043c\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u044d\u043d\u0435\u0440\u0433\u0438\u0438 \u2014 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0442\u0435\u0440\u043c w \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u043f\u0440\u0443\u0436\u0438\u043d\u0443 (\u0441 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0439 \u0436\u0435\u0441\u0442\u043a\u043e\u0441\u0442\u044c\u044e \u0438 \u0434\u043b\u0438\u043d\u043e\u0439), \u0430 0.4*y \u2014 \u044d\u043d\u0435\u0440\u0433\u0438\u044f \u0433\u0440\u0443\u0437\u0430 \u0432 \u0433\u0440\u0430\u0432\u0438\u0442\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u043c \u043f\u043e\u043b\u0435, \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u0430\u044f, \u0447\u0442\u043e \u0431\u044b \u0434\u043b\u044f \u0435\u0435 \u043f\u0440\u0438\u0434\u0443\u043c\u044b\u0432\u0430\u0442\u044c \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441.<br \/>  \u042d\u0442\u0438 \u043c\u0430\u043a\u0440\u043e\u0441\u044b \u0432\u044b\u0440\u0430\u0436\u0430\u044e\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u0447\u043d\u044b\u043c\u0438 NLconstraint \u0438 NLobjective (\u043b\u0438\u043d\u0435\u0439\u043d\u044b\u0435 constraint \u0438 objective \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u0435\u0435, \u043d\u043e \u0441 \u043d\u0430\u0448\u0438\u043c\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c\u0438 \u043d\u0435 \u0441\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f):  <\/p>\n<pre><code>@NLconstraint(m, (x-xctl)^2+(y-yctl)^2 &lt;= 1.7) @NLconstraint(m, sqrt((5.0-xp)^2+(1.0-yp)^2) + sqrt((4.5-xp)^2+(5.0-yp)^2) &lt;= 6.0) @NLobjective(m, Min, 1*(sqrt(((x-0)^2 + (y - 3)^2)) - 0.1)^2                                  + 5*(sqrt((x - xp)^2 + (y - yp)^2) - 0.15)^2                                  + 0.4*y) <\/code><\/pre>\n<p>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f\u0445 \u00ab\u043c\u0435\u043d\u044c\u0448\u0435 \u0438\u043b\u0438 \u0440\u0430\u0432\u043d\u043e\u00bb \u0432\u043c\u0435\u0441\u0442\u043e \u00ab\u0440\u0430\u0432\u043d\u043e\u00bb \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u0447\u0442\u043e \u0432\u0435\u0440\u0435\u0432\u043a\u0430 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u043e\u0432\u0438\u0441\u0430\u0442\u044c, \u043d\u043e \u043d\u0435 \u0440\u0430\u0441\u0442\u044f\u0433\u0438\u0432\u0430\u0442\u044c\u0441\u044f. \u0414\u043b\u044f \u0434\u0432\u0443\u0445 \u0442\u043e\u0447\u0435\u043a \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u0440\u043e\u0433\u043e\u0435 \u0440\u0430\u0432\u0435\u043d\u0441\u0442\u0432\u043e, \u0435\u0441\u043b\u0438 \u043d\u0430\u0434\u043e \u0441\u043e\u0435\u0434\u0438\u043d\u0438\u0442\u044c \u0438\u0445 \u00ab\u0436\u0435\u0441\u0442\u043a\u0438\u043c \u0441\u0442\u0435\u0440\u0436\u043d\u0435\u043c\u00bb, \u0437\u0430\u043c\u0435\u043d\u0438\u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u043c\u0430\u043a\u0440\u043e\u0441.  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u043a\u043e\u0434 \u043c\u0430\u043a\u0440\u043e\u0441\u043e\u0432<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code>macro wire(x,y,x0,y0, l)     v = l^2     :(@NLconstraint(m, ($x0-$x)^2+($y0-$y)^2 &lt;= $v)) end  macro wire(x,y, x0,y0, x1,y1, l)     :(@NLconstraint(m, sqrt(($x0-$x)^2+($y0-$y)^2) + sqrt(($x1-$x)^2+($y1-$y)^2) &lt;= $l)) end   calcenergy(d) = MacroTools.@match d begin     [t__] =&gt; :(+$(map(energy1,t)...))     v_ =&gt; energy1(v)   end  energy1(v) = MacroTools.@match v begin     w(x1_,y1_, x2_,y2_, k_, l_) =&gt; :($k*(sqrt(($x1 - $x2)^2 + ($y1 - $y2)^2) - $l)^2)     x_ =&gt; x   end  macro energy(v)     e = calcenergy(v)     :(@NLobjective(m, Min, $e)) end <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043e\u043f\u0438\u0448\u0435\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f:  <\/p>\n<pre><code>xctl = slider(-2:0.01:5, label=&quot;X Control&quot;) xctlsig = signal(xctl) yctl = slider(-1:0.01:0.5, label=&quot;Y Control&quot;) yctlsig = signal(yctl) <\/code><\/pre>\n<p>  \u043f\u0440\u0438\u0441\u043e\u0435\u0434\u0438\u043d\u0438\u043c \u0438\u0445 \u043a \u043d\u0430\u0448\u0435\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u0435:  <\/p>\n<pre><code>ops = map(myModel, xctlsig, yctlsig) <\/code><\/pre>\n<p>  \u0418 \u043e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u043c \u044d\u0442\u043e \u0432 notebook:  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u043f\u0430\u0440\u0430 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code>xscale = 3 yscale = 3 shift = 1.5  pscale(x,y) = ((x*xscale+shift)cm, (y*yscale)cm)  function l(x1,y1, x2,y2; w=0.3mm, color=&quot;black&quot;)     compose(context(),     linewidth(w), stroke(color),     line([pscale(x1, y1), pscale(x2, y2)])) end <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <\/p>\n<pre><code>@manipulate for xc in xctl, yc in yctl, op in ops     compose(context(), #              text(150px, 220px, &quot;m = $(op[2]) $(op[3])&quot;), #              text(150px, 200px, &quot;p = $(op[4]) $(op[5])&quot;),     circle(pscale(op[2], op[3])..., 0.03),     circle(pscale(op[4], op[5])..., 0.01),      l(op[2], op[3], op[4], op[5], color=&quot;red&quot;),     l(op[2], op[3], 0, 3, color=&quot;red&quot;),      l(op[2], op[3], xc, yc),     l(op[4], op[5], 5, 1),     l(op[4], op[5], 4.5,5)     ) end <\/code><\/pre>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u043f\u043e\u043b\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043a\u043e\u0434\u0430<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code>using Interact, Reactive, JuMP, Compose, MacroTools  macro wire(x,y,x0,y0, l)     v = l^2     :(@NLconstraint(m, ($x0-$x)^2+($y0-$y)^2 &lt;= $v)) end  macro wire(x,y, x0,y0, x1,y1, l)     :(@NLconstraint(m, sqrt(($x0-$x)^2+($y0-$y)^2) + sqrt(($x1-$x)^2+($y1-$y)^2) &lt;= $l)) end   calcenergy(d) = MacroTools.@match d begin     [t__] =&gt; :(+$(map(energy1,t)...))     v_ =&gt; energy1(v)   end  energy1(v) = MacroTools.@match v begin     w(x1_,y1_, x2_,y2_, k_, l_) =&gt; :($k*(sqrt(($x1 - $x2)^2 + ($y1 - $y2)^2) - $l)^2)     x_ =&gt; x   end  macro energy(v)     e = calcenergy(v)     :(@NLobjective(m, Min, $e)) end  function myModel(xctl, yctl)     m = Model()     @variable(m, y &gt;= 0)     @variable(m, x)     @variable(m, yp)     @variable(m, xp)      @wire(x,y, xctl,yctl, 1.7)     @wire(xp, yp, 5.0,1.0, 4.5,5.0, 6.0)      @energy([w(x,y, 0,3, 1, 0.1), w(x,y, xp,yp, 5, 0.15), 0.4*y])      status = solve(m)     xval = getvalue(x)     yval = getvalue(y)     xpval = getvalue(xp)     ypval = getvalue(yp) #    print(&quot;calculate $status $xval $yval for $xctl, $yctl\\n&quot;)      (status, xval, yval, xpval, ypval) end  xctl = slider(-2:0.01:5, label=&quot;X Control&quot;) xctlsig = signal(xctl) yctl = slider(-1:0.01:0.5, label=&quot;Y Control&quot;) yctlsig = signal(yctl)  ops = map(myModel, xctlsig, yctlsig)  xscale = 3 yscale = 3 shift = 1.5  pscale(x,y) = ((x*xscale+shift)cm, (y*yscale)cm)  function l(x1,y1, x2,y2; w=0.3mm, color=&quot;black&quot;)     compose(context(),     linewidth(w), stroke(color),     line([pscale(x1, y1), pscale(x2, y2)])) end   @manipulate for xc in xctl, yc in yctl, op in ops     compose(context(), #              text(150px, 220px, &quot;m = $(op[2]) $(op[3])&quot;), #              text(150px, 200px, &quot;p = $(op[4]) $(op[5])&quot;),     circle(pscale(op[2], op[3])..., 0.03),     circle(pscale(op[4], op[5])..., 0.01),      l(op[2], op[3], op[4], op[5], color=&quot;red&quot;),     l(op[2], op[3], 0, 3, color=&quot;red&quot;),      l(op[2], op[3], xc, yc),     l(op[4], op[5], 5, 1),     l(op[4], op[5], 4.5,5)     ) end <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u041f\u0440\u043e\u0441\u0442\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c notebook: \u0432 Julia REPL \u043d\u0430\u0431\u0440\u0430\u0442\u044c<\/p>\n<pre><code>using IJulia notebook()<\/code><\/pre>\n<p>  \u042d\u0442\u043e \u0434\u043e\u043b\u0436\u043d\u043e \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435 &quot;<a href=\"http:\/\/localhost:8888\/tree\">http:\/\/localhost:8888\/tree<\/a>&quot;. \u0422\u0430\u043c \u043d\u0430\u0434\u043e \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u00abnew\u00bb\/\u00abJulia\u00bb, \u0442\u0430\u043c \u0432 \u043f\u043e\u043b\u0435 \u0432\u0432\u043e\u0434\u0430 \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u0434 \u0438 \u043d\u0430\u0436\u0430\u0442\u044c Shift-Enter.<br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habrahabr.ru\/post\/313138\/\"> https:\/\/habrahabr.ru\/post\/313138\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/16b\/d26\/958\/16bd269583c3465c8c35adf6e56edcf2.PNG\" width=\"320\" align=\"left\"\/>\u041c\u043d\u0435 \u0434\u0430\u0432\u043d\u043e \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0437\u0430\u043d\u044f\u0442\u044c\u0441\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435\u043c \u0440\u043e\u0431\u043e\u0442\u043e\u0432, \u043d\u043e \u0432\u0441\u0435\u0433\u0434\u0430 \u043d\u0435 \u0445\u0432\u0430\u0442\u0430\u0435\u0442 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u044b\u0445 \u0434\u0435\u043d\u0435\u0433, \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0438\u043b\u0438 \u043c\u0435\u0441\u0442\u0430. \u041f\u043e \u044d\u0442\u043e\u043c\u0443 \u044f \u0441\u043e\u0431\u0440\u0430\u043b\u0441\u044f \u043f\u0438\u0441\u0430\u0442\u044c \u0438\u0445 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0435 \u043c\u043e\u0434\u0435\u043b\u0438!<br \/>  \u041c\u043e\u0449\u043d\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0435 \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c, \u043b\u0438\u0431\u043e \u0441\u043b\u043e\u0436\u043d\u043e \u0441\u0442\u044b\u043a\u0443\u044e\u0442\u0441\u044f \u0441\u043e \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u043c\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430\u043c\u0438 (<a href=\"https:\/\/habrahabr.ru\/search\/?q=%5BModelica%5D\">Modelica<\/a>), \u043b\u0438\u0431\u043e \u043f\u0440\u043e\u043f\u0440\u0438\u0435\u0442\u0430\u0440\u043d\u044b (Wolfram Mathematica, \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0421\u0410\u041f\u0420), \u0438 \u044f \u0440\u0435\u0448\u0438\u043b \u0434\u0435\u043b\u0430\u0442\u044c \u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434 \u043d\u0430 <a href=\"http:\/\/julialang.org\/\">Julia<\/a>. \u041f\u043e\u0442\u043e\u043c \u0432\u0441\u0435 \u043d\u0430\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0441\u0442\u044b\u043a\u043e\u0432\u0430\u0442\u044c \u0441 \u0441\u0435\u0440\u0432\u0438\u0441\u0430\u043c\u0438 <a href=\"https:\/\/github.com\/jdlangs\/RobotOS.jl\">ROS<\/a>.<br \/>  \u0411\u0443\u0434\u0435\u043c \u0441\u0447\u0438\u0442\u0430\u0442\u044c, \u0447\u0442\u043e \u043d\u0430\u0448\u0438 \u0440\u043e\u0431\u043e\u0442\u044b \u0434\u0432\u0438\u0433\u0430\u044e\u0442\u0441\u044f \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u043e \u0438 \u0438\u0445 \u043c\u0435\u0445\u0430\u043d\u0438\u043a\u0430 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438 \u0441 \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0435\u0439 \u044d\u043d\u0435\u0440\u0433\u0438\u0435\u0439, \u043f\u0440\u0438 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f\u0445, \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0445 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0435\u0439 \u0438 \u0441\u0435\u0440\u0432\u043e\u043f\u0440\u0438\u0432\u043e\u0434\u0430\u043c\u0438. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043d\u0430\u043c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0440\u0435\u0448\u0438\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0443 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0432 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f\u0445, \u0434\u043b\u044f \u0447\u0435\u0433\u043e \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u044f\u0442\u0441\u044f \u043f\u0430\u043a\u0435\u0442\u044b &quot;<a href=\"https:\/\/github.com\/JuliaOpt\/JuMP.jl\">JuMP<\/a>&quot; (\u0434\u043b\u044f \u043d\u0435\u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0435\u043c\u0443 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u043f\u0430\u043a\u0435\u0442 &quot;<a href=\"https:\/\/github.com\/JuliaOpt\/Ipopt.jl\">Ipopt<\/a>&quot;, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0435 \u0443\u043a\u0430\u0437\u0430\u043d \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044f\u0445 (\u0432\u043c\u0435\u0441\u0442\u043e \u043d\u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u043f\u0440\u0438\u0435\u0442\u0430\u0440\u043d\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438, \u043d\u043e \u044f \u0445\u043e\u0447\u0443 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0442\u0441\u044f \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u044b\u043c\u0438) \u0438 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e). \u0420\u0435\u0448\u0430\u0442\u044c \u0434\u0438\u0444\u0444\u0435\u0440\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f, \u043a\u0430\u043a \u0432 Modelica, \u043c\u044b \u043d\u0435 \u0431\u0443\u0434\u0435\u043c, \u0445\u043e\u0442\u044f \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0435\u0441\u0442\u044c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0440\u0430\u0437\u0432\u0438\u0442\u044b\u0435 \u043f\u0430\u043a\u0435\u0442\u044b, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 &quot;<a href=\"https:\/\/github.com\/pwl\/DASSL.jl\">DASSL<\/a>&quot;.<br \/>  \u0423\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u043e\u0439 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0440\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 (\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 &quot;<a href=\"https:\/\/github.com\/JuliaLang\/Reactive.jl\">Reactive<\/a>&quot;). \u0420\u0438\u0441\u043e\u0432\u0430\u0442\u044c \u0432 \u00ab\u0431\u043b\u043e\u043a\u043d\u043e\u0442\u0435\u00bb (Jupyter), \u0434\u043b\u044f \u0447\u0435\u0433\u043e \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u044e\u0442\u0441\u044f &quot;<a href=\"https:\/\/github.com\/JuliaLang\/IJulia.jl\">IJulia<\/a>&quot;, &quot;<a href=\"https:\/\/github.com\/JuliaLang\/Interact.jl\">Interact<\/a>&quot; \u0438 &quot;<a href=\"https:\/\/github.com\/GiovineItalia\/Compose.jl\">Compose<\/a>&quot;. \u0414\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u0435\u0449\u0435 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f &quot;<a href=\"http:\/\/github.com\/MikeInnes\/MacroTools.jl\">MacroTools<\/a>&quot;.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-279874","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/279874","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=279874"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/279874\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=279874"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=279874"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=279874"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}