<?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 MILP solution ran out of Memory in Mathematical Optimization, Discrete-Event Simulation, and OR</title>
    <link>https://communities.sas.com/t5/Mathematical-Optimization/MILP-solution-ran-out-of-Memory/m-p/629661#M2999</link>
    <description>&lt;P&gt;Hello All!&lt;/P&gt;&lt;P&gt;I am using SAS Enterprise Guide 7.1.&amp;nbsp;I am trying to run the code below for solving an MILP to identify optimal number of Depots to store supply from all the fields. When I used 1 state with 100 counties, it gave me a solution. I am using same set of counties for Depot and Field location. But just as I increased the state number to 2 or 3, my log displayed me "ERROR: Out of memory." Eventually, I will need to run the code for all states which includes 3109 counties. I am also attaching my log. Please kindly help me on how to resolve this issue. Thank you in advance!&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data fdata(Rename=(County=name));
	set UScounties;

	if state in ("North Carolina", "South Carolina", "Virginia") then
		do;
			x=Long;
			demand=rand('UNIFORM') * &amp;amp;MaxDemand;
			Y=Lat;
			output fdata;
			keep county x demand y;
		end;
run;


data pdata(Rename=(county=name));
	set UScounties;
	if state in ("North Carolina", "South Carolina", "Virginia") then
		do;
			x=Long;
			y=Lat;
			fixed_cost=275000;
			output;
			keep county x y fixed_cost;
		end;
run;

/*Solving the MILP*/
proc optmodel;
	set &amp;lt;str&amp;gt; Fields;

	/*declares set of fields*/
	set &amp;lt;str&amp;gt; Depots init {};

	/*declares set of depots*/
	num x{Fields union Depots};

	/*creating an array of x cooordinate with all the field and depot location, union combines both field and depot*/
	num y{Fields union Depots};

	/*creating an array of y cooordinate with all the field and depot location*/
	num demand{Fields};
	num fixed_cost{Depots};
	num distance {i in Fields, j in Depots}=sqrt((x[i] - x[j])^2 + (y[i] 
		- y[j])^2);

	/* linear distance between fields and depots*/
	read data fdata into Fields=[name] x y demand;
	read data pdata into Depots=[name] x y fixed_cost;
	var Assign {Fields, Depots} binary;

	/* binary value to assign specific fields to specific depots*/
	var Build {Depots} binary;

	/*objective function*/
	/* binary variable to determine which depots will be established*/
	min cost=sum{i in Fields, j in Depots} Distance[i, j]*Assign[i, j] + sum{j in 
		Depots}Fixed_cost[j]*Build[j];

	/*Constraints*/
	con Assign_fields{i in Fields}: sum{j in Depots}Assign[i, j]=1;

	/*each field assigned to one depot only*/
	con Build_depot{i in Fields, j in Depots}: Assign[i, j] &amp;lt;=Build[j];

	/* if a field is assigned to a depot, it has to be build*/
	con Depot_capacity{j in Depots}: sum {i in Fields}Demand[i]*Assign[i, 
		j]&amp;lt;=&amp;amp;DepotCapacity*Build[j];

	/*ensuring total field supply to a depot is within its capacity*/
	solve obj Cost with MILP/primalin;
	num varcost=sum {i in FIELDS, j in DEPOTS} distance[i, j] * Assign[i, j].sol;
	num fixcost=sum {j in DEPOTS} fixed_cost[j] * Build[j].sol;
 	for {s in 1.._NSOL_} do; 

	/*clean up the solution*/
	for {i in FIELDS, j in DEPOTS} Assign[i, j]=round(Assign[i, j].sol[s]);
	for {j in DEPOTS} Build[j]=round(Build[j].sol[s]);
	call symput('varcost', put(varcost, 6.1));
	call symput('fixcost', put(fixcost, 5.1));
	call symput('totalcost', put(Cost, 6.1));

	/*create a data set for use by PROC SGPLOT*/
	create data CostFixedCharge_Data from
        [FIELD DEPOT]={i in FIELDS, j in DEPOTS: Assign[i, j]=1} 
		x1=x[i] y1=y[i] x2=x[j] y2=y[j] function='line' drawspace='datavalue' 
		linethickness=1 linecolor='black';
 	submit s; 
 	endsubmit; 
 end; 
