<?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: Please help in below facility location code in Mathematical Optimization, Discrete-Event Simulation, and OR</title>
    <link>https://communities.sas.com/t5/Mathematical-Optimization/Please-help-in-below-facility-location-code/m-p/350635#M1751</link>
    <description>&lt;P&gt;EXPAND does not apply here, but you can use the PRINT statement to inspect parts of your expression. &amp;nbsp;For example,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;print SumCOG;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;returns the correct value 965.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The issue with your NUM declaration is that you have used Geo both as an index set on the left-hand side and as a summation index set on the right-hand side. &amp;nbsp;I think what you intended is this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;num xcog{j in geo} = sum{i in city} ((Wgt[i]/SumCOG)*cor[i,j]);&lt;BR /&gt;print xcog;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS Output&lt;/P&gt;
&lt;DIV class="branch"&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" summary="Procedure Optmodel: PrintTable" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="l b header" scope="col"&gt;[1]&lt;/TH&gt;
&lt;TH class="r b header" scope="col"&gt;xcog&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Xi&lt;/TH&gt;
&lt;TD class="r data"&gt;77.119&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Yi&lt;/TH&gt;
&lt;TD class="r data"&gt;62.176&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;By the way, the value of MinWgtDis is higher than the minimum value returned by the solver,&amp;nbsp;which you can confirm as follows:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;for {j in Geo} x[j] = xcog[j];
print MinWgtDis;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 17 Apr 2017 20:25:16 GMT</pubDate>
    <dc:creator>RobPratt</dc:creator>
    <dc:date>2017-04-17T20:25:16Z</dc:date>
    <item>
      <title>Please help in below facility location code</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Please-help-in-below-facility-location-code/m-p/350378#M1744</link>
      <description>&lt;P&gt;Hi Folks,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am new to Sas trying to solve below simple facility location, Please advice what I am missing,&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Data&lt;/TD&gt;&lt;TD&gt;Wgt&lt;/TD&gt;&lt;TD&gt;X&lt;/TD&gt;&lt;TD&gt;Y&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Boston&lt;/TD&gt;&lt;TD&gt;425&lt;/TD&gt;&lt;TD&gt;100&lt;/TD&gt;&lt;TD&gt;80&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Providence&lt;/TD&gt;&lt;TD&gt;320&lt;/TD&gt;&lt;TD&gt;86&lt;/TD&gt;&lt;TD&gt;40&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Springfield&lt;/TD&gt;&lt;TD&gt;220&lt;/TD&gt;&lt;TD&gt;20&lt;/TD&gt;&lt;TD&gt;60&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Proc optmodel;&lt;/P&gt;&lt;P&gt;set city = {'BO','PR','SP'};&lt;BR /&gt;set Geo = {'X','Y'};&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;number Cor{city,Geo} =[100 80&amp;nbsp;86 40&amp;nbsp;20 60];&lt;/P&gt;&lt;P&gt;number Wgt{City}=[425 320 220];&lt;/P&gt;&lt;P&gt;var x{city,Geo} integer &amp;gt;= 0;&lt;BR /&gt;var y{city,Geo} integer &amp;gt;= 0;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Minimize MinWgtDis = sum{i in City}sum {j in Geo}&lt;BR /&gt;(sqrt((cor[i,j] - x[i,j])^2 + (cor[i,j] - y[i,j])^2 ))* Wgt[i];&lt;BR /&gt;/*&lt;BR /&gt;con x{i in city,j in Geo}: X[i,j]&amp;lt;=200;&lt;BR /&gt;con y{i in city,j in Geo}: y[i,j]&amp;lt;=200;*/&lt;/P&gt;&lt;P&gt;solve;&lt;/P&gt;&lt;P&gt;print MinWgtDis x y;&lt;BR /&gt;quit;&lt;/P&gt;</description>
      <pubDate>Sun, 16 Apr 2017 18:51:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Please-help-in-below-facility-location-code/m-p/350378#M1744</guid>
      <dc:creator>AAZ</dc:creator>
      <dc:date>2017-04-16T18:51:07Z</dc:date>
    </item>
    <item>
      <title>Re: Please help in below facility location code</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Please-help-in-below-facility-location-code/m-p/350391#M1745</link>
      <description>&lt;P&gt;Here's one way to solve it as an unconstrained problem with nonlinear objective and two variables:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data indata;
   input city $12. Wgt X Y;
   datalines;
