<?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 Minimizing a numerical integration in Mathematical Optimization, Discrete-Event Simulation, and OR</title>
    <link>https://communities.sas.com/t5/Mathematical-Optimization/Minimizing-a-numerical-integration/m-p/112944#M665</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I have an optimization problem where I want to minimize a numerical integration subject to certain constraints. Suppose that the objective function (the integration of "FUN") and the constraint are both computed using loops. I have one decesion variable "T" and one integration variable "M". I already wrote a part of the code(the part i wrote just performs the numerical integration )I really need&amp;nbsp; to complete the code . What I need to complete is to minimize the integration of "FUN". The decesion variable is "T" . The constraint I have is computed&amp;nbsp; in the same way of&amp;nbsp; "FUN" , but with M=0 &amp;amp;&amp;nbsp; "FUN"is restricted to the value "10". In otherwords, I want to minimize the integration of "FUN" where the integration variable is M, subject to the constraint that "FUN"=10 at M=0 and the decesion variable in this optimization is "T".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The code I was able to write(integrating "FUN") is:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc iml;&lt;/P&gt;&lt;P&gt;start FUN(M);&lt;/P&gt;&lt;P&gt;x=0;&lt;/P&gt;&lt;P&gt;R=0;&lt;/P&gt;&lt;P&gt;do until (x&amp;lt;T);&lt;/P&gt;&lt;P&gt;x=normal(-1)+M;&lt;/P&gt;&lt;P&gt;R=R+5;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;return(R);&lt;/P&gt;&lt;P&gt;finish;&lt;/P&gt;&lt;P&gt;a={0 1}&lt;/P&gt;&lt;P&gt;call quad(k,"FUN",a};&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Emara&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 31 Oct 2012 12:48:18 GMT</pubDate>
    <dc:creator>Emara</dc:creator>
    <dc:date>2012-10-31T12:48:18Z</dc:date>
    <item>
      <title>Minimizing a numerical integration</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Minimizing-a-numerical-integration/m-p/112944#M665</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I have an optimization problem where I want to minimize a numerical integration subject to certain constraints. Suppose that the objective function (the integration of "FUN") and the constraint are both computed using loops. I have one decesion variable "T" and one integration variable "M". I already wrote a part of the code(the part i wrote just performs the numerical integration )I really need&amp;nbsp; to complete the code . What I need to complete is to minimize the integration of "FUN". The decesion variable is "T" . The constraint I have is computed&amp;nbsp; in the same way of&amp;nbsp; "FUN" , but with M=0 &amp;amp;&amp;nbsp; "FUN"is restricted to the value "10". In otherwords, I want to minimize the integration of "FUN" where the integration variable is M, subject to the constraint that "FUN"=10 at M=0 and the decesion variable in this optimization is "T".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The code I was able to write(integrating "FUN") is:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc iml;&lt;/P&gt;&lt;P&gt;start FUN(M);&lt;/P&gt;&lt;P&gt;x=0;&lt;/P&gt;&lt;P&gt;R=0;&lt;/P&gt;&lt;P&gt;do until (x&amp;lt;T);&lt;/P&gt;&lt;P&gt;x=normal(-1)+M;&lt;/P&gt;&lt;P&gt;R=R+5;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;return(R);&lt;/P&gt;&lt;P&gt;finish;&lt;/P&gt;&lt;P&gt;a={0 1}&lt;/P&gt;&lt;P&gt;call quad(k,"FUN",a};&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Emara&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 31 Oct 2012 12:48:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Minimizing-a-numerical-integration/m-p/112944#M665</guid>
      <dc:creator>Emara</dc:creator>
      <dc:date>2012-10-31T12:48:18Z</dc:date>
    </item>
    <item>
      <title>Re: Minimizing a numerical integration</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Minimizing-a-numerical-integration/m-p/112945#M666</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Emara,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There's a quite similar posting about this on comp.soft-sys.sas which I believe is from you as well.&lt;BR /&gt;I've responded in the newsgroup but will respond here also in the interest of getting the information&lt;BR /&gt;to as many interested parties as possible.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for posting this question.&amp;nbsp; The best way to do this currently&lt;BR /&gt;is to use PROC NLP along with PROC FCMP (a Base SAS procedure) to &lt;BR /&gt;define the objective function.&amp;nbsp; I consulted with one of our developers&lt;BR /&gt;on this question and he sent some sample code which uses this approach&lt;BR /&gt;for a problem that's pretty similar to yours.&amp;nbsp; It's included at the &lt;BR /&gt;end of this email.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PROC OPTMODEL in SAS/OR is the successor to PROC NLP (it handles&lt;/P&gt;&lt;P&gt;not only nonlinear but also linear, mixed integer, and quadratic optimization). &lt;/P&gt;&lt;P&gt;However OPTMODEL is not yet FCMP-enabled and so it's best, given your&lt;/P&gt;&lt;P&gt;requirements, for you to stick with PROC NLP for now.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you have any questions please feel free to contact me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Ed Hughes&lt;BR /&gt;SAS/OR Product Manager&lt;BR /&gt;919-531-6916&lt;BR /&gt;&lt;A href="mailto:Ed.Hughes@sas.com"&gt;Ed.Hughes@sas.com&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sample code follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data barddata;&lt;BR /&gt; input y @@;&lt;BR /&gt; datalines;&lt;BR /&gt;0.14 0.18 0.22 0.25 0.29 0.32 0.35 0.39&lt;BR /&gt;0.37 0.58 0.73 0.96 1.34 2.10 4.39&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;proc fcmp outlib=work.myfuncs.test;&lt;BR /&gt; function bard(x1, x2, x3);&lt;BR /&gt;&amp;nbsp; array y[15] /nosymbols ;&lt;BR /&gt;&amp;nbsp; rc = read_array('barddata', y);&lt;BR /&gt;&amp;nbsp; fx = 0;&lt;BR /&gt;&amp;nbsp; do k = 1 to 15; &lt;BR /&gt;&amp;nbsp;&amp;nbsp; vk = 16 - k;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; wk = min(k,vk);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; fxk = y&lt;K&gt; - (x1 + k/(vk*x2 + wk*x3));&lt;BR /&gt;&amp;nbsp;&amp;nbsp; fx = fx + fxk**2;&lt;BR /&gt;&amp;nbsp; end;&lt;BR /&gt;&amp;nbsp; return (0.5*fx);&lt;BR /&gt; endsub;&lt;BR /&gt;run;&lt;/K&gt;&lt;/P&gt;&lt;P&gt;options cmplib = work.myfuncs;&lt;/P&gt;&lt;P&gt;proc nlp;&lt;BR /&gt; parms x1 x2 x3 = 1.0;&lt;BR /&gt;&amp;nbsp; bounds&amp;nbsp; 0 &amp;lt;= x1 &amp;lt;= 10,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0 &amp;lt;= x2 &amp;lt;= 10,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0 &amp;lt;= x3 &amp;lt;= 10;&lt;BR /&gt; min bardfn;&lt;BR /&gt; bardfn = bard(x1,x2,x3);&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 31 Oct 2012 20:50:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Minimizing-a-numerical-integration/m-p/112945#M666</guid>
      <dc:creator>Ed_Hughes_sas</dc:creator>
      <dc:date>2012-10-31T20:50:46Z</dc:date>
    </item>
  </channel>
</rss>

