<?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: Problem in NLPQN optimization in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Problem-in-NLPQN-optimization/m-p/292671#M2951</link>
    <description>&lt;P&gt;Hi Rick,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That was the problem. I thought that for each functoin call the function would call again the global as it was proviously defined! Once I have reset to value of the storing matrices it all works!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks four your help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jorge&lt;/P&gt;</description>
    <pubDate>Fri, 19 Aug 2016 08:24:34 GMT</pubDate>
    <dc:creator>jnv</dc:creator>
    <dc:date>2016-08-19T08:24:34Z</dc:date>
    <item>
      <title>Problem in NLPQN optimization</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Problem-in-NLPQN-optimization/m-p/292482#M2949</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to optimize the following code. It tries to find the values of and AR(2) given an initial error variance and a convergence variance.&lt;/P&gt;&lt;P&gt;I have been able to set the problem in Excel Solver and the solution converges. When I try to solve it in SAS I am getting two errors:&lt;/P&gt;&lt;P&gt;Either it doesnt compute anything and give me values of the objective function with the same initial parameters that are larger than if I just call the function with the same values, or it gives me ERROR: Overflow error in *`.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have noticed that the value of the gradient is very large. What puzzles me is why Solver using a gradient search algorithm would be able and SAS IML wont. I have use several routines with no success.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is the code I am using&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc iml; free;

h=10; /*maximum projection horizon*/
W=j(h,h,0); /*Create starting covariance matrix*/
F=j(h,h,0); /*Create parameter matrix*/
int=j(h,h,0);
year=7; /*Create vector with variance convergence*/
var_y=1.7935990244;
fc_cov=j(h,h,0); /*Create covariance matrix*/
lowIdx = do(h+1, (h*h)-1, h+1); /*Index for lower diagonal*/
F[lowIdx]=1;
weight=j(h,1,0);
weight[1:(h-year)]=1;

/*map variance matrix W and paramter matrix F*/
	W[1,1]=0.77;

start minsqre(param) global(h, W, F, int, var_y, fc_cov, weight);

	F[1,1]=param[1];
	F[1,2]=param[2];

/*Project forecast error variance*/

		do j=0 to (h-1);
			int=(F**j)*W*(t(F**j));
			fc_cov=fc_cov+int;
		end;

	y_var=diag(j(h,1,var_y));
	target=sum(diag(weight)#((fc_cov-y_var)##2));
	

	return(target);

finish minsqre;



theta={0.1 0.1};
opt=j(1,11,.); opt[1]=0; opt[2]=5;
cons={	.-1 . .,
		. 1 . .,
		1 1 -1 1,
		-1 1 -1 1 };

/*check4=minsqre(theta);*/
/*print check4;*/


call nlpqn(rc,thetares,"minsqre",theta,opt);



quit;

&lt;/CODE&gt;&lt;/PRE&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, 18 Aug 2016 15:37:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Problem-in-NLPQN-optimization/m-p/292482#M2949</guid>
      <dc:creator>jnv</dc:creator>
      <dc:date>2016-08-18T15:37:13Z</dc:date>
    </item>
    <item>
      <title>Re: Problem in NLPQN optimization</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Problem-in-NLPQN-optimization/m-p/292528#M2950</link>
      <description>&lt;P&gt;So let me see if I undestand your problem. You are MINIMIZING a constrained problem on the triangular region formed by&amp;nbsp;&lt;/P&gt;
&lt;P&gt;-1 &amp;lt;= p2 &amp;lt;= 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;p1 + p2 &amp;lt;= 1&lt;/P&gt;
&lt;P&gt;-p1 + p2 &amp;lt;= 1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't understand what your objective function is computing, but I'm guessing that you have a mistake there. For example, do you really intend for the fc_cov matrix to persist across calls? &amp;nbsp;It looks like you are using that matrix to accumulate some weighted matrix products. &amp;nbsp;If so, you probably want to zero out the fc_cov matrix at the beginning of each call.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If I add the line&lt;/P&gt;
&lt;P&gt;fc_cov=j(h,h,0);&amp;nbsp;&lt;/P&gt;
&lt;P&gt;at the top of the objective function, the NLP routine computes a minimum near (0.9, -0.2) for the initial conditions you specified.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There might not a&amp;nbsp;unique solution for this problem, since other initial conditions seem to converge to other local minima.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Aug 2016 18:54:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Problem-in-NLPQN-optimization/m-p/292528#M2950</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2016-08-18T18:54:57Z</dc:date>
    </item>
    <item>
      <title>Re: Problem in NLPQN optimization</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Problem-in-NLPQN-optimization/m-p/292671#M2951</link>
      <description>&lt;P&gt;Hi Rick,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That was the problem. I thought that for each functoin call the function would call again the global as it was proviously defined! Once I have reset to value of the storing matrices it all works!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks four your help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jorge&lt;/P&gt;</description>
      <pubDate>Fri, 19 Aug 2016 08:24:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Problem-in-NLPQN-optimization/m-p/292671#M2951</guid>
      <dc:creator>jnv</dc:creator>
      <dc:date>2016-08-19T08:24:34Z</dc:date>
    </item>
  </channel>
</rss>

