<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How can I pass extra arguments to the objective function in a nonlinear optimization exercise in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/How-can-I-pass-extra-arguments-to-the-objective-function-in-a/m-p/252513#M2588</link>
    <description>&lt;P&gt;Thanks, Rick.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am reading your article, once I found there is a similar question posted earlier on the forum. Here is a quick related question. If I have mutiple extra arguments, which are difficult to be written as a single matrix, how should I write the global clause? Should it be like&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;global (y1,y2,...)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;or global (y1) global (y2) .... ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
    <pubDate>Thu, 25 Feb 2016 19:39:11 GMT</pubDate>
    <dc:creator>bigbigben</dc:creator>
    <dc:date>2016-02-25T19:39:11Z</dc:date>
    <item>
      <title>How can I pass extra arguments to the objective function in a nonlinear optimization exercise</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/How-can-I-pass-extra-arguments-to-the-objective-function-in-a/m-p/252507#M2586</link>
      <description>&lt;P&gt;It looks that the objective function used in nonlinear optimization routines can only have one input vector. However, what if I need to pass some other parameters to the objective function. For example, I want to minimize the sum of square of difference between a function value and a target value, and the target value is user defined. Let me use a simple case, suppose x is a 3*1 vector I want to find to minimize the following funciton.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;z=(x[1]-y[1])**2 + (x[2]-y[2])**3 + (x[3]-y[3])**2, where y is the vector of target specified by users. Therefore, it is better not hard coded in the objective function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Ideally, the objective function should have two arguments, x and y;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; start obj_func(x,y);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; z=(x[1]-y[1])**2 + (x[2]-y[2])**3 + (x[3]-y[3])**2;&lt;/P&gt;
&lt;P&gt;return(z);&lt;/P&gt;
&lt;P&gt;finish obj_func;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The reason I cannot put x and y together as a single vector is that I only need to search for x, for a given y. In MATLAB, all the optimization routines allow passing extra arguements to the objective function. I am not sure if I can do similar things in SAS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks a bunch.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Feb 2016 19:30:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/How-can-I-pass-extra-arguments-to-the-objective-function-in-a/m-p/252507#M2586</guid>
      <dc:creator>bigbigben</dc:creator>
      <dc:date>2016-02-25T19:30:45Z</dc:date>
    </item>
    <item>
      <title>Re: How can I pass extra arguments to the objective function in a nonlinear optimization exercise</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/How-can-I-pass-extra-arguments-to-the-objective-function-in-a/m-p/252511#M2587</link>
      <description>&lt;P&gt;Use the GLOBAL clause to list parameters that are important to evaluate the function, but that are not optimized:&lt;/P&gt;
&lt;P&gt;start obj_func(x) GLOBAL(y);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See the article &lt;A href="http://blogs.sas.com/content/iml/2011/10/12/maximum-likelihood-estimation-in-sasiml.html" target="_self"&gt;"Maximum likelihood estimation in SAS/IML"&lt;/A&gt;&amp;nbsp;or these other blog posts:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.sas.com/content/iml/tag/optimization" target="_blank"&gt;http://blogs.sas.com/content/iml/tag/optimization&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Feb 2016 19:35:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/How-can-I-pass-extra-arguments-to-the-objective-function-in-a/m-p/252511#M2587</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2016-02-25T19:35:37Z</dc:date>
    </item>
    <item>
      <title>Re: How can I pass extra arguments to the objective function in a nonlinear optimization exercise</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/How-can-I-pass-extra-arguments-to-the-objective-function-in-a/m-p/252513#M2588</link>
      <description>&lt;P&gt;Thanks, Rick.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am reading your article, once I found there is a similar question posted earlier on the forum. Here is a quick related question. If I have mutiple extra arguments, which are difficult to be written as a single matrix, how should I write the global clause? Should it be like&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;global (y1,y2,...)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;or global (y1) global (y2) .... ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 25 Feb 2016 19:39:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/How-can-I-pass-extra-arguments-to-the-objective-function-in-a/m-p/252513#M2588</guid>
      <dc:creator>bigbigben</dc:creator>
      <dc:date>2016-02-25T19:39:11Z</dc:date>
    </item>
    <item>
      <title>Re: How can I pass extra arguments to the objective function in a nonlinear optimization exercise</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/How-can-I-pass-extra-arguments-to-the-objective-function-in-a/m-p/252520#M2589</link>
      <description>&lt;P&gt;Use commas, as in&lt;/P&gt;
&lt;P&gt;global(y1, y2, y3);&lt;/P&gt;</description>
      <pubDate>Thu, 25 Feb 2016 19:49:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/How-can-I-pass-extra-arguments-to-the-objective-function-in-a/m-p/252520#M2589</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2016-02-25T19:49:12Z</dc:date>
    </item>
  </channel>
</rss>