quit;&lt;/CODE&gt;&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 05 Mar 2020 00:13:45 GMT</pubDate>
    <dc:creator>thossain</dc:creator>
    <dc:date>2020-03-05T00:13:45Z</dc:date>
    <item>
      <title>MILP solution ran out of Memory</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/MILP-solution-ran-out-of-Memory/m-p/629661#M2999</link>
      <description>&lt;P&gt;Hello All!&lt;/P&gt;&lt;P&gt;I am using SAS Enterprise Guide 7.1.&amp;nbsp;I am trying to run the code below for solving an MILP to identify optimal number of Depots to store supply from all the fields. When I used 1 state with 100 counties, it gave me a solution. I am using same set of counties for Depot and Field location. But just as I increased the state number to 2 or 3, my log displayed me "ERROR: Out of memory." Eventually, I will need to run the code for all states which includes 3109 counties. I am also attaching my log. Please kindly help me on how to resolve this issue. Thank you in advance!&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data fdata(Rename=(County=name));
	set UScounties;

	if state in ("North Carolina", "South Carolina", "Virginia") then
		do;
			x=Long;
			demand=rand('UNIFORM') * &amp;amp;MaxDemand;
			Y=Lat;
			output fdata;
			keep county x demand y;
		end;
run;


data pdata(Rename=(county=name));
	set UScounties;
	if state in ("North Carolina", "South Carolina", "Virginia") then
		do;
			x=Long;
			y=Lat;
			fixed_cost=275000;
			output;
			keep county x y fixed_cost;
		end;
run;

/*Solving the MILP*/
proc optmodel;
	set &amp;lt;str&amp;gt; Fields;

	/*declares set of fields*/
	set &amp;lt;str&amp;gt; Depots init {};

	/*declares set of depots*/
	num x{Fields union Depots};

	/*creating an array of x cooordinate with all the field and depot location, union combines both field and depot*/
	num y{Fields union Depots};

	/*creating an array of y cooordinate with all the field and depot location*/
	num demand{Fields};
	num fixed_cost{Depots};
	num distance {i in Fields, j in Depots}=sqrt((x[i] - x[j])^2 + (y[i] 
		- y[j])^2);

	/* linear distance between fields and depots*/
	read data fdata into Fields=[name] x y demand;
	read data pdata into Depots=[name] x y fixed_cost;
	var Assign {Fields, Depots} binary;

	/* binary value to assign specific fields to specific depots*/
	var Build {Depots} binary;

	/*objective function*/
	/* binary variable to determine which depots will be established*/
	min cost=sum{i in Fields, j in Depots} Distance[i, j]*Assign[i, j] + sum{j in 
		Depots}Fixed_cost[j]*Build[j];

	/*Constraints*/
	con Assign_fields{i in Fields}: sum{j in Depots}Assign[i, j]=1;

	/*each field assigned to one depot only*/
	con Build_depot{i in Fields, j in Depots}: Assign[i, j] &amp;lt;=Build[j];

	/* if a field is assigned to a depot, it has to be build*/
	con Depot_capacity{j in Depots}: sum {i in Fields}Demand[i]*Assign[i, 
		j]&amp;lt;=&amp;amp;DepotCapacity*Build[j];

	/*ensuring total field supply to a depot is within its capacity*/
	solve obj Cost with MILP/primalin;
	num varcost=sum {i in FIELDS, j in DEPOTS} distance[i, j] * Assign[i, j].sol;
	num fixcost=sum {j in DEPOTS} fixed_cost[j] * Build[j].sol;
 	for {s in 1.._NSOL_} do; 

	/*clean up the solution*/
	for {i in FIELDS, j in DEPOTS} Assign[i, j]=round(Assign[i, j].sol[s]);
	for {j in DEPOTS} Build[j]=round(Build[j].sol[s]);
	call symput('varcost', put(varcost, 6.1));
	call symput('fixcost', put(fixcost, 5.1));
	call symput('totalcost', put(Cost, 6.1));

	/*create a data set for use by PROC SGPLOT*/
	create data CostFixedCharge_Data from
        [FIELD DEPOT]={i in FIELDS, j in DEPOTS: Assign[i, j]=1} 
		x1=x[i] y1=y[i] x2=x[j] y2=y[j] function='line' drawspace='datavalue' 
		linethickness=1 linecolor='black';
 	submit s; 
 	endsubmit; 
 end; 
quit;&lt;/CODE&gt;&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Mar 2020 00:13:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/MILP-solution-ran-out-of-Memory/m-p/629661#M2999</guid>
      <dc:creator>thossain</dc:creator>
      <dc:date>2020-03-05T00:13:45Z</dc:date>
    </item>
  </channel>
</rss>

