<?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 using nlpcg in sas iml in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/using-nlpcg-in-sas-iml/m-p/136454#M1097</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying to minimize the function&lt;/P&gt;&lt;P&gt;f =(w1+a1x+b1y)^2 +(w2+a2x+b2y)^2 subject to&lt;/P&gt;&lt;P&gt;1 &amp;lt; x,y&amp;lt; 55 using the nlpcg routine.&lt;/P&gt;&lt;P&gt;I first define a global variable m which contains the&lt;/P&gt;&lt;P&gt;coefficients Wi, Ai, Bi-the data. So&lt;/P&gt;&lt;P&gt;m is a 2x3 matrix with first row (w1 a1 b1) and second row&lt;/P&gt;&lt;P&gt;(w2 a2 b2).The starting point is x=(1,1). I want the optimal x that will minimize f.I &lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;have the following sas code to define the Objective&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt; function. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Start f(x) global (m);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sum= m [,2:3]*x + m [,1];&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; res = ssq (sum);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return res;&lt;/P&gt;&lt;P&gt;Finish f;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;con={ 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 55&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 55};&lt;/P&gt;&lt;P&gt;x=j (2,1,1);&lt;/P&gt;&lt;P&gt;opt={0 3};&lt;/P&gt;&lt;P&gt;call nlpcg (rc, xr,"f", x, con);&lt;/P&gt;&lt;P&gt;print rc; print xr;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;I get an error that says (execution) matrix does not conform to operation pointing to the line inside f where I do the multiplication m [,2:3]*x. I don't recall the exact words in the message but IML objects to the part where I multiply m and x. Then it says rc and xr do not have values.&amp;nbsp; I have tried doing the multiplication inside a DO LOOP ...extracting each row of m and multiplying by x. This also gives an error though the message is slightly different-it says rc=100. I thought rc is at most 10. In any case I would rather not use the DO loop. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Would appreciate any help with the problem.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 10 Jun 2014 17:39:30 GMT</pubDate>
    <dc:creator>nstdt</dc:creator>
    <dc:date>2014-06-10T17:39:30Z</dc:date>
    <item>
      <title>using nlpcg in sas iml</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/using-nlpcg-in-sas-iml/m-p/136454#M1097</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying to minimize the function&lt;/P&gt;&lt;P&gt;f =(w1+a1x+b1y)^2 +(w2+a2x+b2y)^2 subject to&lt;/P&gt;&lt;P&gt;1 &amp;lt; x,y&amp;lt; 55 using the nlpcg routine.&lt;/P&gt;&lt;P&gt;I first define a global variable m which contains the&lt;/P&gt;&lt;P&gt;coefficients Wi, Ai, Bi-the data. So&lt;/P&gt;&lt;P&gt;m is a 2x3 matrix with first row (w1 a1 b1) and second row&lt;/P&gt;&lt;P&gt;(w2 a2 b2).The starting point is x=(1,1). I want the optimal x that will minimize f.I &lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;have the following sas code to define the Objective&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt; function. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Start f(x) global (m);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sum= m [,2:3]*x + m [,1];&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; res = ssq (sum);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return res;&lt;/P&gt;&lt;P&gt;Finish f;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;con={ 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 55&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 55};&lt;/P&gt;&lt;P&gt;x=j (2,1,1);&lt;/P&gt;&lt;P&gt;opt={0 3};&lt;/P&gt;&lt;P&gt;call nlpcg (rc, xr,"f", x, con);&lt;/P&gt;&lt;P&gt;print rc; print xr;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;I get an error that says (execution) matrix does not conform to operation pointing to the line inside f where I do the multiplication m [,2:3]*x. I don't recall the exact words in the message but IML objects to the part where I multiply m and x. Then it says rc and xr do not have values.&amp;nbsp; I have tried doing the multiplication inside a DO LOOP ...extracting each row of m and multiplying by x. This also gives an error though the message is slightly different-it says rc=100. I thought rc is at most 10. In any case I would rather not use the DO loop. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Would appreciate any help with the problem.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Jun 2014 17:39:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/using-nlpcg-in-sas-iml/m-p/136454#M1097</guid>
      <dc:creator>nstdt</dc:creator>
      <dc:date>2014-06-10T17:39:30Z</dc:date>
    </item>
    <item>
      <title>Re: using nlpcg in sas iml</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/using-nlpcg-in-sas-iml/m-p/136455#M1098</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The problem is that when IML calls your objective function during the optimization, it is supplying a row vector for x. Try transposing x in the second line of your objective module, i.e.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sum= m [,2:3]*x` + m [,1];&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and see if that doesn't work as it is supposed to.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Jun 2014 20:15:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/using-nlpcg-in-sas-iml/m-p/136455#M1098</guid>
      <dc:creator>Hutch_sas</dc:creator>
      <dc:date>2014-06-10T20:15:44Z</dc:date>
    </item>
    <item>
      <title>Re: using nlpcg in sas iml</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/using-nlpcg-in-sas-iml/m-p/136456#M1099</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I tried that but it gives me a different error now :&lt;/P&gt;&lt;P&gt;Execution error as noted previously (rc = 100).I have also dropped the constants with from my input since they should not make a difference to the minimization. &lt;/P&gt;&lt;P&gt;What does this rc=100 indicate? &lt;/P&gt;&lt;P&gt;Thanks for any help. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Jun 2014 09:32:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/using-nlpcg-in-sas-iml/m-p/136456#M1099</guid>
      <dc:creator>nstdt</dc:creator>
      <dc:date>2014-06-12T09:32:56Z</dc:date>
    </item>
    <item>
      <title>Re: using nlpcg in sas iml</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/using-nlpcg-in-sas-iml/m-p/136457#M1100</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Could you post your current program, and your run-time log?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Jun 2014 12:35:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/using-nlpcg-in-sas-iml/m-p/136457#M1100</guid>
      <dc:creator>Hutch_sas</dc:creator>
      <dc:date>2014-06-12T12:35:57Z</dc:date>
    </item>
    <item>
      <title>Re: using nlpcg in sas iml</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/using-nlpcg-in-sas-iml/m-p/136458#M1101</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Actually you're suggestion does work. I think that in addition to the transposed vector x, the variable passed into f was called something else inside the body of f( it was not called x inside).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks so much for the help! &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Jun 2014 18:40:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/using-nlpcg-in-sas-iml/m-p/136458#M1101</guid>
      <dc:creator>nstdt</dc:creator>
      <dc:date>2014-06-12T18:40:34Z</dc:date>
    </item>
  </channel>
</rss>

