<?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: Need help with basic code, proc optmodel, summation notation in Mathematical Optimization, Discrete-Event Simulation, and OR</title>
    <link>https://communities.sas.com/t5/Mathematical-Optimization/Need-help-with-basic-code-proc-optmodel-summation-notation/m-p/776317#M3527</link>
    <description>&lt;P&gt;This helps tremendously.&amp;nbsp; Thanks so much.&lt;/P&gt;</description>
    <pubDate>Mon, 25 Oct 2021 22:32:24 GMT</pubDate>
    <dc:creator>robrob</dc:creator>
    <dc:date>2021-10-25T22:32:24Z</dc:date>
    <item>
      <title>Need help with basic code, proc optmodel, summation notation</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Need-help-with-basic-code-proc-optmodel-summation-notation/m-p/776229#M3525</link>
      <description>&lt;P&gt;I'm new to SAS and not very familiar with summation notation so learning both.&amp;nbsp; I have the following problem: two products: "Gin" and "Kol" produced in three locations: "Eth" "Tan" "Nig" with variable cost as follows:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Gin&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Kol&lt;/P&gt;&lt;P&gt;Eth&amp;nbsp; &amp;nbsp; &amp;nbsp;21.00&amp;nbsp; &amp;nbsp; &amp;nbsp;22.50&lt;/P&gt;&lt;P&gt;Tan&amp;nbsp; &amp;nbsp; &amp;nbsp;22.50&amp;nbsp; &amp;nbsp; &amp;nbsp;24.50&lt;/P&gt;&lt;P&gt;Nig&amp;nbsp; &amp;nbsp; &amp;nbsp;23.00&amp;nbsp; &amp;nbsp; &amp;nbsp;25.50&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Constraints are&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;demand for Gin is 550 and for Kol is 450&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;plant capacity Eth 425 Tan 400 Nig 750&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My error ridden code so far is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;proc optmodel;

set loc={"Eth", "Tan", "Nig"};
set type={"Gin", "Kol"};
number cost{type, loc}=[21.00 22.50 
					22.50 24.50 
					23.00 25.50];
number dem{type}=[550 450];
number cap{loc}=[425 400 750];
number fc{loc}=[1500 2000 3000];

var x{loc, type} &amp;gt;=0;
var y binary;

minimize total_cost = sum{i,j in x, i,j in cost} x[i,j]*cost[i,j];


con capacity: sum{i in loc}x[i,j]&amp;lt;=cap[i];
con demand: sum{j in type}x[i,j]&amp;lt;=dem[j];

solve; 

print x;

quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Any help is greatly appreciated!&lt;/P&gt;</description>
      <pubDate>Mon, 25 Oct 2021 16:25:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Need-help-with-basic-code-proc-optmodel-summation-notation/m-p/776229#M3525</guid>
      <dc:creator>robrob</dc:creator>
      <dc:date>2021-10-25T16:25:37Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with basic code, proc optmodel, summation notation</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Need-help-with-basic-code-proc-optmodel-summation-notation/m-p/776268#M3526</link>
      <description>&lt;P&gt;In the cost declaration, the syntax is correct, but you need to reverse the arguments:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*number cost{type, loc}=[21.00 22.50 */
number cost{loc, type}=[21.00 22.50 
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;In the objective declaration, you need to refer to the index sets in the SUM operator:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*minimize total_cost = sum{i,j in x, i,j in cost} x[i,j]*cost[i,j];*/
minimize total_cost = sum{i in loc, j in type} x[i,j]*cost[i,j];
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;In the capacity constraint declaration, you need an index for each constraint, and the sum is over j:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*con capacity: sum{i in loc}x[i,j]&amp;lt;=cap[i];*/
con capacity{i in loc}: sum{j in type}x[i,j]&amp;lt;=cap[i];
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;In the demand constraint declaration, you need an index for each constraint, the sum is over i, and the &amp;lt;= should be &amp;gt;=:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*con demand: sum{j in type}x[i,j]&amp;lt;=dem[j];*/
con demand{j in type}: sum{i in loc}x[i,j]&amp;gt;=dem[j];
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;As a new user, you might find&amp;nbsp;&lt;A href="https://go.documentation.sas.com/doc/en/ormpex/15.2/titlepage.htm" target="_self"&gt;this book of examples&lt;/A&gt; helpful.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Oct 2021 18:32:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Need-help-with-basic-code-proc-optmodel-summation-notation/m-p/776268#M3526</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2021-10-25T18:32:50Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with basic code, proc optmodel, summation notation</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Need-help-with-basic-code-proc-optmodel-summation-notation/m-p/776317#M3527</link>
      <description>&lt;P&gt;This helps tremendously.&amp;nbsp; Thanks so much.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Oct 2021 22:32:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Need-help-with-basic-code-proc-optmodel-summation-notation/m-p/776317#M3527</guid>
      <dc:creator>robrob</dc:creator>
      <dc:date>2021-10-25T22:32:24Z</dc:date>
    </item>
  </channel>
</rss>

