<?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: Sas Studio Proc Optmodel: Multi-part constraint in Mathematical Optimization, Discrete-Event Simulation, and OR</title>
    <link>https://communities.sas.com/t5/Mathematical-Optimization/Sas-Studio-Proc-Optmodel-Multi-part-constraint/m-p/321004#M1606</link>
    <description>&lt;P&gt;Okay, I'm following you.&amp;nbsp; What about the other error, that one is this there.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; 86         minimize TotalCost = sum {i in Plant} ( sum {j in Product} ( X[i,j]*VariaCost[i,j]  + Y[i,j]*FixedCost[i,j] ));
                                                                                                       _
                                                                                                       618
 ERROR 618-782: The subscript count does not match array 'Y', 2 NE 1.
 
 86       ! minimize TotalCost = sum {i in Plant} ( sum {j in Product} ( X[i,j]*VariaCost[i,j]  + Y[i,j]*FixedCost[i,j] ));
                                                                                                                      _
                                                                                                                      618
 ERROR 618-782: The subscript count does not match array 'FixedCost', 2 NE 1.
 &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Total code now looks like this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc optmodel;
set Plant = {'Osaka','Nagoya','Yokohama','Nara','Fukuoka'};
set Product = {'Haihai','Sensei','Hiro','Kirito'};

number Supply {Plant} = [673 580 659 662 623] ;
number Demand {Product} = [514 527 495 493];
number VariaCost {Plant,Product} = [
25.25	24.4	25.45	24.6
21.15	22.3	24.8	23.15
22.5	25.35	24.85	23.35
24.05	24.4	21.65	22.35
21.5	23.5	23.5	21.85];
number FixedCost {Plant} = [1434 1249 2527];
number M = 1000000;
number MinUse {Plant,Product} = [
60	98	139	133
71	85	80	55
70	61	56	57
136	145	134	144
109	95	118	145];
number MaxUse {Plant,Product} = [
354	343	369	346
299	324	358	319
347	338	290	340
327	325	280	323
308	300	370	354];

var X {Plant,Product} integer &amp;gt;= 0;
var Y {Plant} binary;

minimize TotalCost = sum {i in Plant} ( sum {j in Product} ( X[i,j]*VariaCost[i,j]  + Y[i,j]*FixedCost[i,j] ));

con SupplyConst {i in Plant} : sum {j in Product} X[i,j]&amp;lt;=Supply[i];
con DemandConst {j in Product} : sum {i in Plant} X[i,j]&amp;gt;=Demand[j];



solve;

print TotalCost X;

quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for taking another look at this.&lt;/P&gt;</description>
    <pubDate>Fri, 23 Dec 2016 20:28:58 GMT</pubDate>
    <dc:creator>ccockrum</dc:creator>
    <dc:date>2016-12-23T20:28:58Z</dc:date>
    <item>
      <title>Sas Studio Proc Optmodel: Multi-part constraint</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Sas-Studio-Proc-Optmodel-Multi-part-constraint/m-p/319066#M1597</link>
      <description>&lt;P&gt;Hey, I am needing some help figuring out how to do a multi-part constraint for the proc optmodel.&amp;nbsp; Here is the data I am working with and trying to structure correctly. The specific part I am struggling with is how to do setup the minimum and maximum production constraints per product per plant.&amp;nbsp; I've attached an Excel spreadsheet showing the data I am working with and below is my attempt at writing the SAS code correctly.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc optmodel;
set Plant = {'Osaka','Nagoya','Yokohama','Nara','Fukuoka'};
set Product = {'Haihai','Sensei','Hiro','Kirito'};

number Supply {Plant} = [673 580 659 662 623] ;
number Demand {Product} = [514 527 495 493];
number VariaCost {Plant,Product} = [
25.25	24.4	25.45	24.6
21.15	22.3	24.8	23.15
22.5	25.35	24.85	23.35
24.05	24.4	21.65	22.35
21.5	23.5	23.5	21.85];
number FixedCost {Plant} = [1434 1249 2527];
number M = 1000000;
number MinUse {Plant,Product} = [
60	98	139	133
71	85	80	55
70	61	56	57
136	145	134	144
109	95	118	145];
number MaxUse {Plant,Product} = [
354	343	369	346
299	324	358	319
347	338	290	340
327	325	280	323
308	300	370	354];

