<?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 Assigning value to next state in PROC OPTMODEL Constraints in Mathematical Optimization, Discrete-Event Simulation, and OR</title>
    <link>https://communities.sas.com/t5/Mathematical-Optimization/Assigning-value-to-next-state-in-PROC-OPTMODEL-Constraints/m-p/512017#M2479</link>
    <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am new to SAS and also using PROC OPTMODEL for the first time. I am trying to do unit commitment of generators.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have loads from hour 1 to 24.&amp;nbsp;&lt;/P&gt;&lt;P&gt;In a particular constraint, I wish to assign the next state of a variable based on a condition.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Code :&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;con count{i in PLANTS, j in HOUROP}:&lt;BR /&gt;if sum{i in PLANTS, j in HOUROP} use_plant[i,j] &amp;lt; pl_minup[i] then use_plant[i,j+1] = 1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, since my loads (j in HOUROP) has values from only 1 to 24, the following error appears&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Error:&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;DIV class="sasError"&gt;ERROR: The array subscript 'use_plant[1,25]' is invalid at line 217 column 68.&lt;/DIV&gt;&lt;DIV class="sasError"&gt;ERROR: The array subscript 'use_plant[2,25]' is invalid at line 217 column 68.&lt;/DIV&gt;&lt;DIV class="sasError"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasError"&gt;I need to limit this constraint to work only till hour =23. I am finding trouble in doing so. Would appreciate any kind of help.&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasError"&gt;Thank you!&lt;/DIV&gt;</description>
    <pubDate>Sun, 11 Nov 2018 17:41:58 GMT</pubDate>
    <dc:creator>nehajain23</dc:creator>
    <dc:date>2018-11-11T17:41:58Z</dc:date>
    <item>
      <title>Assigning value to next state in PROC OPTMODEL Constraints</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Assigning-value-to-next-state-in-PROC-OPTMODEL-Constraints/m-p/512017#M2479</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am new to SAS and also using PROC OPTMODEL for the first time. I am trying to do unit commitment of generators.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have loads from hour 1 to 24.&amp;nbsp;&lt;/P&gt;&lt;P&gt;In a particular constraint, I wish to assign the next state of a variable based on a condition.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Code :&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;con count{i in PLANTS, j in HOUROP}:&lt;BR /&gt;if sum{i in PLANTS, j in HOUROP} use_plant[i,j] &amp;lt; pl_minup[i] then use_plant[i,j+1] = 1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, since my loads (j in HOUROP) has values from only 1 to 24, the following error appears&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Error:&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;DIV class="sasError"&gt;ERROR: The array subscript 'use_plant[1,25]' is invalid at line 217 column 68.&lt;/DIV&gt;&lt;DIV class="sasError"&gt;ERROR: The array subscript 'use_plant[2,25]' is invalid at line 217 column 68.&lt;/DIV&gt;&lt;DIV class="sasError"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasError"&gt;I need to limit this constraint to work only till hour =23. I am finding trouble in doing so. Would appreciate any kind of help.&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasError"&gt;Thank you!&lt;/DIV&gt;</description>
      <pubDate>Sun, 11 Nov 2018 17:41:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Assigning-value-to-next-state-in-PROC-OPTMODEL-Constraints/m-p/512017#M2479</guid>
      <dc:creator>nehajain23</dc:creator>
      <dc:date>2018-11-11T17:41:58Z</dc:date>
    </item>
    <item>
      <title>Re: Assigning value to next state in PROC OPTMODEL Constraints</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Assigning-value-to-next-state-in-PROC-OPTMODEL-Constraints/m-p/512628#M2482</link>
      <description>&lt;P&gt;To avoid the error, you can use a logical condition in the constraint declaration:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;con count{i in PLANTS, j in HOUROP: j+1 in HOUROP}:&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But you also need to rewrite the IF-THEN logic as a linear constraint.&amp;nbsp; Your desired implication is equivalent to its contrapositive:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* if use_plant[i,j+1] = 0 then sum{i in PLANTS, j in HOUROP} use_plant[i,j] &amp;gt;= pl_minup[i] */
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can capture this with a big-M constraint:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;pl_minup[i] - sum{i in PLANTS, j in HOUROP} use_plant[i,j] &amp;lt;= (pl_minup[i] - 0) * use_plant[i,j+1];
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This simplifies to:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;sum{i in PLANTS, j in HOUROP} use_plant[i,j] &amp;gt;= pl_minup[i] * (1 - use_plant[i,j+1]);
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 13 Nov 2018 16:32:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Assigning-value-to-next-state-in-PROC-OPTMODEL-Constraints/m-p/512628#M2482</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2018-11-13T16:32:40Z</dc:date>
    </item>
  </channel>
</rss>

