<?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: How to set constrains for this problem in Mathematical Optimization, Discrete-Event Simulation, and OR</title>
    <link>https://communities.sas.com/t5/Mathematical-Optimization/How-to-set-constrains-for-this-problem/m-p/586570#M2865</link>
    <description>&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I only need it for one day. So starting at 8 am and ending at 7 am the next day. doesn't need to wrap it up. Thanks.&lt;/P&gt;</description>
    <pubDate>Thu, 05 Sep 2019 23:36:21 GMT</pubDate>
    <dc:creator>DanielZhang</dc:creator>
    <dc:date>2019-09-05T23:36:21Z</dc:date>
    <item>
      <title>How to set constrains for this problem</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/How-to-set-constrains-for-this-problem/m-p/586302#M2862</link>
      <description>&lt;P&gt;Hi guys,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am having trouble to add the new constraints for this kind of problem. The work I am doing is managing the pump and valve running over the 24 hours from 8 am to 7 am the next day.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;set&amp;lt;num&amp;gt; = {8,9,10,11,...7};&lt;/P&gt;&lt;P&gt;set PUMP = /Pump1 Pump2 Pump3/;&lt;/P&gt;&lt;P&gt;var PumpStation{TIME,PUMP} Binary;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The objective function is minimized power usage.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The constraints I am working on is once the pump is on, it has to run for at least 2 hours.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The valve is the following :&lt;/P&gt;&lt;P&gt;var Valve{TIME} Binary;&lt;/P&gt;&lt;P&gt;var ValveFlow{TIME} integer;&lt;/P&gt;&lt;P&gt;con Flow_pb: ValveFlow[t] &amp;gt;= 200*Valve[t];&lt;/P&gt;&lt;P&gt;con Flow_lb: ValveFlow[t] &amp;lt;= 1000*Valve[t];&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The new constraints adding in the valve is once the valve is open, the flow needs to be same for at least 4 hours.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Sep 2019 05:30:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/How-to-set-constrains-for-this-problem/m-p/586302#M2862</guid>
      <dc:creator>DanielZhang</dc:creator>
      <dc:date>2019-09-05T05:30:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to set constrains for this problem</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/How-to-set-constrains-for-this-problem/m-p/586432#M2864</link>
      <description>&lt;P&gt;Do you want the schedule to repeat every day?&amp;nbsp; I'm wondering about whether activities just before 7am need to "wrap around" to the beginning of the day.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Sep 2019 14:26:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/How-to-set-constrains-for-this-problem/m-p/586432#M2864</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2019-09-05T14:26:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to set constrains for this problem</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/How-to-set-constrains-for-this-problem/m-p/586570#M2865</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I only need it for one day. So starting at 8 am and ending at 7 am the next day. doesn't need to wrap it up. Thanks.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Sep 2019 23:36:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/How-to-set-constrains-for-this-problem/m-p/586570#M2865</guid>
      <dc:creator>DanielZhang</dc:creator>
      <dc:date>2019-09-05T23:36:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to set constrains for this problem</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/How-to-set-constrains-for-this-problem/m-p/586585#M2866</link>
      <description>&lt;P&gt;I recommend declaring your time periods as follows, with the interpretation that 0 corresponds to 8am:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;set TIME = 0..23;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then declare the following additional binary variable and linear constraints:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;var StartPumpStation{TIME,PUMP} binary;

/* if PumpStation[t,p] = 1 and PumpStation[t-1,p] = 0 then StartPumpStation[t,p] = 1 */
con StartPumpStationCon1 {t in TIME, p in PUMP: t-1 in TIME}:
   PumpStation[t,p] - PumpStation[t-1,p] &amp;lt;= StartPumpStation[t,p];

/* if StartPumpStation[t,p] = 1 then PumpStation[t-1,p] = 0 */
con StartPumpStationCon2 {t in TIME, p in PUMP: t-1 in TIME}:
   StartPumpStation[t,p] &amp;lt;= 1 - PumpStation[t-1,p];

/* if StartPumpStation[t,p] = 1 then PumpStation[t,p] = PumpStation[t+1,p] = 1 */
con StartPumpStationCon3 {t in TIME, p in PUMP, t2 in t..t+1: t+1 in TIME}:
   StartPumpStation[t,p] &amp;lt;= PumpStation[t2,p];
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;For the valve flows, define lower and upper bounds in the declaration:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;var ValveFlow{TIME} integer &amp;gt;= 0 &amp;lt;= 1000;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then declare another binary variable and linear constraints:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;var StartValve {TIME} binary;

/* if Valve[t] = 1 and Valve[t-1] = 0 then StartValve[t] = 1 */
con StartValveCon1 {t in TIME: t-1 in TIME}:
   Valve[t] - Valve[t-1] &amp;lt;= StartValve[t];

/* if StartValve[t] = 1 then Valve[t-1] = 0 */
con StartValveCon2 {t in TIME: t-1 in TIME}:
   StartValve[t] &amp;lt;= 1 - Valve[t-1];

/* if StartValve[t] = 1 then Valve[t] = 1 */
con StartValveCon3 {t in TIME}:
   StartValve[t] &amp;lt;= Valve[t];

/* if StartValve[t] = 1 then ValveFlow[t] = ValveFlow[t+1] = ValveFlow[t+2] = ValveFlow[t+3] */
con StartValveCon4 {t in TIME, t2 in t..t+2: t+3 in TIME}:
   ValveFlow[t2] - ValveFlow[t2+1] &amp;lt;= (ValveFlow[t2].ub - ValveFlow[t2+1].lb) * (1 - StartValve[t]);
con StartValveCon5 {t in TIME, t2 in t..t+2: t+3 in TIME}:
   ValveFlow[t2+1] - ValveFlow[t2] &amp;lt;= (ValveFlow[t2+1].ub - ValveFlow[t2].lb) * (1 - StartValve[t]);
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 06 Sep 2019 01:14:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/How-to-set-constrains-for-this-problem/m-p/586585#M2866</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2019-09-06T01:14:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to set constrains for this problem</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/How-to-set-constrains-for-this-problem/m-p/586602#M2867</link>
      <description>&lt;P&gt;Thank you very much Rob&lt;img id="smileyvery-happy" class="emoticon emoticon-smileyvery-happy" src="https://communities.sas.com/i/smilies/16x16_smiley-very-happy.png" alt="Smiley Very Happy" title="Smiley Very Happy" /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Sep 2019 02:41:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/How-to-set-constrains-for-this-problem/m-p/586602#M2867</guid>
      <dc:creator>DanielZhang</dc:creator>
      <dc:date>2019-09-06T02:41:45Z</dc:date>
    </item>
  </channel>
</rss>

