<?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: Open a Facility with constraint in Mathematical Optimization, Discrete-Event Simulation, and OR</title>
    <link>https://communities.sas.com/t5/Mathematical-Optimization/Open-a-Facility-with-constraint/m-p/565693#M2781</link>
    <description>&lt;P&gt;To do this in PROC OPTMODEL, see &lt;A href="https://go.documentation.sas.com/?docsetId=ormpex&amp;amp;docsetTarget=ormpex_ex19_sect009.htm&amp;amp;docsetVersion=15.1&amp;amp;locale=en" target="_self"&gt;this example&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For PROC PRINT, the correct syntax is:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc print data=Public.ContainersfromPortstoICtoDC(where=(ContainersfromPortstoICtoDC &amp;gt;0);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 12 Jun 2019 21:20:17 GMT</pubDate>
    <dc:creator>RobPratt</dc:creator>
    <dc:date>2019-06-12T21:20:17Z</dc:date>
    <item>
      <title>Open a Facility with constraint</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Open-a-Facility-with-constraint/m-p/565617#M2772</link>
      <description>&lt;P&gt;num Min_Qty_at_IC=2500;&lt;/P&gt;&lt;P&gt;var Build {IC} binary;&lt;/P&gt;&lt;P&gt;var ContainersfromPortstoICtoDC {Ports,IC,DC}&amp;gt;=0;&lt;/P&gt;&lt;P&gt;con All_ICs_are_Used {c in IC} : sum{p in Ports, d in DC} ContainersfromPortstoICtoDC [p,c,d]&amp;gt;=Min_Qty_at_IC*Build[c];&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a bunch of Ports (index by p), IC (indexed by c) and DC (indexed by d). The demand from Ports to DC is fixed. It is the number of ICs (x out of 19 total ICs, x is the answer) and which ones are the result of my model. There is a constraint that if an IC is open, it needs to have atleast 2,500 units flow through them. I ran the model. Model ran but this constraint is not being obeyed correctly as I see that there are some IC that are open but with flows less than 2,500. I am not sure what I am missing.&lt;/P&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;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jun 2019 16:41:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Open-a-Facility-with-constraint/m-p/565617#M2772</guid>
      <dc:creator>Santha</dc:creator>
      <dc:date>2019-06-12T16:41:03Z</dc:date>
    </item>
    <item>
      <title>Re: Open a Facility with constraint</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Open-a-Facility-with-constraint/m-p/565620#M2773</link>
      <description>&lt;P&gt;There are some IC with 0 flows. thats ok. that means it is closed. But if any IC is open, it shd have atleast 2,500 that is the minimum&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jun 2019 16:50:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Open-a-Facility-with-constraint/m-p/565620#M2773</guid>
      <dc:creator>Santha</dc:creator>
      <dc:date>2019-06-12T16:50:17Z</dc:date>
    </item>
    <item>
      <title>Re: Open a Facility with constraint</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Open-a-Facility-with-constraint/m-p/565636#M2774</link>
      <description>&lt;P&gt;Your model enforces the logical implication:&lt;/P&gt;
&lt;P&gt;if Build[c] = 1 then&amp;nbsp;sum{p in Ports, d in DC} ContainersfromPortstoICtoDC[p,c,d] &amp;gt;= Min_Qty_at_IC.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But you also need ("big-M") constraints to enforce the following:&lt;/P&gt;
&lt;P&gt;if&amp;nbsp;ContainersfromPortstoICtoDC[p,c,d] &amp;gt; 0 then Build[c] = 1.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jun 2019 17:53:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Open-a-Facility-with-constraint/m-p/565636#M2774</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2019-06-12T17:53:12Z</dc:date>
    </item>
    <item>
      <title>Re: Open a Facility with constraint</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Open-a-Facility-with-constraint/m-p/565638#M2775</link>
      <description>&lt;P&gt;I do have the Big M constraint. Sorry I did not add to the earlier message. Here it is.&lt;/P&gt;&lt;P&gt;con CheckIC {c in IC}: ContainersatIC[c] &amp;lt;= 15000*Build[c]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Big M in my case is the total flows plus little more rounded up to 15000.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;impvar ContainersatIC{c in IC}=sum{p in Ports, d in DC} ContainersfromPortstoICtoDC [p,c,d];&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jun 2019 17:58:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Open-a-Facility-with-constraint/m-p/565638#M2775</guid>
      <dc:creator>Santha</dc:creator>
      <dc:date>2019-06-12T17:58:20Z</dc:date>
    </item>
    <item>
      <title>Re: Open a Facility with constraint</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Open-a-Facility-with-constraint/m-p/565648#M2776</link>
      <description>&lt;P&gt;I don't immediately see anything wrong.&amp;nbsp; Please post the full code, including data.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jun 2019 19:17:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Open-a-Facility-with-constraint/m-p/565648#M2776</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2019-06-12T19:17:58Z</dc:date>
    </item>
    <item>
      <title>Re: Open a Facility with constraint</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Open-a-Facility-with-constraint/m-p/565668#M2777</link>
      <description>&lt;P&gt;Hi Rob&lt;/P&gt;&lt;P&gt;Thank you. Here is my full code. I am not able to send the data as it contains price information. However, the data read is good and the data is clean. I have verified that part.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc optmodel;&lt;/P&gt;&lt;P&gt;/* Declare Ports, ICs and DCs */&lt;BR /&gt;set&amp;lt;str&amp;gt; Ports;/* this is a set of Ports*/&lt;BR /&gt;set&amp;lt;str&amp;gt; DC; /* this is a set of ICs*/&lt;BR /&gt;set&amp;lt;str&amp;gt; IC; /* this is a set of DCs*/&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/* declare Constants*/&lt;BR /&gt;num Min_Qty_at_IC=2500;&lt;BR /&gt;num Inbound_Fuel_Per_Container=10;&lt;BR /&gt;num Drayage_Fuel=2.8;/* This is a Percentage Based Charge*/&lt;BR /&gt;**num NumberofICsopen = x;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/* Delcare Variables for the Scenario involving many ICs and chosen IC to have &amp;gt;2,500 FEU */&lt;/P&gt;&lt;P&gt;var Build {IC} binary;&amp;nbsp; /*If C is selected, then it is 1, else 0 */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/*Declaring an Array of Costs - THIS IS INPUT data */&lt;BR /&gt;num InboundLinehaul {Ports,IC}; /* This is an array of InboundLinehaul Costs indexed over Ports and IC*/&lt;BR /&gt;num OutboundLinehaul {IC,DC}; /*This is an array of OutboundLinehaul Costs indexed over IC and DC*/&lt;BR /&gt;num Outbound_Fuel{IC,DC}; /* This is an array of Outbound Fuel Cost Per Mil;e indexed over IC and DC*/&lt;BR /&gt;num TransloadCost {IC};/*This is an array of Transload Costs at IC*/&lt;BR /&gt;num DrayageCost {IC};/*This is an array of Drayage Costs at IC*/&lt;BR /&gt;num PierPassCost {IC};/*This is an array of PierPass Costs at IC*/&lt;BR /&gt;num MilesBetweenIC_DC {IC,DC}; /*This is an array of Miles between IC and DC indexed over IC and DC */&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;/* Declaring an Array of Decision Variables*/&lt;/P&gt;&lt;P&gt;var ContainersfromPortstoICtoDC {Ports,IC,DC}&amp;gt;=0;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;/*Declaring Implicit Variables*/&lt;BR /&gt;impvar ContainersatIC{c in IC}=sum{p in Ports, d in DC} ContainersfromPortstoICtoDC [p,c,d];&lt;/P&gt;&lt;P&gt;impvar Inbound_Linehaul_Costs= sum {p in Ports, c in IC, d in DC} InboundLinehaul [p,c] *ContainersfromPortstoICtoDC [p,c,d];&lt;BR /&gt;impvar Inbound_Fuel_Costs=Inbound_Fuel_Per_Container*sum {p in Ports, c in IC, d in DC} ContainersfromPortstoICtoDC [p,c,d];&lt;/P&gt;&lt;P&gt;impvar Outbound_Linehaul_Costs = sum {p in Ports, c in IC, d in DC} OutboundLinehaul [c,d] * ContainersfromPortstoICtoDC [p,c,d];&lt;BR /&gt;impvar Outbound_Fuel_Costs = sum{c in IC, d in DC} Outbound_Fuel[c,d]*MilesBetweenIC_DC[c,d];&lt;/P&gt;&lt;P&gt;impvar Transloading_Costs = sum{p in Ports, c in IC, d in DC} ContainersfromPortstoICtoDC[p,c,d]*TransloadCost[c];&lt;BR /&gt;impvar Drayage_Costs =sum{p in Ports, c in IC, d in DC} ContainersfromPortstoICtoDC [p,c,d]*DrayageCost[c];&lt;BR /&gt;impvar Drayage_Fuel_Costs=Drayage_Fuel*sum{p in Ports, c in IC, d in DC} ContainersfromPortstoICtoDC [p,c,d]*DrayageCost[c];&lt;BR /&gt;impvar PierPass_Costs=sum{p in Ports, c in IC, d in DC} ContainersfromPortstoICtoDC[p,c,d]*PierPassCost[c];&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/* declare Objective Function*/&lt;BR /&gt;Min TotalCost = Inbound_Linehaul_Costs+Inbound_Fuel_Costs+Outbound_Linehaul_Costs+Outbound_Fuel_Costs+Transloading_Costs+Drayage_Costs+Drayage_Fuel_Costs+PierPass_Costs;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/* declare Constraints*/&lt;/P&gt;&lt;P&gt;con All_ICs_are_Used{c in IC} :&lt;BR /&gt;sum{p in Ports, d in DC} ContainersfromPortstoICtoDC [p,c,d]&amp;gt;=Min_Qty_at_IC*Build[c];&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;con Flows_from_Ports_to_DC_Modelequals_FlowFromPortstoDC_inInputData {p in Ports, d in DC}:&lt;BR /&gt;sum {c in IC} ContainersfromPortstoICtoDC[p, c, d] = Containers [p,d]; /*the flow from p to d that goes through ALL ICs*/&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;con CheckIC {c in IC}: ContainersatIC[c] &amp;lt;= 15000*Build[c];/*15000 is the Big M- Have it as the sum demandfrom the data*/&lt;BR /&gt;**con HaveAtleastTheseManyICsopen: Sum{c in IC} Build [c] =NumberofICsopen;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;**expand;&lt;BR /&gt;solve with lp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/*Outputs*/&lt;BR /&gt;print ContainersfromPortstoICtoDC;&lt;BR /&gt;print ContainersatIC;&lt;BR /&gt;print TotalCost;&lt;BR /&gt;print Inbound_Linehaul_Costs;&lt;BR /&gt;print Inbound_Fuel_Costs;&lt;BR /&gt;print Outbound_Linehaul_Costs;&lt;BR /&gt;print Outbound_Fuel_Costs;&lt;BR /&gt;print Transloading_Costs;&lt;BR /&gt;print Drayage_Costs;&lt;BR /&gt;print Drayage_Fuel_Costs;&lt;BR /&gt;print PierPass_Costs;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jun 2019 20:05:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Open-a-Facility-with-constraint/m-p/565668#M2777</guid>
      <dc:creator>Santha</dc:creator>
      <dc:date>2019-06-12T20:05:37Z</dc:date>
    </item>
    <item>
      <title>Re: Open a Facility with constraint</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Open-a-Facility-with-constraint/m-p/565671#M2778</link>
      <description>&lt;P&gt;You have declared binary variables but then call the LP solver.&amp;nbsp; Just use SOLVE (or SOLVE WITH MILP) instead of SOLVE WITH LP.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jun 2019 20:10:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Open-a-Facility-with-constraint/m-p/565671#M2778</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2019-06-12T20:10:08Z</dc:date>
    </item>
    <item>
      <title>Re: Open a Facility with constraint</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Open-a-Facility-with-constraint/m-p/565677#M2779</link>
      <description>&lt;P&gt;Rob.&lt;/P&gt;&lt;P&gt;Thank you. That did it.&amp;nbsp; Too bad that I did not catch this.&amp;nbsp; Thank you for your time again.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jun 2019 20:20:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Open-a-Facility-with-constraint/m-p/565677#M2779</guid>
      <dc:creator>Santha</dc:creator>
      <dc:date>2019-06-12T20:20:17Z</dc:date>
    </item>
    <item>
      <title>Re: Open a Facility with constraint</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Open-a-Facility-with-constraint/m-p/565687#M2780</link>
      <description>&lt;P&gt;Hi rob. I have one last associated question.&lt;/P&gt;&lt;P&gt;how do i print a variable only when observation is &amp;gt;0? I tried this.&lt;/P&gt;&lt;P&gt;print Public.ContainersfromPortstoICtoDC; This prints everything. I want only when the value is not zero.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Proc print data=Public.ContainersfromPortstoICtoDC where&amp;nbsp;ContainersfromPortstoICtoDC &amp;gt;0;? This was not successful.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jun 2019 20:56:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Open-a-Facility-with-constraint/m-p/565687#M2780</guid>
      <dc:creator>Santha</dc:creator>
      <dc:date>2019-06-12T20:56:11Z</dc:date>
    </item>
    <item>
      <title>Re: Open a Facility with constraint</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Open-a-Facility-with-constraint/m-p/565693#M2781</link>
      <description>&lt;P&gt;To do this in PROC OPTMODEL, see &lt;A href="https://go.documentation.sas.com/?docsetId=ormpex&amp;amp;docsetTarget=ormpex_ex19_sect009.htm&amp;amp;docsetVersion=15.1&amp;amp;locale=en" target="_self"&gt;this example&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For PROC PRINT, the correct syntax is:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc print data=Public.ContainersfromPortstoICtoDC(where=(ContainersfromPortstoICtoDC &amp;gt;0);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 12 Jun 2019 21:20:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Open-a-Facility-with-constraint/m-p/565693#M2781</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2019-06-12T21:20:17Z</dc:date>
    </item>
    <item>
      <title>Re: Open a Facility with constraint</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Open-a-Facility-with-constraint/m-p/565695#M2782</link>
      <description>&lt;P&gt;HI rob&lt;/P&gt;&lt;P&gt;I tried that but got an error that&amp;nbsp;Public.ContainersfromPortstoICtoDC does not exist.&lt;/P&gt;&lt;P&gt;"ContainersfromPortstoICtoDC" is an implicit variable that I have declared. So I am not sure of the right syntax.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jun 2019 21:27:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Open-a-Facility-with-constraint/m-p/565695#M2782</guid>
      <dc:creator>Santha</dc:creator>
      <dc:date>2019-06-12T21:27:50Z</dc:date>
    </item>
    <item>
      <title>Re: Open a Facility with constraint</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Open-a-Facility-with-constraint/m-p/565959#M2783</link>
      <description>&lt;P&gt;Hi.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to see my various cost buckets. For example, if i want to see my&amp;nbsp;Inbound_Linehaul_Costs (that is an implicit variable in the model) by different lanes (lanes are Ports-IC combinations), how do i do that? Can you help me with that. My model succesfully solved. I just dont know how to extract the relevant outputs.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jun 2019 18:21:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Open-a-Facility-with-constraint/m-p/565959#M2783</guid>
      <dc:creator>Santha</dc:creator>
      <dc:date>2019-06-13T18:21:08Z</dc:date>
    </item>
  </channel>
</rss>

