<?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: How to use Proc Optmodel to solve for a Multiplier to minimize an objective? in Mathematical Optimization, Discrete-Event Simulation, and OR</title>
    <link>https://communities.sas.com/t5/Mathematical-Optimization/How-to-use-Proc-Optmodel-to-solve-for-a-Multiplier-to-minimize/m-p/477984#M2312</link>
    <description>&lt;P&gt;Wow, that simplifies things. Can't express how thankful I am!&lt;/P&gt;</description>
    <pubDate>Fri, 13 Jul 2018 18:19:32 GMT</pubDate>
    <dc:creator>dsklein12</dc:creator>
    <dc:date>2018-07-13T18:19:32Z</dc:date>
    <item>
      <title>How to use Proc Optmodel to solve for a Multiplier to minimize an objective?</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/How-to-use-Proc-Optmodel-to-solve-for-a-Multiplier-to-minimize/m-p/477953#M2308</link>
      <description>&lt;P&gt;Hi -&lt;/P&gt;&lt;P&gt;I currently have two datasets - forecast and guarantees (see attached). I have a portfolio of products each with a distinct product_id. In the forecast dataset I have projected sales and the current discount being realized by a client. In the guarantee dataset is the respective guarantee offered per product. You will notice that this particular client is getting a better deal on some products (discount &amp;gt; guarantee) and worse deals (discount &amp;lt; guarantee) on others.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My goal is to solve for a&amp;nbsp; common Factor that would be used to multiply by the discount of all the products so that the good deals and bad deals zero out (or common as close to 0 as possible).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;See below what I've tried, which obviously is not working. Not sure where to go from here. Any help would be much appreciated! Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc optmodel;&lt;BR /&gt;set &amp;lt;str&amp;gt; FORECAST;&lt;BR /&gt;set &amp;lt;str&amp;gt; GUARANTEES;&lt;BR /&gt;num discount {FORECAST};&lt;BR /&gt;num proj_sales {FORECAST};&lt;BR /&gt;num Guarantee {GUARANTEES};&lt;BR /&gt;read data work.forecast into FORECAST=[product_id] discount proj_sales;&lt;BR /&gt;read data work.guarantees into GUARANTEES=[product_id] Guarantee;&lt;/P&gt;&lt;P&gt;var factor {FORECAST};&lt;/P&gt;&lt;P&gt;impvar new_rate {fac in FORECAST} = discount[fac] * factor[fac];&lt;BR /&gt;impvar variance {fac in FORECAST} = new_rate[fac] - Guarantee[gtee]; /*ERROR: gtee is unknown*/&lt;BR /&gt;impvar sales_performance {fac in FORECAST} = variance[fac] * proj_sales[fac];&lt;BR /&gt;&lt;BR /&gt;/* I'm not sure how to set a minimum objective with the constraint that it has to be &amp;gt;= 0 */&lt;BR /&gt;min x = sum {fac in FORECAST} sales_performance[fac];&lt;/P&gt;&lt;P&gt;con c1:&lt;BR /&gt;x &amp;gt;= 0;&lt;/P&gt;&lt;P&gt;solve;&lt;BR /&gt;print factor;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jul 2018 17:01:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/How-to-use-Proc-Optmodel-to-solve-for-a-Multiplier-to-minimize/m-p/477953#M2308</guid>
      <dc:creator>dsklein12</dc:creator>
      <dc:date>2018-07-13T17:01:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to use Proc Optmodel to solve for a Multiplier to minimize an objective?</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/How-to-use-Proc-Optmodel-to-solve-for-a-Multiplier-to-minimize/m-p/477970#M2309</link>
      <description>&lt;P&gt;If I understand correctly, you want a common value of factor across all products, so your problem has only one decision variable (not one per product), as follows:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc optmodel;
   set &amp;lt;str&amp;gt; PRODUCTS;
   num discount {PRODUCTS};
   num proj_sales {PRODUCTS};
   num Guarantee {PRODUCTS};
   read data work.indata into PRODUCTS=[product_id] discount proj_sales Guarantee;

   var factor;

   impvar new_rate {p in PRODUCTS} = discount[p] * factor;
   impvar variance {p in PRODUCTS} = new_rate[p] - Guarantee[p];
   impvar sales_performance {p in PRODUCTS} = variance[p] * proj_sales[p];

   con c1: sum {p in PRODUCTS} sales_performance[p] = 0;

   solve;
   print factor;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The resulting value for factor is:&lt;/P&gt;
&lt;DIV class="branch"&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" summary="Procedure Optmodel: PrintTable" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;1.14663218567975&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But that approach is overkill.&amp;nbsp; Your constraint reduces to&amp;nbsp;the following equation, where factor is the only variable:&lt;/P&gt;
&lt;P&gt;sum {p in PRODUCTS} (discount[p] * factor - Guarantee[p]) * proj_sales[p] = 0&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Solving this linear equation&amp;nbsp;algebraically for factor yields the explicit formula:&lt;/P&gt;
&lt;P&gt;factor = (sum {p in PRODUCTS} Guarantee[p] * proj_sales[p]) / (sum {p in PRODUCTS} discount[p] * proj_sales[p])&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As you can check, this formula also yields:&lt;/P&gt;
&lt;DIV class="branch"&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" summary="Procedure Optmodel: PrintTable" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;1.14663218567975&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Fri, 13 Jul 2018 17:53:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/How-to-use-Proc-Optmodel-to-solve-for-a-Multiplier-to-minimize/m-p/477970#M2309</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2018-07-13T17:53:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to use Proc Optmodel to solve for a Multiplier to minimize an objective?</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/How-to-use-Proc-Optmodel-to-solve-for-a-Multiplier-to-minimize/m-p/477974#M2310</link>
      <description>&lt;P&gt;This worked!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For the linear equation would you just replace the solver call with the formula you mention?&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jul 2018 18:05:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/How-to-use-Proc-Optmodel-to-solve-for-a-Multiplier-to-minimize/m-p/477974#M2310</guid>
      <dc:creator>dsklein12</dc:creator>
      <dc:date>2018-07-13T18:05:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to use Proc Optmodel to solve for a Multiplier to minimize an objective?</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/How-to-use-Proc-Optmodel-to-solve-for-a-Multiplier-to-minimize/m-p/477983#M2311</link>
      <description>&lt;P&gt;You can replace everything after READ DATA with this one line:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;   print ((sum {p in PRODUCTS} Guarantee[p] * proj_sales[p]) / (sum {p in PRODUCTS} discount[p] * proj_sales[p])) best32.;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 13 Jul 2018 18:17:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/How-to-use-Proc-Optmodel-to-solve-for-a-Multiplier-to-minimize/m-p/477983#M2311</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2018-07-13T18:17:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to use Proc Optmodel to solve for a Multiplier to minimize an objective?</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/How-to-use-Proc-Optmodel-to-solve-for-a-Multiplier-to-minimize/m-p/477984#M2312</link>
      <description>&lt;P&gt;Wow, that simplifies things. Can't express how thankful I am!&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jul 2018 18:19:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/How-to-use-Proc-Optmodel-to-solve-for-a-Multiplier-to-minimize/m-p/477984#M2312</guid>
      <dc:creator>dsklein12</dc:creator>
      <dc:date>2018-07-13T18:19:32Z</dc:date>
    </item>
  </channel>
</rss>

