<?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 Mathematical Optimization, Discrete-Event Simulation, and OR</title>
    <link>https://communities.sas.com/t5/Mathematical-Optimization/PROC-GA-under-non-linear-constraint/m-p/348697#M1732</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;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;</description>
    <pubDate>Mon, 10 Apr 2017 13:47:10 GMT</pubDate>
    <dc:creator>KarolinaA</dc:creator>
    <dc:date>2017-04-10T13:47:10Z</dc:date>
    <item>
      <title>PROC GA under non-linear constraint</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/PROC-GA-under-non-linear-constraint/m-p/348697#M1732</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;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;</description>
      <pubDate>Mon, 10 Apr 2017 13:47:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/PROC-GA-under-non-linear-constraint/m-p/348697#M1732</guid>
      <dc:creator>KarolinaA</dc:creator>
      <dc:date>2017-04-10T13:47:10Z</dc:date>
    </item>
    <item>
      <title>Re: PROC GA under non-linear constraint</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/PROC-GA-under-non-linear-constraint/m-p/348714#M1734</link>
      <description>&lt;P&gt;Some thought.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;function funkc(selected[*]); 
 
call ReadMember(selected,1,x); 
F= 0.1*x[1]*x[2]; &lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;if (5+2.2*cos(10*atan(x[1]/x[2])))**2 - x[1]**2 - x[2]**2&amp;nbsp;&amp;lt; 0 then F=9999999;&lt;/SPAN&gt;&lt;BR /&gt;
return(F);
endsub; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and make population size bigger.&lt;/P&gt;
&lt;PRE&gt;call Initialize('DEFAULT',15000);&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Apr 2017 12:36:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/PROC-GA-under-non-linear-constraint/m-p/348714#M1734</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-04-11T12:36:34Z</dc:date>
    </item>
    <item>
      <title>Re: PROC GA under non-linear constraint</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/PROC-GA-under-non-linear-constraint/m-p/348722#M1735</link>
      <description>Nice idea. Got an error: ERROR: The array 'x' cannot be an argument of the '**' operation.&lt;BR /&gt;</description>
      <pubDate>Mon, 10 Apr 2017 14:38:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/PROC-GA-under-non-linear-constraint/m-p/348722#M1735</guid>
      <dc:creator>KarolinaA</dc:creator>
      <dc:date>2017-04-10T14:38:16Z</dc:date>
    </item>
    <item>
      <title>Re: PROC GA under non-linear constraint</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/PROC-GA-under-non-linear-constraint/m-p/348723#M1736</link>
      <description>Okay. It was very simple. Could you please edit your post and change x to x[1] and y to x[2] and then it would be a solution &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Mon, 10 Apr 2017 14:43:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/PROC-GA-under-non-linear-constraint/m-p/348723#M1736</guid>
      <dc:creator>KarolinaA</dc:creator>
      <dc:date>2017-04-10T14:43:54Z</dc:date>
    </item>
    <item>
      <title>Re: PROC GA under non-linear constraint</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/PROC-GA-under-non-linear-constraint/m-p/348748#M1737</link>
      <description>&lt;P&gt;Here's how you can solve it with the NLP solver in PROC OPTMODEL:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc optmodel;
   var x &amp;gt;= -10 &amp;lt;= 10 init 1;
   var y &amp;gt;= -6  &amp;lt;= 6  init 1;
   min F = 0.1*x*y;
   con Mycon:
      x**2 + y**2 &amp;lt;= (5+2.2*cos(10*atan(x/y)))**2;
   solve with nlp / ms;
   print x y;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 10 Apr 2017 15:23:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/PROC-GA-under-non-linear-constraint/m-p/348748#M1737</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2017-04-10T15:23:56Z</dc:date>
    </item>
  </channel>
</rss>

