<?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 do i find argmax of the solution  in OPTMODEL?? in Mathematical Optimization, Discrete-Event Simulation, and OR</title>
    <link>https://communities.sas.com/t5/Mathematical-Optimization/How-do-i-find-argmax-of-the-solution-in-OPTMODEL/m-p/330225#M1656</link>
    <description>&lt;P&gt;There is no built-in support for argmax of an array, but here are five ways to compute it yourself:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc optmodel;
   set MYSET = /a b c d e/;
   num a {MYSET} = [13 100 37 100 42];
   num max = max {i in MYSET} a[i];
   put max=;

   /* set of indices that achieve the max */
   set ARGMAXSET = {i in MYSET: a[i] = max};
   put ARGMAXSET=;

   /* last index that achieves the precomputed max */
   str argmax;
   for {i in MYSET: a[i] = max} argmax = i;
   put argmax=;

   /* first index that achieves the precomputed max */
   for {i in MYSET: a[i] = max} do;
      argmax = i;
      leave;
   end;
   put argmax=;

   /* last index that achieves the max, calculated within the loop */
   num max1 init -constant('BIG');
   for {i in MYSET} do;
      if max1 &amp;lt;= a[i] then do;
         max1 = a[i];
         argmax = i;
      end;
   end;
   put max1= argmax=;

   /* first index that achieves the max, calculated within the loop */
   num max2 init -constant('BIG');
   for {i in MYSET} do;
      if max2 &amp;lt; a[i] then do;
         max2 = a[i];
         argmax = i;
      end;
   end;
   put max2= argmax=;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;For some examples of row generation in&amp;nbsp;PROC OPTMODEL, see this SAS Global Forum paper...&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/resources/papers/proceedings16/SAS3161-2016.pdf" target="_blank"&gt;http://support.sas.com/resources/papers/proceedings16/SAS3161-2016.pdf&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;...and the "Milk Collection" and "Lost Baggage Distribution" examples in the SAS/OR doc:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://go.documentation.sas.com/?docsetId=ormpex&amp;amp;docsetVersion=14.2&amp;amp;docsetTarget=titlepage.htm&amp;amp;locale=en" target="_blank"&gt;http://go.documentation.sas.com/?docsetId=ormpex&amp;amp;docsetVersion=14.2&amp;amp;docsetTarget=titlepage.htm&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 06 Feb 2017 16:20:10 GMT</pubDate>
    <dc:creator>RobPratt</dc:creator>
    <dc:date>2017-02-06T16:20:10Z</dc:date>
    <item>
      <title>How do i find argmax of the solution  in OPTMODEL??</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/How-do-i-find-argmax-of-the-solution-in-OPTMODEL/m-p/330099#M1655</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to do an iterative linearization procedure by row generation in proc optmodel. Between successive iterations i need to find the argmax of the current solution and also store the solution value of that particular index to add a cut and the cuts keep accumulating until convergence is reached. I could not find a fucntion that could give me the index. what is the best way to go about this?&lt;/P&gt;</description>
      <pubDate>Mon, 06 Feb 2017 05:12:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/How-do-i-find-argmax-of-the-solution-in-OPTMODEL/m-p/330099#M1655</guid>
      <dc:creator>karthick_gopal</dc:creator>
      <dc:date>2017-02-06T05:12:25Z</dc:date>
    </item>
    <item>
      <title>Re: How do i find argmax of the solution  in OPTMODEL??</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/How-do-i-find-argmax-of-the-solution-in-OPTMODEL/m-p/330225#M1656</link>
      <description>&lt;P&gt;There is no built-in support for argmax of an array, but here are five ways to compute it yourself:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc optmodel;
   set MYSET = /a b c d e/;
   num a {MYSET} = [13 100 37 100 42];
   num max = max {i in MYSET} a[i];
   put max=;

   /* set of indices that achieve the max */
   set ARGMAXSET = {i in MYSET: a[i] = max};
   put ARGMAXSET=;

   /* last index that achieves the precomputed max */
   str argmax;
   for {i in MYSET: a[i] = max} argmax = i;
   put argmax=;

   /* first index that achieves the precomputed max */
   for {i in MYSET: a[i] = max} do;
      argmax = i;
      leave;
   end;
   put argmax=;

   /* last index that achieves the max, calculated within the loop */
   num max1 init -constant('BIG');
   for {i in MYSET} do;
      if max1 &amp;lt;= a[i] then do;
         max1 = a[i];
         argmax = i;
      end;
   end;
   put max1= argmax=;

   /* first index that achieves the max, calculated within the loop */
   num max2 init -constant('BIG');
   for {i in MYSET} do;
      if max2 &amp;lt; a[i] then do;
         max2 = a[i];
         argmax = i;
      end;
   end;
   put max2= argmax=;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;For some examples of row generation in&amp;nbsp;PROC OPTMODEL, see this SAS Global Forum paper...&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/resources/papers/proceedings16/SAS3161-2016.pdf" target="_blank"&gt;http://support.sas.com/resources/papers/proceedings16/SAS3161-2016.pdf&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;...and the "Milk Collection" and "Lost Baggage Distribution" examples in the SAS/OR doc:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://go.documentation.sas.com/?docsetId=ormpex&amp;amp;docsetVersion=14.2&amp;amp;docsetTarget=titlepage.htm&amp;amp;locale=en" target="_blank"&gt;http://go.documentation.sas.com/?docsetId=ormpex&amp;amp;docsetVersion=14.2&amp;amp;docsetTarget=titlepage.htm&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Feb 2017 16:20:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/How-do-i-find-argmax-of-the-solution-in-OPTMODEL/m-p/330225#M1656</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2017-02-06T16:20:10Z</dc:date>
    </item>
    <item>
      <title>Re: How do i find argmax of the solution  in OPTMODEL??</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/How-do-i-find-argmax-of-the-solution-in-OPTMODEL/m-p/330565#M1658</link>
      <description>&lt;P&gt;Thank you rob!&lt;/P&gt;</description>
      <pubDate>Tue, 07 Feb 2017 18:23:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/How-do-i-find-argmax-of-the-solution-in-OPTMODEL/m-p/330565#M1658</guid>
      <dc:creator>karthick_gopal</dc:creator>
      <dc:date>2017-02-07T18:23:18Z</dc:date>
    </item>
  </channel>
</rss>

