<?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 PROC GA under non-linear constraint in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/PROC-GA-under-non-linear-constraint/m-p/348594#M63705</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a function I neet to optimize using PROC GA and it is&amp;nbsp;simple -- &amp;nbsp;0.1*x*y. But then I have constraint which is not&amp;nbsp;that&amp;nbsp;simple &amp;nbsp;x**2 + y**2&amp;nbsp;&amp;lt;= (5+2.2*cos(10*atan(x/y)))**2. How&amp;nbsp; can I solve this in SAS? Sorry, I am very new with SAS. My code so far looks like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;proc ga seed = 12 maxiter = 30; 
 
function funkc(selected[*]); 
array x[2] /nosym; 
call ReadMember(selected,1,x); 
x1 = x[1]; 
x2 = x[2]; 
F= 0.1*x1*x2; 
return(F);
endsub; 
 
call SetEncoding('R2'); 
array LowerBound[2] /nosym (-10 -6); 
array UpperBound[2] /nosym (10 6); 
call SetBounds(LowerBound, UpperBound);  
call SetObjFunc('funkc',0); 
call SetCrossProb(0.65); 
call SetCross('Heuristic'); 
call SetMutProb(0.15); 
array del[2] /nosym (0.2 0.2); 
call SetMut('Delta','nchange', 1, 'delta',del); 
call SetSel('tournament','size', 2); 
call SetElite(2); 
call Initialize('DEFAULT',150); 
run; 
quit; &lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 10 Apr 2017 05:34:29 GMT</pubDate>
    <dc:creator>KarolinaA</dc:creator>
    <dc:date>2017-04-10T05:34:29Z</dc:date>
    <item>
      <title>PROC GA under non-linear constraint</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-GA-under-non-linear-constraint/m-p/348594#M63705</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a function I neet to optimize using PROC GA and it is&amp;nbsp;simple -- &amp;nbsp;0.1*x*y. But then I have constraint which is not&amp;nbsp;that&amp;nbsp;simple &amp;nbsp;x**2 + y**2&amp;nbsp;&amp;lt;= (5+2.2*cos(10*atan(x/y)))**2. How&amp;nbsp; can I solve this in SAS? Sorry, I am very new with SAS. My code so far looks like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;proc ga seed = 12 maxiter = 30; 
 
function funkc(selected[*]); 
array x[2] /nosym; 
call ReadMember(selected,1,x); 
x1 = x[1]; 
x2 = x[2]; 
F= 0.1*x1*x2; 
return(F);
endsub; 
 
call SetEncoding('R2'); 
array LowerBound[2] /nosym (-10 -6); 
array UpperBound[2] /nosym (10 6); 
call SetBounds(LowerBound, UpperBound);  
call SetObjFunc('funkc',0); 
call SetCrossProb(0.65); 
call SetCross('Heuristic'); 
call SetMutProb(0.15); 
array del[2] /nosym (0.2 0.2); 
call SetMut('Delta','nchange', 1, 'delta',del); 
call SetSel('tournament','size', 2); 
call SetElite(2); 
call Initialize('DEFAULT',150); 
run; 
quit; &lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Apr 2017 05:34:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-GA-under-non-linear-constraint/m-p/348594#M63705</guid>
      <dc:creator>KarolinaA</dc:creator>
      <dc:date>2017-04-10T05:34:29Z</dc:date>
    </item>
    <item>
      <title>Re: PROC GA under non-linear constraint</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-GA-under-non-linear-constraint/m-p/348688#M63713</link>
      <description>&lt;P&gt;I really suggest you to use&amp;nbsp;Nonlinear Optimization Function, since GA can not guarantee you to get the optimal solution.&lt;/P&gt;
&lt;P&gt;And better post it at IML forum.&lt;/P&gt;
&lt;P&gt;If you want stick with PROC GA ,then post it at OR forum, since PROC GA is under SAS/OR.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc iml;
start F_UC2D(x);
f = 0.1*x[1]*x[2];;
return(f);
finish F_UC2D;

start C_UC2D(x);
c = (5+2.2*cos(10*atan(x[1]/x[2])))**2 - x[1]**2 - x[2]**2 ;
return(c);
finish C_UC2D;

x = j(1,2,0.5);
optn= j(1,10,.);optn[1]=0; optn[2]= 1; optn[10]= 1;
CALL NLPNMS(rc,xres,"F_UC2D",x,optn) nlc="C_UC2D";

print rc[l='rc&amp;gt;0 means find a soultion'],xres[l='solution for x'];
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE id="IDX4" class="table"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="data"&gt;ABSXCONV convergence criterion satisfied.&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;ARTICLE id="IDX5"&gt;
&lt;TABLE class="table"&gt;&lt;COLGROUP&gt;&lt;COL /&gt;&lt;/COLGROUP&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="c b header" scope="col"&gt;rc&amp;gt;0 means find a soultion&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;4&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/ARTICLE&gt;
&lt;ARTICLE id="IDX6"&gt;
&lt;TABLE class="table"&gt;&lt;COLGROUP&gt;&lt;COL /&gt;&lt;COL /&gt;&lt;/COLGROUP&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="c b header" colspan="2" scope="colgroup"&gt;solution for x&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;-4.283178&lt;/TD&gt;
&lt;TD class="r data"&gt;5.7739759&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/ARTICLE&gt;</description>
      <pubDate>Mon, 10 Apr 2017 13:39:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-GA-under-non-linear-constraint/m-p/348688#M63713</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-04-10T13:39:28Z</dc:date>
    </item>
    <item>
      <title>Re: PROC GA under non-linear constraint</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-GA-under-non-linear-constraint/m-p/348690#M63714</link>
      <description>&lt;P&gt;I minimize object function,&lt;/P&gt;
&lt;P&gt;If you want maximize it , use&lt;/P&gt;
&lt;P&gt;optn[1]=1;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Apr 2017 13:35:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-GA-under-non-linear-constraint/m-p/348690#M63714</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-04-10T13:35:10Z</dc:date>
    </item>
  </channel>
</rss>

