<?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: proc optmodel - How can I invoke a do statement in an impvar decalaration in Mathematical Optimization, Discrete-Event Simulation, and OR</title>
    <link>https://communities.sas.com/t5/Mathematical-Optimization/proc-optmodel-How-can-I-invoke-a-do-statement-in-an-impvar/m-p/379479#M1932</link>
    <description>&lt;P&gt;Does trg_grp_busy need to be known by the solver, or is it okay to be calculated after the solve?&lt;/P&gt;</description>
    <pubDate>Wed, 26 Jul 2017 17:25:39 GMT</pubDate>
    <dc:creator>RobPratt</dc:creator>
    <dc:date>2017-07-26T17:25:39Z</dc:date>
    <item>
      <title>proc optmodel - How can I invoke a do statement in an impvar decalaration</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/proc-optmodel-How-can-I-invoke-a-do-statement-in-an-impvar/m-p/379466#M1931</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to create an impvar that adds a value that shows that an organisation is busy between two dates.&amp;nbsp; The code correctly calculates the number of times a Org is tasked between a two dates.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;CODE A&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc optmodel;


set &amp;lt;number&amp;gt; PERIOD = 0.. 100; /*Sets the periods which an event can take place */
set FE = {'GG','WG','1RI','SG'};  /* Possible FEs */
set TASKS = {'PS', 'WS', 'WX', 'TT'};
number i;
num trg_grp_busy{FE, PERIOD} init 0;  /* Holds the periods in which a FE is busy, could be on an activity, 
setup or downtime activity or Leave */


num ACT_ST{FE, TASKS} = [ 1     3    4    0
                          3     2    6    2
                                  2  5    2    5
                                  0  1    2    3];

num ACT_END{FE, TASKS} = [2     5    6    1
                          4     7    8    4
                                  4  6    3    7
                                  2  4    5    5];

for {f in FE, T in TASKS}
do i = ACT_ST[f,T] to ACT_END[f,T];
   trg_grp_busy[f,i] = trg_grp_busy[f,i] + 1;
end;


quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;When I add a var X[f,T] and create an impvar using the logic in the For ... DO loop I get a errors.&amp;nbsp; How can I create an impvar using this logic or ensure that the variable&amp;nbsp;is recalculated when solve is called.&amp;nbsp; I have tried created an impvar using the logic and an impvar that reference another variable but they are not updated for the values of X[f,T]&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc optmodel;


set &amp;lt;number&amp;gt; PERIOD = 0.. 100; /*Sets the periods which an event can take place */
set FE = {'GG','WG','1RI','SG'};  /* Possible FEs */
set TASKS = {'PS', 'WS', 'WX', 'TT'};
number i;
num trg_grp_busy{FE, PERIOD} init 0;  /* Holds the periods in which a FE is busy, could be on an activity, 
setup or downtime activity or Leave */

var X{FE, TASKS} integer &amp;gt;=0 &amp;lt;= 20;

num ACT_END{FE, TASKS} = [2     5    6    1
                          4     7    8    4
                                  4  6    3    7
                                  2  4    5    5];

impvar CONSTRAINTS{f in FE, P in PERIOD} = trg_grp_busy[f,P];
for {f in FE, T in TASKS}
do i = X[f,T] to ACT_END[f,T];
   trg_grp_busy[f,i] = trg_grp_busy[f,i] + 1;
end;


max HP = sum{f in FE, T in TASKS} X[f,T]*ACT_ST[f,T];
solve;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;version 14.2&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Thanks&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jul 2017 17:02:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/proc-optmodel-How-can-I-invoke-a-do-statement-in-an-impvar/m-p/379466#M1931</guid>
      <dc:creator>liam847</dc:creator>
      <dc:date>2017-07-26T17:02:05Z</dc:date>
    </item>
    <item>
      <title>Re: proc optmodel - How can I invoke a do statement in an impvar decalaration</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/proc-optmodel-How-can-I-invoke-a-do-statement-in-an-impvar/m-p/379479#M1932</link>
      <description>&lt;P&gt;Does trg_grp_busy need to be known by the solver, or is it okay to be calculated after the solve?&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jul 2017 17:25:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/proc-optmodel-How-can-I-invoke-a-do-statement-in-an-impvar/m-p/379479#M1932</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2017-07-26T17:25:39Z</dc:date>
    </item>
    <item>
      <title>Re: proc optmodel - How can I invoke a do statement in an impvar decalaration</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/proc-optmodel-How-can-I-invoke-a-do-statement-in-an-impvar/m-p/379605#M1933</link>
      <description>&lt;P&gt;It may not hurt to so the code and the error messages from the log. Since error messages sometimes have indicators where the error occurs you would want to paste the information into a code box opened using the forum {i} icon to preserve the formatting. The main message windows on this forum will signficantly reformat some text making the error indicators less than helpful.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jul 2017 22:59:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/proc-optmodel-How-can-I-invoke-a-do-statement-in-an-impvar/m-p/379605#M1933</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-07-26T22:59:16Z</dc:date>
    </item>
    <item>
      <title>Re: proc optmodel - How can I invoke a do statement in an impvar decalaration</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/proc-optmodel-How-can-I-invoke-a-do-statement-in-an-impvar/m-p/379656#M1935</link>
      <description>&lt;P&gt;Rob&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;trg_grp_busy needs to be known by the solver as it will be used in a constraint as the trg grps&amp;nbsp;can only be scheduled on a number of events. during any one period.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would use proc CLP to schedule the events but I need added functionaity in that if resource X has been selected for use on &amp;nbsp;Activity A then Activity B also needs to use Resource X.&amp;nbsp; I believe that this functionality is under consideration for a future release.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanlks&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jul 2017 09:24:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/proc-optmodel-How-can-I-invoke-a-do-statement-in-an-impvar/m-p/379656#M1935</guid>
      <dc:creator>qliam</dc:creator>
      <dc:date>2017-07-27T09:24:20Z</dc:date>
    </item>
    <item>
      <title>Re: proc optmodel - How can I invoke a do statement in an impvar decalaration</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/proc-optmodel-How-can-I-invoke-a-do-statement-in-an-impvar/m-p/383921#M1942</link>
      <description>&lt;P&gt;Your response reminded me of &lt;A href="https://communities.sas.com/t5/Mathematical-Optimization/Resource-Constraints-using-Proc-CLP/m-p/366934#M1867" target="_self"&gt;this post&lt;/A&gt;&amp;nbsp;from last month. &amp;nbsp;I have added another reply there to illustrate how you can model resource constraints with MILP.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;By the way, here are several equivalent ways to calculate trg_grp_busy as a numeric parameter as in Code A, but without an explicit DO loop:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;num trg_grp_busy2{f in FE, P in PERIOD} = 
   card({T in TASKS: P in ACT_ST[f,T]..ACT_END[f,T]});
