<?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: Proc Optmodel to minimize Mean Absolute Error in Mathematical Optimization, Discrete-Event Simulation, and OR</title>
    <link>https://communities.sas.com/t5/Mathematical-Optimization/Proc-Optmodel-to-minimize-Mean-Absolute-Error/m-p/585005#M2856</link>
    <description>&lt;P&gt;You have declared forecast and sae as numeric constants and explicitly set their values once, so the objective function is a constant that does not depend on the variable a.&amp;nbsp; Instead, you can use implicit variables to get the behavior you want:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;impvar forecast{&amp;lt;i,t&amp;gt; in MASTER_DATES} = 
   if &amp;lt;i,t-1&amp;gt; in MASTER_DATES then performance[i,t-1]*a+(1-a)*forecast[i,t-1]
   else performance[i,t];

impvar sae{&amp;lt;i,t&amp;gt; in MASTER_DATES} = abs(performance[i,t] - forecast[i,t]);
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 29 Aug 2019 17:28:33 GMT</pubDate>
    <dc:creator>RobPratt</dc:creator>
    <dc:date>2019-08-29T17:28:33Z</dc:date>
    <item>
      <title>Proc Optmodel to minimize Mean Absolute Error</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Proc-Optmodel-to-minimize-Mean-Absolute-Error/m-p/584996#M2855</link>
      <description>&lt;P&gt;Using the below code I can calculate absolute error for each month. However, something isn't working when I try to minimize the sum of a created variable, "sae". Effectively, I'm trying to minimize "mae" (which is the average of the "sae" values, excluding the first observation) to find the optimal value for "a".&amp;nbsp;&lt;/P&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;&lt;P&gt;proc optmodel;&lt;BR /&gt;set &amp;lt;str,num&amp;gt; MASTER_DATES;&lt;BR /&gt;set MASTER = setof {&amp;lt;i,t&amp;gt; in MASTER_DATES}i;&lt;BR /&gt;set NROW = setof {&amp;lt;i,t&amp;gt; in MASTER_DATES}t;&lt;/P&gt;&lt;P&gt;num performance {MASTER_DATES};&lt;BR /&gt;num month {MASTER_DATES};&lt;/P&gt;&lt;P&gt;read data example_data1 into MASTER_DATES=[master_nbr nrow] performance month;&lt;/P&gt;&lt;P&gt;num forecast{&amp;lt;i,t&amp;gt; in MASTER_DATES};&lt;BR /&gt;num sae{&amp;lt;i,t&amp;gt; in MASTER_DATES};&lt;/P&gt;&lt;P&gt;var a &amp;gt;=0 &amp;lt;=1;&lt;/P&gt;&lt;P&gt;for {&amp;lt;i,t&amp;gt; in MASTER_DATES} do;&lt;BR /&gt;if &amp;lt;i,t-1&amp;gt; in MASTER_DATES then&lt;BR /&gt;do;&lt;BR /&gt;forecast[i,t] = (performance[i,t-1]*a)+((1-a)*forecast[i,t-1]);&lt;BR /&gt;sae[i,t] = abs(performance[i,t] - forecast[i,t]);&lt;BR /&gt;end;&lt;BR /&gt;else&lt;BR /&gt;do;&lt;BR /&gt;forecast[i,t] = performance[i,t];&lt;BR /&gt;sae[i,t] = 0;&lt;BR /&gt;end;&lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;min mae = (sum {&amp;lt;i,t&amp;gt; in MASTER_DATES} sae[i,t]) / 10;&lt;/P&gt;&lt;P&gt;solve;&lt;BR /&gt;print a;&lt;/P&gt;&lt;P&gt;create data optmodel_outdata from [master_nbr nrow] performance month forecast sae;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Dan&lt;/P&gt;</description>
      <pubDate>Thu, 29 Aug 2019 17:09:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Proc-Optmodel-to-minimize-Mean-Absolute-Error/m-p/584996#M2855</guid>
      <dc:creator>dsklein12</dc:creator>
      <dc:date>2019-08-29T17:09:22Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Optmodel to minimize Mean Absolute Error</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Proc-Optmodel-to-minimize-Mean-Absolute-Error/m-p/585005#M2856</link>
      <description>&lt;P&gt;You have declared forecast and sae as numeric constants and explicitly set their values once, so the objective function is a constant that does not depend on the variable a.&amp;nbsp; Instead, you can use implicit variables to get the behavior you want:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;impvar forecast{&amp;lt;i,t&amp;gt; in MASTER_DATES} = 
   if &amp;lt;i,t-1&amp;gt; in MASTER_DATES then performance[i,t-1]*a+(1-a)*forecast[i,t-1]
   else performance[i,t];

impvar sae{&amp;lt;i,t&amp;gt; in MASTER_DATES} = abs(performance[i,t] - forecast[i,t]);
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 29 Aug 2019 17:28:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Proc-Optmodel-to-minimize-Mean-Absolute-Error/m-p/585005#M2856</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2019-08-29T17:28:33Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Optmodel to minimize Mean Absolute Error</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Proc-Optmodel-to-minimize-Mean-Absolute-Error/m-p/585815#M2859</link>
      <description>Thank you Rob for the explanation. This works perfect!</description>
      <pubDate>Tue, 03 Sep 2019 13:17:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Proc-Optmodel-to-minimize-Mean-Absolute-Error/m-p/585815#M2859</guid>
      <dc:creator>dsklein12</dc:creator>
      <dc:date>2019-09-03T13:17:20Z</dc:date>
    </item>
  </channel>
</rss>

