{"id":8903,"date":"2017-10-27T09:00:03","date_gmt":"2017-10-27T13:00:03","guid":{"rendered":"https:\/\/blogs.mathworks.com\/pick\/?p=8903"},"modified":"2017-11-07T19:02:38","modified_gmt":"2017-11-08T00:02:38","slug":"easy-design-iteration-sweeps-for-simulink-models","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/pick\/2017\/10\/27\/easy-design-iteration-sweeps-for-simulink-models\/","title":{"rendered":"Easy design iteration sweeps for Simulink models"},"content":{"rendered":"<div class=\"content\">\n<p><!--introduction--><\/p>\n<p><a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/32620\">Greg&#8217;s<\/a> pick this week is <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/60323-stoical\">STOICAL<\/a> by <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/2911149-reinhold\">Reinhold<\/a>.<\/p>\n<p>Simulink is well suited for laying out block diagrams of system simulations. These models can be configured in numerous ways including block parameter values, logging various signals in the model, conditional block variations, model configuration settings.<\/p>\n<p>Reinhold provides a unique way to identify, manage, and script interactions with a Simulink model that enable creating numerous model configurations, running simulations for those configurations, and collecting the results of the simulations.<\/p>\n<p>Reinhold essentially provides a markup language that enables identification of various configurable model elements along with an command line API that is used to interpret the markup language and make adjustments to the model configuration.<\/p>\n<p><!--\/introduction--><\/p>\n<h3>Contents<\/h3>\n<div>\n<ul>\n<li><a href=\"#58e7cb1a-7c43-40f2-846d-c7780d05092e\">What does the Markup Look Like?<\/a><\/li>\n<li><a href=\"#208ce306-74b1-4e80-aae8-4ffe33e980d3\">What problems does STOICAL work to solve?<\/a><\/li>\n<li><a href=\"#dd34d326-2f31-485c-a82e-ba72005054b7\">STOIOCAL is best suited when modeling system level dynamics.<\/a><\/li>\n<li><a href=\"#3b8455bb-ba92-4c68-b398-fec2558617ec\">What do you think?<\/a><\/li>\n<\/ul>\n<\/div>\n<h4>What does the Markup Look Like?<a name=\"58e7cb1a-7c43-40f2-846d-c7780d05092e\"><\/a><\/h4>\n<p>There are several examples included.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/pick\/files\/image-005-sl-300x85.png\" alt=\"\" hspace=\"5\" vspace=\"5\" \/><\/p>\n<p>Note the use of <tt>#PARAM#<\/tt> to identify a tunable element in the model.<\/p>\n<p>The API can then be used to set values for the parameter<\/p>\n<pre class=\"codeinput\">setParameterValue(<span class=\"string\">'#System#SystemGain'<\/span>,<span class=\"string\">'myNewValue'<\/span>,STOICAL);\r\n<\/pre>\n<p>This includes a hierarchical reference as the <tt>SystemGain<\/tt> parameter is contained a subsystem that was identified as <tt>System<\/tt> using the following markup syntax.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/pick\/files\/image-001-sl-300x80.png\" alt=\"\" hspace=\"5\" vspace=\"5\" \/><\/p>\n<p>Another interesting feature is the ability to restore default values for parameters using<\/p>\n<pre class=\"codeinput\"> setParameterValues2Default(STOICAL);\r\n<\/pre>\n<h4>What problems does STOICAL work to solve?<a name=\"208ce306-74b1-4e80-aae8-4ffe33e980d3\"><\/a><\/h4>\n<p>Historically there hasn&#8217;t been much tooling in Simulink to manage model configurations, especially for variations between simulation runs. STOICAL provides the following features to help out with the configuration management.<\/p>\n<div>\n<ul>\n<li>Parameter values are available as part of model file<\/li>\n<li>Searching and retrieving parameter values<\/li>\n<li>Captures errors that occur in simulation runs<\/li>\n<li>Manages Simscape Powersystems solver configurations<\/li>\n<li>Providing a default choice for variant subsystems<\/li>\n<li>Easily enable logging signal lines from a script<\/li>\n<li>Use regular expressions to change parameters, signal logging, etc.<\/li>\n<li>Enable subsystem variant management using descriptive names<\/li>\n<li>Store results from multiple simulation runs in a consistent format<\/li>\n<\/ul>\n<\/div>\n<p>Over the past couple of years, a number of features have been released with Simulink to address many of these issues.<\/p>\n<p>The following are a couple of my personal favorites:<\/p>\n<div>\n<ul>\n<li><a href=\"https:\/\/www.mathworks.com\/help\/simulink\/ug\/what-is-a-data-dictionary.html\">Data dictionary<\/a><\/li>\n<li><a title=\"https:\/\/www.mathworks.com\/help\/releases\/R2016b\/simulink\/ug\/inspect-and-configure-design-attributes-of-model-data.html (link no longer works)\">Model data table<\/a><\/li>\n<li><a href=\"https:\/\/www.mathworks.com\/help\/simulink\/slref\/parsim.html\">PARSIM<\/a> and the associated <a href=\"https:\/\/www.mathworks.com\/help\/simulink\/slref\/simulink.simulationinput-class.html\"><tt>SimulationInput<\/tt><\/a> object<\/li>\n<li><a href=\"https:\/\/www.mathworks.com\/help\/simulink\/gui\/variant-manager-interface.html\">Variant manager<\/a><\/li>\n<li><a href=\"https:\/\/www.mathworks.com\/help\/sltest\/index.html\">Simulink Test<\/a><\/li>\n<\/ul>\n<\/div>\n<p>I&#8217;ll avoid diving into excruciating detail about these new features, sufficed to say that if you&#8217;re interested it&#8217;s worth checking out the documentation and <a href=\"https:\/\/www.mathworks.com\/help\/simulink\/release-notes.html\">release notes<\/a>.<\/p>\n<h4>STOIOCAL is best suited when modeling system level dynamics.<a name=\"dd34d326-2f31-485c-a82e-ba72005054b7\"><\/a><\/h4>\n<p>The STOICAL tool does a great job at making model configuration accessible. The methods it uses to achieve this excludes its use from many code generation applications. If you plan on using this for parameter tuning, I would recommend using this only on elements of system models that will not be the source of generated C-code. For example, plant models and environment models.<\/p>\n<p>Also the use of regular expressions to quickly identify model elements from the MATLAB Command Line is quite nice. While some progress has been made in this area within Simulink, the command line interface for this type of activity is clunky (see find_system as an example).<\/p>\n<h4>What do you think?<a name=\"3b8455bb-ba92-4c68-b398-fec2558617ec\"><\/a><\/h4>\n<p>Let us know <a href=\"https:\/\/blogs.mathworks.com\/pick\/?p=8903#respond\">here<\/a>.<\/p>\n<p><script language=\"JavaScript\"> <!-- \n    function grabCode_9a835862544b4fac9cc892049cf50e15() {\n        \/\/ Remember the title so we can use it in the new page\n        title = document.title;\n\n        \/\/ Break up these strings so that their presence\n        \/\/ in the Javascript doesn't mess up the search for\n        \/\/ the MATLAB code.\n        t1='9a835862544b4fac9cc892049cf50e15 ' + '##### ' + 'SOURCE BEGIN' + ' #####';\n        t2='##### ' + 'SOURCE END' + ' #####' + ' 9a835862544b4fac9cc892049cf50e15';\n    \n        b=document.getElementsByTagName('body')[0];\n        i1=b.innerHTML.indexOf(t1)+t1.length;\n        i2=b.innerHTML.indexOf(t2);\n \n        code_string = b.innerHTML.substring(i1, i2);\n        code_string = code_string.replace(\/REPLACE_WITH_DASH_DASH\/g,'--');\n\n        \/\/ Use \/x3C\/g instead of the less-than character to avoid errors \n        \/\/ in the XML parser.\n        \/\/ Use '\\x26#60;' instead of '<' so that the XML parser\n        \/\/ doesn't go ahead and substitute the less-than character. \n        code_string = code_string.replace(\/\\x3C\/g, '\\x26#60;');\n\n        copyright = 'Copyright 2017 The MathWorks, Inc.';\n\n        w = window.open();\n        d = w.document;\n        d.write('<\/p>\n\n\n\n\n<pre>\\n');\r\n        d.write(code_string);\r\n\r\n        \/\/ Add copyright line at the bottom if specified.\r\n        if (copyright.length > 0) {\r\n            d.writeln('');\r\n            d.writeln('%%');\r\n            if (copyright.length > 0) {\r\n                d.writeln('% _' + copyright + '_');\r\n            }\r\n        }\r\n\r\n        d.write('<\/pre>\n\n\n\n\n<p>\\n');\n\n        d.title = title + ' (MATLAB code)';\n        d.close();\n    }   \n     --> <\/script><\/p>\n<p style=\"text-align: right; font-size: xx-small; font-weight: lighter; font-style: italic; color: gray;\">\n<a><span style=\"font-size: x-small; font-style: italic;\">Get<br \/>\nthe MATLAB code<noscript>(requires JavaScript)<\/noscript><\/span><\/a><\/p>\n<p>Published with MATLAB\u00ae R2017b<\/p>\n<\/div>\n<p><!--\n9a835862544b4fac9cc892049cf50e15 ##### SOURCE BEGIN #####\n%% Easy design iteration sweeps for Simulink models\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/32620 Greg's>\n% pick this week is <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/60323-stoical % STOICAL> by <https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/2911149-reinhold % Reinhold>.\n%\n% Simulink is well suited for laying out block diagrams of system simulations.\n% These models can be configured in numerous ways including block parameter values,\n% logging various signals in the model, conditional block variations, model configuration\n% settings.\n%\n% Reinhold provides a unique way to identify, manage, and script interactions\n% with a Simulink model that enable creating numerous model configurations, running\n% simulations for those configurations, and collecting the results of the simulations.\n%\n% Reinhold essentially provides a markup language that enables identification\n% of various configurable model elements along with an command line API that is\n% used to interpret the markup language and make adjustments to the model configuration.\n%% What does the Markup Look Like?\n% There are several examples included.\n%\n% <<image-005-sl.png>>\n%\n% Note the use of |#PARAM#| to identify a tunable element in the model.\n%\n% The API can then be used to set values for the parameter\n%%\nsetParameterValue('#System#SystemGain','myNewValue',STOICAL);\n%%\n% This includes a hierarchical reference as the |SystemGain| parameter is\n% contained a subsystem that was identified as |System| using the following markup\n% syntax.\n%\n% <<image-001-sl.png>>\n%\n% Another interesting feature is the ability to restore default values for\n% parameters using\n\nsetParameterValues2Default(STOICAL);\n%% What problems does STOICAL work to solve?\n% Historically there hasn't been much tooling in Simulink to manage model configurations,\n% especially for variations between simulation runs. STOICAL provides the following\n% features to help out with the configuration management.\n%\n% * Parameter values are available as part of model file\n% * Searching and retrieving parameter values\n% * Captures errors that occur in simulation runs\n% * Manages Simscape Powersystems solver configurations\n% * Providing a default choice for variant subsystems\n% * Easily enable logging signal lines from a script\n% * Use regular expressions to change parameters, signal logging, etc.\n% * Enable subsystem variant management using descriptive names\n% * Store results from multiple simulation runs in a consistent format\n%\n% Over the past couple of years, a number of features have been released\n% with Simulink to address many of these issues.\n%\n% The following are a couple of my personal favorites:\n%\n% * <https:\/\/www.mathworks.com\/help\/simulink\/ug\/what-is-a-data-dictionary.html % Data dictionary>\n% * <https:\/\/www.mathworks.com\/help\/releases\/R2016b\/simulink\/ug\/inspect-and-configure-design-attributes-of-model-data.html % Model data table>\n% * <https:\/\/www.mathworks.com\/help\/simulink\/slref\/parsim.html PARSIM> and the\n% associted <https:\/\/www.mathworks.com\/help\/simulink\/slref\/simulink.simulationinput-class.html % SimulationInput>| |object\n% * <https:\/\/www.mathworks.com\/help\/simulink\/gui\/variant-manager-interface.html % Variant manager>\n% * <https:\/\/www.mathworks.com\/help\/sltest\/index.html Simulink Test>\n%\n% I'll avoid diving into excruciating detail about these new features, sufficed\n% to say that if you're interested it's worth checking out the documentation and\n% <https:\/\/www.mathworks.com\/help\/simulink\/release-notes.html release notes>.\n%% STOIOCAL is best suited when modeling system level dynamics.\n% The STOICAL tool does a great job at making model configuration accessible.\n% The methods it uses to achieve this excludes its use from many code generation\n% applications.  If you plan on using this for parameter tuning, I would recommend\n% using this only on elements of system models that will not be the source of\n% generated C-code. For example, plant models and environment models.\n%\n%\n%\n% Also the use of regular expressions to quickly identify model elements\n% from the MATLAB Command Line is quite nice.  While some progress has been made\n% in this area within Simulink, standard the command line interface for this type\n% of activitiy is clunkey (see find_system as an example).\n%\n%\n%% What do you think?\n% Let us know <https:\/\/blogs.mathworks.com\/pick\/ here>.\n##### SOURCE END ##### 9a835862544b4fac9cc892049cf50e15\n--><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img decoding=\"async\"  class=\"img-responsive\" src=\"https:\/\/blogs.mathworks.com\/pick\/files\/image-005-sl-300x85.png\" onError=\"this.style.display ='none';\" \/><\/div>\n<p>Greg&#8217;s pick this week is STOICAL by Reinhold.<br \/>\nSimulink is well suited for laying out block diagrams of system simulations. These models can be configured in numerous ways including block&#8230; <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/pick\/2017\/10\/27\/easy-design-iteration-sweeps-for-simulink-models\/\">read more >><\/a><\/p>\n","protected":false},"author":36,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[16],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/8903"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/users\/36"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/comments?post=8903"}],"version-history":[{"count":9,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/8903\/revisions"}],"predecessor-version":[{"id":8946,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/8903\/revisions\/8946"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/media?parent=8903"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/categories?post=8903"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/tags?post=8903"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}