num trg_grp_busy3{f in FE, P in PERIOD} = 
   sum {T in TASKS: P in ACT_ST[f,T]..ACT_END[f,T]} 1;
num trg_grp_busy4{f in FE, P in PERIOD} = 
   sum {T in TASKS} (P in ACT_ST[f,T]..ACT_END[f,T]);
num trg_grp_busy5{f in FE, P in PERIOD} = 
   sum {T in TASKS} (ACT_ST[f,T] &amp;lt;= P &amp;lt;= ACT_END[f,T]);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jul 2017 20:33:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/proc-optmodel-How-can-I-invoke-a-do-statement-in-an-impvar/m-p/383921#M1942</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2017-07-28T20:33:32Z</dc:date>
    </item>
    <item>
      <title>Re: proc optmodel - How can I invoke a do statement in an impvar decalaration</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/proc-optmodel-How-can-I-invoke-a-do-statement-in-an-impvar/m-p/387352#M1948</link>
      <description>Rob&lt;BR /&gt;&lt;BR /&gt;Sorry for delay in responding to your post but I have been out of the&lt;BR /&gt;country.&lt;BR /&gt;&lt;BR /&gt;Many thanks for the amended code here&lt;BR /&gt;ts-using-Proc-CLP/m-p/366934#M1867&amp;gt; although I couldn't get the code to&lt;BR /&gt;achieve the answer I expected. The schedres file shows all activities being&lt;BR /&gt;assigned the LONDON resource. If add an addition line of code&lt;BR /&gt;&lt;BR /&gt;con OneResourceLoc {a in ACTIVITIES} : sum{r in RESOURCES} IsRes[r,a] &amp;lt;= 1;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;it selects the correct resources for the activities.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I cannot however get it to only allocate each resource to only one activity&lt;BR /&gt;at a time. The code is currently allocating VANCOVER to event AB2 (start 50,&lt;BR /&gt;End 70) and to event AB4 (start 30, end 60).&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;What am I missing?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Many Thanks&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 11 Aug 2017 14:33:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/proc-optmodel-How-can-I-invoke-a-do-statement-in-an-impvar/m-p/387352#M1948</guid>
      <dc:creator>liam847</dc:creator>
      <dc:date>2017-08-11T14:33:01Z</dc:date>
    </item>
    <item>
      <title>Re: proc optmodel - How can I invoke a do statement in an impvar decalaration</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/proc-optmodel-How-can-I-invoke-a-do-statement-in-an-impvar/m-p/387403#M1949</link>
      <description>&lt;P&gt;Sorry, there were a few errors. &amp;nbsp;I have now corrected the code. &amp;nbsp;Please try again.&lt;/P&gt;</description>
      <pubDate>Fri, 11 Aug 2017 16:19:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/proc-optmodel-How-can-I-invoke-a-do-statement-in-an-impvar/m-p/387403#M1949</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2017-08-11T16:19:50Z</dc:date>
    </item>
    <item>
      <title>Re: proc optmodel - How can I invoke a do statement in an impvar decalaration</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/proc-optmodel-How-can-I-invoke-a-do-statement-in-an-impvar/m-p/387838#M1951</link>
      <description>&lt;P&gt;Rob,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;that works.&amp;nbsp; Many thanks for your help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Aug 2017 16:11:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/proc-optmodel-How-can-I-invoke-a-do-statement-in-an-impvar/m-p/387838#M1951</guid>
      <dc:creator>liam847</dc:creator>
      <dc:date>2017-08-14T16:11:14Z</dc:date>
    </item>
  </channel>
</rss>

