{"id":4193,"date":"2023-03-18T11:43:00","date_gmt":"2023-03-18T10:43:00","guid":{"rendered":"http:\/\/mosaic-modeling.de\/?page_id=4193"},"modified":"2023-08-22T09:56:30","modified_gmt":"2023-08-22T08:56:30","slug":"optimization-code-generation-and-execution","status":"publish","type":"page","link":"https:\/\/mosaic-modeling.de\/?page_id=4193","title":{"rendered":"Optimization: Code generation and execution"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_83 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">On this page<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/mosaic-modeling.de\/?page_id=4193\/#Purpose\" >Purpose<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/mosaic-modeling.de\/?page_id=4193\/#Explanation-of-the-editor\" >Explanation of the editor<\/a><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/mosaic-modeling.de\/?page_id=4193\/#Code-generation\" >Code generation<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/mosaic-modeling.de\/?page_id=4193\/#NEOS-server\" >NEOS server<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n\n<p class=\"has-vivid-red-color has-text-color\"><strong>Mandatory element<\/strong><\/p>\n\n\n<h3><span class=\"ez-toc-section\" id=\"Purpose\"><\/span>Purpose<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>The code generation has the same task in the simulation: it shall provide the code for an optimization, which can then be solved in an appropriate optimization environment.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Explanation-of-the-editor\"><\/span>Explanation of the editor<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<h4><span class=\"ez-toc-section\" id=\"Code-generation\"><\/span>Code generation<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p>The code generation works in the same way as in the simulation. The preferred language specification can be chosen from a list of predefined specifications or you can choose a user-defined language specification. Additional information on the number of degrees of freedom and other quantities is provided in the status window (Figure 1). The generated code can be copied to a file of the required file type.<\/p>\n<figure id=\"attachment_4984\" aria-describedby=\"caption-attachment-4984\" style=\"width: 1920px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/mosaic-modeling.de\/wp-content\/uploads\/2023\/08\/Editor_CodeGeneration.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-4984\" src=\"http:\/\/mosaic-modeling.de\/wp-content\/uploads\/2023\/08\/Editor_CodeGeneration.png\" alt=\"\" width=\"1920\" height=\"1080\" srcset=\"https:\/\/mosaic-modeling.de\/wp-content\/uploads\/2023\/08\/Editor_CodeGeneration.png 1920w, https:\/\/mosaic-modeling.de\/wp-content\/uploads\/2023\/08\/Editor_CodeGeneration-300x169.png 300w, https:\/\/mosaic-modeling.de\/wp-content\/uploads\/2023\/08\/Editor_CodeGeneration-1024x576.png 1024w, https:\/\/mosaic-modeling.de\/wp-content\/uploads\/2023\/08\/Editor_CodeGeneration-768x432.png 768w, https:\/\/mosaic-modeling.de\/wp-content\/uploads\/2023\/08\/Editor_CodeGeneration-1536x864.png 1536w, https:\/\/mosaic-modeling.de\/wp-content\/uploads\/2023\/08\/Editor_CodeGeneration-1110x624.png 1110w, https:\/\/mosaic-modeling.de\/wp-content\/uploads\/2023\/08\/Editor_CodeGeneration-528x297.png 528w\" sizes=\"auto, (max-width: 1920px) 100vw, 1920px\" \/><\/a><figcaption id=\"caption-attachment-4984\" class=\"wp-caption-text\">Figure 1: Code generation for an optimization.<\/figcaption><\/figure>\n<h4><span class=\"ez-toc-section\" id=\"NEOS-server\"><\/span>NEOS server<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p>If you have no access to optimization software, you can also try to solve the optimization problem via the NEOS server (Figure 2). To this end, you must first of all accept the terms of condition. Afterwards, you can select the preferred solver (tab &#8220;Submit&#8221;) by selecting the type of the optimization problem at hand. After clicking on &#8220;Generate Code &amp; Submit&#8221;, you can find the log of the solution in the history tab. Note that the NEOS server has a queue, so that it may take a couple of minutes until your problem is solved.<\/p>\n<figure id=\"attachment_4985\" aria-describedby=\"caption-attachment-4985\" style=\"width: 1920px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/mosaic-modeling.de\/wp-content\/uploads\/2023\/08\/Editor_NEOSServer.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-4985\" src=\"http:\/\/mosaic-modeling.de\/wp-content\/uploads\/2023\/08\/Editor_NEOSServer.png\" alt=\"\" width=\"1920\" height=\"1080\" srcset=\"https:\/\/mosaic-modeling.de\/wp-content\/uploads\/2023\/08\/Editor_NEOSServer.png 1920w, https:\/\/mosaic-modeling.de\/wp-content\/uploads\/2023\/08\/Editor_NEOSServer-300x169.png 300w, https:\/\/mosaic-modeling.de\/wp-content\/uploads\/2023\/08\/Editor_NEOSServer-1024x576.png 1024w, https:\/\/mosaic-modeling.de\/wp-content\/uploads\/2023\/08\/Editor_NEOSServer-768x432.png 768w, https:\/\/mosaic-modeling.de\/wp-content\/uploads\/2023\/08\/Editor_NEOSServer-1536x864.png 1536w, https:\/\/mosaic-modeling.de\/wp-content\/uploads\/2023\/08\/Editor_NEOSServer-1110x624.png 1110w, https:\/\/mosaic-modeling.de\/wp-content\/uploads\/2023\/08\/Editor_NEOSServer-528x297.png 528w\" sizes=\"auto, (max-width: 1920px) 100vw, 1920px\" \/><\/a><figcaption id=\"caption-attachment-4985\" class=\"wp-caption-text\">Figure 2: Code generation and solution on NEOS server.<\/figcaption><\/figure>","protected":false},"excerpt":{"rendered":"<p>Mandatory element Purpose The code generation has the same task in the simulation: it shall provide the code for an optimization, which can then be solved in an appropriate optimization environment. Explanation of the editor Code generation The code generation works in the same way as in the simulation. The preferred language specification can be [&hellip;]<\/p>\n","protected":false},"author":252,"featured_media":0,"parent":4187,"menu_order":4,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-4193","page","type-page","status-publish","czr-hentry"],"_links":{"self":[{"href":"https:\/\/mosaic-modeling.de\/index.php?rest_route=\/wp\/v2\/pages\/4193","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mosaic-modeling.de\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/mosaic-modeling.de\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/mosaic-modeling.de\/index.php?rest_route=\/wp\/v2\/users\/252"}],"replies":[{"embeddable":true,"href":"https:\/\/mosaic-modeling.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4193"}],"version-history":[{"count":3,"href":"https:\/\/mosaic-modeling.de\/index.php?rest_route=\/wp\/v2\/pages\/4193\/revisions"}],"predecessor-version":[{"id":5692,"href":"https:\/\/mosaic-modeling.de\/index.php?rest_route=\/wp\/v2\/pages\/4193\/revisions\/5692"}],"up":[{"embeddable":true,"href":"https:\/\/mosaic-modeling.de\/index.php?rest_route=\/wp\/v2\/pages\/4187"}],"wp:attachment":[{"href":"https:\/\/mosaic-modeling.de\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4193"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}