Boston      425 100  80
Providence  320  86  40
Springfield 220  20  60
;

proc sgplot data=indata;
   bubble x=x y=y size=wgt / datalabel=city;
run;

proc optmodel;
   set &amp;lt;str&amp;gt; CITIES;
   num wgt {CITIES};
   num xc {CITIES};
   num yc {CITIES};
   read data indata into CITIES=[city] wgt xc=x yc=y;

   var X, Y;

   min MinWgtDis = sum {i in CITIES} (sqrt((xc[i] - X)^2 + (yc[i] - Y)^2)) * wgt[i];

   solve;
   print MinWgtDis X Y;
   create data sganno from function='text' drawspace='datavalue' label='facility' x1=X y1=Y;
quit;

proc sgplot data=indata sganno=sganno;
   bubble x=x y=y size=wgt / datalabel=city;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The resulting plot provides a sanity check on the optimal solution returned.&lt;/P&gt;</description>
      <pubDate>Sun, 16 Apr 2017 21:19:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Please-help-in-below-facility-location-code/m-p/350391#M1745</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2017-04-16T21:19:42Z</dc:date>
    </item>
    <item>
      <title>Re: Please help in below facility location code</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Please-help-in-below-facility-location-code/m-p/350392#M1746</link>
      <description>&lt;P&gt;Wow, that's super! Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to solve it without defining data table, started to get some numbers but am still missing something, can you help me figuring out the error. I think coz I don't have a seperate variable for Xi and Yi&amp;nbsp;it's not working right&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;/P&gt;&lt;P&gt;set city = {'BO','PR','SP'};&lt;BR /&gt;set Geo = {'Xi','Yi'};&lt;/P&gt;&lt;P&gt;number Cor{city,Geo} =[100 80 86 40 20 60];&lt;BR /&gt;number Wgt{city}=[425 320 220];&lt;/P&gt;&lt;P&gt;var x &amp;gt;= 0 ;&lt;BR /&gt;var y &amp;gt;= 0;&lt;BR /&gt;&lt;BR /&gt;Minimize MinWgtDis = sum{i in city} sum {j in Geo}&lt;BR /&gt;((sqrt((cor[i,j] - x)^2 + (cor[i,j] - y)^2 ))* Wgt[i]);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;solve;&lt;/P&gt;&lt;P&gt;print MinWgtDis x y ;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 16 Apr 2017 21:28:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Please-help-in-below-facility-location-code/m-p/350392#M1746</guid>
      <dc:creator>AAZ</dc:creator>
      <dc:date>2017-04-16T21:28:16Z</dc:date>
    </item>
    <item>
      <title>Re: Please help in below facility location code</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Please-help-in-below-facility-location-code/m-p/350393#M1747</link>
      <description>&lt;P&gt;You can use the EXPAND statement to see how the objective function you defined gets populated:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Var x &amp;gt;= 0                                                                                
Var y &amp;gt;= 0                                                                                
Minimize MinWgtDis=SQRT((-x + 100)**2 + (-y + 100)**2)*425 + SQRT((-x + 80)**2 + (-y + 80)
**2)*425 + SQRT((-x + 86)**2 + (-y + 86)**2)*320 + SQRT((-x + 40)**2 + (-y + 40)**2)*320  
 + SQRT((-x + 20)**2 + (-y + 20)**2)*220 + SQRT((-x + 60)**2 + (-y + 60)**2)*220          
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can see that the formula for MinWgtDis is not really what you intended. &amp;nbsp;Here's a modification of your code that instead does what you want:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc optmodel;
set city = {'BO','PR','SP'};
set Geo = {'Xi','Yi'};
number Cor{city,Geo} =[100 80 86 40 20 60];
number Wgt{city}=[425 320 220];
var x {Geo} &amp;gt;= 0 ;

Minimize MinWgtDis = sum{i in city} sqrt(sum {j in Geo} (cor[i,j] - x[j])^2)* Wgt[i];
 