var X {Plant,Product} integer &amp;gt;= 0;
var Y {Plant} binary;

minimize TotalCost = sum {i in Plant} ( sum {j in Product} ( X[i,j]*VariaCost[i,j] ) + Y[i]*FixedCost[i] );

con SupplyConst {i in Plant} : sum {j in Product} X[i,j]&amp;lt;=Supply[i];
con DemandConst {j in Product} : sum {i in Plant} X[i,j]&amp;gt;=Demand[j];
con Producing {i in Plant} : sum {j in Product} X[i,j] &amp;lt;= M * Y[i];
con UseMinimum {i in Plant} : sum {j in Product} X[i,j] &amp;gt;= MinUse[i] * Y[i];




solve;

print TotalCost X;

quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thanks in advance for helping a rookie,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Chad&lt;/P&gt;</description>
      <pubDate>Wed, 14 Dec 2016 22:10:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Sas-Studio-Proc-Optmodel-Multi-part-constraint/m-p/319066#M1597</guid>
      <dc:creator>ccockrum</dc:creator>
      <dc:date>2016-12-14T22:10:38Z</dc:date>
    </item>
    <item>
      <title>Re: Sas Studio Proc Optmodel: Multi-part constraint</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Sas-Studio-Proc-Optmodel-Multi-part-constraint/m-p/319092#M1598</link>
      <description>&lt;P&gt;From the data in the spreadsheet, it looks like you want:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;number FixedCost {Plant,Product} = [
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;var Y {Plant,Product} binary;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With corresponding changes in the objective declaration.&amp;nbsp; And then:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*con Producing {i in Plant} : sum {j in Product} X[i,j] &amp;lt;= M * Y[i];*/
/*con UseMinimum {i in Plant} : sum {j in Product} X[i,j] &amp;gt;= MinUse[i] * Y[i];*/
con UseMinimum {i in Plant, j in Product}: X[i,j] &amp;gt;= MinUse[i,j] * Y[i,j];
con UseMaximum {i in Plant, j in Product}: X[i,j] &amp;lt;= MaxUse[i,j] * Y[i,j];
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You don't need M.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Dec 2016 02:21:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Sas-Studio-Proc-Optmodel-Multi-part-constraint/m-p/319092#M1598</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2016-12-15T02:21:09Z</dc:date>
    </item>
    <item>
      <title>Re: Sas Studio Proc Optmodel: Multi-part constraint</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Sas-Studio-Proc-Optmodel-Multi-part-constraint/m-p/319346#M1599</link>
      <description>&lt;P&gt;Thanks for the help Rob, I really appreciate it.&amp;nbsp; I thought I was tracking with you on the changes, but I've hit some errors I'm not sure how to debug.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;at line 91:&lt;/P&gt;&lt;PRE class="sasLog"&gt;minimize TotalCost = sum {i in Plant} ( sum {j in Product} ( X[i,j]*VariaCost[i,j] ) + Y[i]*FixedCost[i] );&lt;/PRE&gt;&lt;PRE class="sasLog"&gt;ERROR 618-782: The subscript count does not match array 'Y', 1 NE 2.&lt;/PRE&gt;&lt;PRE class="sasLog"&gt;ERROR 618-782: The subscript count does not match array 'FixedCost', 1 NE 2.&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;at line 96:&lt;/P&gt;&lt;PRE class="sasLog"&gt;con Producing {i in Plant} : sum {j in Product} X[i,j] &amp;lt;= M * Y[i];&lt;/PRE&gt;&lt;PRE class="sasLog"&gt;ERROR 618-782: The subscript count does not match array 'Y', 1 NE 2.&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;at line 97:&lt;/P&gt;&lt;PRE class="sasLog"&gt;con UseMinimum {i in Plant} : sum {j in Product} X[i,j] &amp;gt;= MinUse[i] * Y[i];&lt;/PRE&gt;&lt;PRE class="sasLog"&gt;ERROR 618-782: The subscript count does not match array 'MinUse', 1 NE 2.&lt;/PRE&gt;&lt;PRE class="sasLog"&gt;ERROR 618-782: The subscript count does not match array 'Y', 1 NE 2.&lt;/PRE&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;and finally:&lt;/P&gt;&lt;PRE class="sasLog"&gt;ERROR: The constraint 'Producing' has an incomplete declaration.&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Am I correct in assuming that one has to M?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;latest code&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc optmodel;
set Plant = {'Osaka','Nagoya','Yokohama','Nara','Fukuoka'};
set Product = {'Haihai','Sensei','Hiro','Kirito'};

number Supply {Plant} = [673 580 659 662 623] ;
number Demand {Product} = [514 527 495 493];
number VariaCost {Plant,Product} = [
25.25	24.4	25.45	24.6
21.15	22.3	24.8	23.15
22.5	25.35	24.85	23.35
24.05	24.4	21.65	22.35
21.5	23.5	23.5	21.85];
number FixedCost {Plant,Product} = [
1415	1392	803	618
321	755	942	706
1252	1178	1391	1362
1408	1349	901	1386
619	702	1473	1493];
number M = 1000000;
number MinUse {Plant,Product} = [
60	98	139	133
71	85	80	55
70	61	56	57
136	145	134	144
109	95	118	145];
number MaxUse {Plant,Product} = [
354	343	369	346
299	324	358	319
347	338	290	340
327	325	280	323
308	300	370	354];

var X {Plant,Product} integer &amp;gt;= 0;
var Y {Plant,Product} binary;

minimize TotalCost = sum {i in Plant} ( sum {j in Product} ( X[i,j]*VariaCost[i,j] ) + Y[i]*FixedCost[i] );


con SupplyConst {i in Plant} : sum {j in Product} X[i,j]&amp;lt;=Supply[i];
con DemandConst {j in Product} : sum {i in Plant} X[i,j]&amp;gt;=Demand[j];
con Producing {i in Plant} : sum {j in Product} X[i,j] &amp;lt;= M * Y[i];
con UseMinimum {i in Plant} : sum {j in Product} X[i,j] &amp;gt;= MinUse[i] * Y[i];
con UseMinimum {i in Plant, j in Product}: X[i,j] &amp;gt;= MinUse[i,j] * Y[i,j];
con UseMaximum {i in Plant, j in Product}: X[i,j] &amp;lt;= MaxUse[i,j] * Y[i,j];


solve;

print TotalCost X;

quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 15 Dec 2016 18:05:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Sas-Studio-Proc-Optmodel-Multi-part-constraint/m-p/319346#M1599</guid>
      <dc:creator>ccockrum</dc:creator>
      <dc:date>2016-12-15T18:05:14Z</dc:date>
    </item>
    <item>
      <title>Re: Sas Studio Proc Optmodel: Multi-part constraint</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Sas-Studio-Proc-Optmodel-Multi-part-constraint/m-p/319367#M1600</link>
      <description>&lt;P&gt;Those error messages are telling you that you can't use Y[i] and FixedCost[i] because those arrays now require two subscripts each.&amp;nbsp; You need Y[i,j] and FixedCost[i,j] instead.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The Producing and UseMinimum constraints that I commented out are obsolete, and M is now also obsolete because it appears only in Producing.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Dec 2016 19:06:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Sas-Studio-Proc-Optmodel-Multi-part-constraint/m-p/319367#M1600</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2016-12-15T19:06:16Z</dc:date>
    </item>
    <item>
      <title>Re: Sas Studio Proc Optmodel: Multi-part constraint</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Sas-Studio-Proc-Optmodel-Multi-part-constraint/m-p/320992#M1604</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I made the change to Y[i,j]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;minimize TotalCost = sum {i in Plant} ( sum {j in Product} ( X[i,j]*VariaCost[i,j] ) + Y[i,j]*FixedCost[i,j] );&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;But I am still getting these errors on that line of code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class="sasLog"&gt;ERROR 525-782: The symbol 'j' is unknown.&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class="sasLog"&gt;ERROR 618-782: The subscript count does not match array 'Y', 2 NE 1.&lt;/PRE&gt;&lt;PRE class="sasLog"&gt;ERROR 618-782: The subscript count does not match array 'FixedCost', 2 NE 1.&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 23 Dec 2016 19:03:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Sas-Studio-Proc-Optmodel-Multi-part-constraint/m-p/320992#M1604</guid>
      <dc:creator>ccockrum</dc:creator>
      <dc:date>2016-12-23T19:03:23Z</dc:date>
    </item>
    <item>
      <title>Re: Sas Studio Proc Optmodel: Multi-part constraint</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Sas-Studio-Proc-Optmodel-Multi-part-constraint/m-p/320994#M1605</link>
      <description>&lt;P&gt;Your parentheses on the summand are incorrect.&amp;nbsp; You can use either one of the following:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;minimize TotalCost = sum {i in Plant} ( sum {j in Product} ( X[i,j]*VariaCost[i,j]  + Y[i,j]*FixedCost[i,j] ));
minimize TotalCost = sum {i in Plant, j in Product} ( X[i,j]*VariaCost[i,j]  + Y[i,j]*FixedCost[i,j] );
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 23 Dec 2016 19:26:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Sas-Studio-Proc-Optmodel-Multi-part-constraint/m-p/320994#M1605</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2016-12-23T19:26:27Z</dc:date>
    </item>
    <item>
      <title>Re: Sas Studio Proc Optmodel: Multi-part constraint</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Sas-Studio-Proc-Optmodel-Multi-part-constraint/m-p/321004#M1606</link>
      <description>&lt;P&gt;Okay, I'm following you.&amp;nbsp; What about the other error, that one is this there.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; 86         minimize TotalCost = sum {i in Plant} ( sum {j in Product} ( X[i,j]*VariaCost[i,j]  + Y[i,j]*FixedCost[i,j] ));
                                                                                                       _
                                                                                                       618
 ERROR 618-782: The subscript count does not match array 'Y', 2 NE 1.
 
 86       ! minimize TotalCost = sum {i in Plant} ( sum {j in Product} ( X[i,j]*VariaCost[i,j]  + Y[i,j]*FixedCost[i,j] ));
                                                                                                                      _
                                                                                                                      618
 ERROR 618-782: The subscript count does not match array 'FixedCost', 2 NE 1.
 &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Total code now looks like this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc optmodel;
set Plant = {'Osaka','Nagoya','Yokohama','Nara','Fukuoka'};
set Product = {'Haihai','Sensei','Hiro','Kirito'};

number Supply {Plant} = [673 580 659 662 623] ;
number Demand {Product} = [514 527 495 493];
number VariaCost {Plant,Product} = [
25.25	24.4	25.45	24.6
21.15	22.3	24.8	23.15
22.5	25.35	24.85	23.35
24.05	24.4	21.65	22.35
21.5	23.5	23.5	21.85];
number FixedCost {Plant} = [1434 1249 2527];
number M = 1000000;
number MinUse {Plant,Product} = [
60	98	139	133
71	85	80	55
70	61	56	57
136	145	134	144
109	95	118	145];
number MaxUse {Plant,Product} = [
354	343	369	346
299	324	358	319
347	338	290	340
327	325	280	323
308	300	370	354];

var X {Plant,Product} integer &amp;gt;= 0;
var Y {Plant} binary;

minimize TotalCost = sum {i in Plant} ( sum {j in Product} ( X[i,j]*VariaCost[i,j]  + Y[i,j]*FixedCost[i,j] ));

con SupplyConst {i in Plant} : sum {j in Product} X[i,j]&amp;lt;=Supply[i];
con DemandConst {j in Product} : sum {i in Plant} X[i,j]&amp;gt;=Demand[j];



solve;

print TotalCost X;

quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for taking another look at this.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Dec 2016 20:28:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Sas-Studio-Proc-Optmodel-Multi-part-constraint/m-p/321004#M1606</guid>
      <dc:creator>ccockrum</dc:creator>
      <dc:date>2016-12-23T20:28:58Z</dc:date>
    </item>
    <item>
      <title>Re: Sas Studio Proc Optmodel: Multi-part constraint</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Sas-Studio-Proc-Optmodel-Multi-part-constraint/m-p/321011#M1607</link>
      <description>&lt;P&gt;Those additional errors are because you switched back to the old declarations for FixedCost and Y. &amp;nbsp;Also, you still need the new UseMinimum and UseMaximum constraints.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Dec 2016 23:48:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Sas-Studio-Proc-Optmodel-Multi-part-constraint/m-p/321011#M1607</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2016-12-23T23:48:14Z</dc:date>
    </item>
  </channel>
</rss>

