<?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: Global variables in nested optimization problem in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Global-variables-in-nested-optimization-problem/m-p/477459#M4282</link>
    <description>&lt;P&gt;You haven't defined S, l, or h.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I suggest you start by reading the article &lt;A href="https://blogs.sas.com/content/iml/2016/05/11/tips-before-optimization.html" target="_self"&gt;"Ten tips before you run an optimization."&lt;/A&gt;&amp;nbsp;You also might want to look at &lt;A href="https://blogs.sas.com/content/iml/2014/03/12/optimizing-a-function-of-an-integral.html" target="_self"&gt;"Optimizing a function of an integral,"&lt;/A&gt; which optimizes a function that in turn calls other functions.&lt;/P&gt;</description>
    <pubDate>Thu, 12 Jul 2018 13:37:33 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2018-07-12T13:37:33Z</dc:date>
    <item>
      <title>Global variables in nested optimization problem</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Global-variables-in-nested-optimization-problem/m-p/477369#M4281</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to solve a nested optimization problem with SAS/IML, specifically):&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="opt3.PNG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/21752iC9B1D223FC5EE244/image-size/large?v=v2&amp;amp;px=999" role="button" title="opt3.PNG" alt="opt3.PNG" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="opt4.PNG" style="width: 390px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/21753i6A520AA77A4AA52A/image-size/large?v=v2&amp;amp;px=999" role="button" title="opt4.PNG" alt="opt4.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm not sure how to handle the input vs global variables in this case (which I think is why it is not working). I don't know how to handle z.&amp;nbsp; This is what i have so far:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/* function P*/&lt;BR /&gt;start P(z) global(h,b,p1,p2,a_inter,X_I);&lt;BR /&gt;&amp;nbsp; &amp;nbsp;return( sum(h#(CDF('NORMAL',(b-p1#(X_I*(a_inter*(z`))))/p2))) );&lt;BR /&gt;finish;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/* derivative of theta function*/&lt;BR /&gt;start deri(theta_x) global(l,h,z);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; return(&amp;nbsp;l - sum(P(z)#h#exp(h*theta_x)/( P(z)#(exp(h*theta_x)-1) + 1 ) ) );&lt;BR /&gt;finish;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/* finding root of theta function*/&lt;BR /&gt;start theta(z);&lt;BR /&gt;bounds = {0,10000};&lt;BR /&gt;&amp;nbsp;return( froot( "deri", bounds) );&lt;BR /&gt;finish;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/*main function*/&lt;BR /&gt;start Func(z) global(l,h);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; return( -theta(z)*l + (sum(log(1 + P(z)#(exp(h#theta(z)) - 1) ) )) - 0.5*z*(z`) );&lt;BR /&gt;finish;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;z = RANDNORMAL(S,0, 1); /*x0*/&lt;BR /&gt;z = (z`);&lt;BR /&gt;opt = {1,2};&lt;BR /&gt;call nlpnra(rc, result, "Func", z, opt);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Given that the equations are done correctly, how would I set this up so that the root/derivative function can make use if the current z that the optimization algorithm is&amp;nbsp;evaluating? Is there something else that is wrong?&lt;/P&gt;</description>
      <pubDate>Thu, 12 Jul 2018 08:43:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Global-variables-in-nested-optimization-problem/m-p/477369#M4281</guid>
      <dc:creator>jan_t_lagen</dc:creator>
      <dc:date>2018-07-12T08:43:45Z</dc:date>
    </item>
    <item>
      <title>Re: Global variables in nested optimization problem</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Global-variables-in-nested-optimization-problem/m-p/477459#M4282</link>
      <description>&lt;P&gt;You haven't defined S, l, or h.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I suggest you start by reading the article &lt;A href="https://blogs.sas.com/content/iml/2016/05/11/tips-before-optimization.html" target="_self"&gt;"Ten tips before you run an optimization."&lt;/A&gt;&amp;nbsp;You also might want to look at &lt;A href="https://blogs.sas.com/content/iml/2014/03/12/optimizing-a-function-of-an-integral.html" target="_self"&gt;"Optimizing a function of an integral,"&lt;/A&gt; which optimizes a function that in turn calls other functions.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Jul 2018 13:37:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Global-variables-in-nested-optimization-problem/m-p/477459#M4282</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2018-07-12T13:37:33Z</dc:date>
    </item>
    <item>
      <title>Re: Global variables in nested optimization problem</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Global-variables-in-nested-optimization-problem/m-p/477461#M4283</link>
      <description>&lt;P&gt;Haven't looked through your functions in depth, but have have a few parameters, which you have not defined yet. Eg S and I.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, why do you set&amp;nbsp;&lt;SPAN&gt;z = (z`) ?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Jul 2018 13:37:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Global-variables-in-nested-optimization-problem/m-p/477461#M4283</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-07-12T13:37:26Z</dc:date>
    </item>
    <item>
      <title>Re: Global variables in nested optimization problem</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Global-variables-in-nested-optimization-problem/m-p/477498#M4284</link>
      <description>&lt;P&gt;Sorry for the confusion, i should have shown the step where I import the other variables, all of them are defined vectors (1xN)&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When trying the function one by one it seemed as z was transposed when i sent it in so i just did that as a quick fix.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Jul 2018 14:23:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Global-variables-in-nested-optimization-problem/m-p/477498#M4284</guid>
      <dc:creator>jan_t_lagen</dc:creator>
      <dc:date>2018-07-12T14:23:00Z</dc:date>
    </item>
    <item>
      <title>Re: Global variables in nested optimization problem</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Global-variables-in-nested-optimization-problem/m-p/477499#M4285</link>
      <description>&lt;P&gt;I should have shown the step where i define them, my bad. (They are all vectors of length 1xN)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'll start reading up on what you linked me, thank you!&lt;/P&gt;</description>
      <pubDate>Thu, 12 Jul 2018 14:24:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Global-variables-in-nested-optimization-problem/m-p/477499#M4285</guid>
      <dc:creator>jan_t_lagen</dc:creator>
      <dc:date>2018-07-12T14:24:07Z</dc:date>
    </item>
  </channel>
</rss>