solve;
print MinWgtDis x;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 16 Apr 2017 21:38:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Please-help-in-below-facility-location-code/m-p/350393#M1747</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2017-04-16T21:38:23Z</dc:date>
    </item>
    <item>
      <title>Re: Please help in below facility location code</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Please-help-in-below-facility-location-code/m-p/350595#M1748</link>
      <description>&lt;P&gt;how to use the expand statment to see how the function is&amp;nbsp;populated ?&lt;/P&gt;</description>
      <pubDate>Mon, 17 Apr 2017 18:26:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Please-help-in-below-facility-location-code/m-p/350595#M1748</guid>
      <dc:creator>AAZ</dc:creator>
      <dc:date>2017-04-17T18:26:27Z</dc:date>
    </item>
    <item>
      <title>Re: Please help in below facility location code</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Please-help-in-below-facility-location-code/m-p/350596#M1749</link>
      <description>&lt;P&gt;What I showed above came from the simplest invocation, which expands the whole model:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;expand;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But you can also expand just the objective as follows:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;expand MinWgtDis;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The full documentation for the EXPAND statement is here:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://go.documentation.sas.com/?docsetId=ormpug&amp;amp;docsetVersion=14.2&amp;amp;docsetTarget=ormpug_optmodel_syntax11.htm&amp;amp;locale=en#ormpug.optmodel.npxexpandstmt" target="_blank"&gt;http://go.documentation.sas.com/?docsetId=ormpug&amp;amp;docsetVersion=14.2&amp;amp;docsetTarget=ormpug_optmodel_syntax11.htm&amp;amp;locale=en#ormpug.optmodel.npxexpandstmt&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Apr 2017 18:33:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Please-help-in-below-facility-location-code/m-p/350596#M1749</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2017-04-17T18:33:22Z</dc:date>
    </item>
    <item>
      <title>Re: Please help in below facility location code</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Please-help-in-below-facility-location-code/m-p/350601#M1750</link>
      <description>&lt;P&gt;I actually added two addional lines, but when I write expand, it expands only the optmization formula&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;number SumCOG = sum(of Wgt[*]);&lt;/P&gt;&lt;P&gt;number xcog{geo} = sum{i in city} (sum{j in Geo} (Wgt[i]/SumCOG)*cor[i,j]);&lt;BR /&gt;expand ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;XCOG is not calculated right and want &amp;nbsp;trace it, but it doesn't show up in the expand result.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Apr 2017 18:45:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Please-help-in-below-facility-location-code/m-p/350601#M1750</guid>
      <dc:creator>AAZ</dc:creator>
      <dc:date>2017-04-17T18:45:11Z</dc:date>
    </item>
    <item>
      <title>Re: Please help in below facility location code</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Please-help-in-below-facility-location-code/m-p/350635#M1751</link>
      <description>&lt;P&gt;EXPAND does not apply here, but you can use the PRINT statement to inspect parts of your expression. &amp;nbsp;For example,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;print SumCOG;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;returns the correct value 965.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The issue with your NUM declaration is that you have used Geo both as an index set on the left-hand side and as a summation index set on the right-hand side. &amp;nbsp;I think what you intended is this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;num xcog{j in geo} = sum{i in city} ((Wgt[i]/SumCOG)*cor[i,j]);&lt;BR /&gt;print xcog;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS Output&lt;/P&gt;
&lt;DIV class="branch"&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" summary="Procedure Optmodel: PrintTable" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="l b header" scope="col"&gt;[1]&lt;/TH&gt;
&lt;TH class="r b header" scope="col"&gt;xcog&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Xi&lt;/TH&gt;
&lt;TD class="r data"&gt;77.119&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Yi&lt;/TH&gt;
&lt;TD class="r data"&gt;62.176&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;By the way, the value of MinWgtDis is higher than the minimum value returned by the solver,&amp;nbsp;which you can confirm as follows:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;for {j in Geo} x[j] = xcog[j];
print MinWgtDis;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 17 Apr 2017 20:25:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Please-help-in-below-facility-location-code/m-p/350635#M1751</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2017-04-17T20:25:16Z</dc:date>
    </item>
    <item>
      <title>Re: Please help in below facility location code</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Please-help-in-below-facility-location-code/m-p/350658#M1752</link>
      <description>&lt;P&gt;that's extremly&amp;nbsp;helpful Rob,I need to work on the summation notation.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;when you added&amp;nbsp;&lt;/P&gt;&lt;P&gt;"for {j in Geo} x[j] = xcog[j];&lt;BR /&gt;print MinWgtDis;"&lt;/P&gt;&lt;P&gt;&amp;nbsp;it means untill j holds a value, go back and&amp;nbsp;use the new xcog instead of x &amp;nbsp;to calculate the minimum cost, right ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and to print each and every indvidual X,Y, not the summed one.&lt;/P&gt;&lt;P&gt;I have to put this"sqrt(sum {j in Geo} (cor[i,j] - x[j])^2)* Wgt[i];" &amp;nbsp;in &amp;nbsp;avariable and then print it&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Apr 2017 21:45:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Please-help-in-below-facility-location-code/m-p/350658#M1752</guid>
      <dc:creator>AAZ</dc:creator>
      <dc:date>2017-04-17T21:45:02Z</dc:date>
    </item>
    <item>
      <title>Re: Please help in below facility location code</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Please-help-in-below-facility-location-code/m-p/350662#M1753</link>
      <description>&lt;P&gt;The FOR loop sets&amp;nbsp;x[j] to xcog[j] for each j in Geo. &amp;nbsp;The subsequent PRINT statement prints the new value of MinWgtDis, which gets automatically updated whenever any part of its definition gets updated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A good source for learning about PROC OPTMODEL is&amp;nbsp;&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="_self"&gt;SAS/OR 14.2 User's Guide: Mathematical Programming Examples&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Apr 2017 21:59:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Please-help-in-below-facility-location-code/m-p/350662#M1753</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2017-04-17T21:59:44Z</dc:date>
    </item>
    <item>
      <title>Re: Please help in below facility location code</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Please-help-in-below-facility-location-code/m-p/350993#M1761</link>
      <description>&lt;P&gt;Thank you rob&lt;/P&gt;</description>
      <pubDate>Tue, 18 Apr 2017 19:17:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Please-help-in-below-facility-location-code/m-p/350993#M1761</guid>
      <dc:creator>AAZ</dc:creator>
      <dc:date>2017-04-18T19:17:12Z</dc:date>
    </item>
    <item>
      <title>Re: Please help in below facility location code</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Please-help-in-below-facility-location-code/m-p/352439#M1770</link>
      <description>&lt;P&gt;Hi Rob,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I added this code to your solution, it works fine, is there is a better way to do ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/*Calculating CoG Coordinates */&lt;BR /&gt;num SumCOG = sum(of Wgt[*]);&lt;BR /&gt;for {i in CITIES} X = sum{i in CITIES} (Wgt[i]*xc[i])/SumCOG ;&lt;BR /&gt;for {i in CITIES} Y = sum{i in CITIES} (Wgt[i]*yc[i])/SumCOG ;&lt;/P&gt;&lt;P&gt;print MinWgtDis SumCOG X Y;&lt;BR /&gt;expand;&lt;/P&gt;</description>
      <pubDate>Sat, 22 Apr 2017 15:32:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Please-help-in-below-facility-location-code/m-p/352439#M1770</guid>
      <dc:creator>AAZ</dc:creator>
      <dc:date>2017-04-22T15:32:37Z</dc:date>
    </item>
    <item>
      <title>Re: Please help in below facility location code</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Please-help-in-below-facility-location-code/m-p/353368#M1793</link>
      <description>&lt;P&gt;The FOR loop over CITIES is unnecessary, and you are performing the exact same calculation multiple times. &amp;nbsp;Instead, you can just do this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;X = sum{i in CITIES} (Wgt[i]*xc[i])/SumCOG ;
Y = sum{i in CITIES} (Wgt[i]*yc[i])/SumCOG ;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 25 Apr 2017 18:24:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Please-help-in-below-facility-location-code/m-p/353368#M1793</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2017-04-25T18:24:02Z</dc:date>
    </item>
  </channel>
</rss>

