<?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: setting up a constraint in Mathematical Optimization, Discrete-Event Simulation, and OR</title>
    <link>https://communities.sas.com/t5/Mathematical-Optimization/setting-up-a-constraint/m-p/371085#M1900</link>
    <description>Hi Mr. Pratt,&lt;BR /&gt;Sorry for the bother again. I don't think this solution works as planned. For example, if I put 2 instead of 0.1, I obtain about the same number of persons assigned 2 tasks as those 1 task. Can you please take another look at this?&lt;BR /&gt;Thank you!&lt;BR /&gt;</description>
    <pubDate>Tue, 27 Jun 2017 23:08:39 GMT</pubDate>
    <dc:creator>ilee1801</dc:creator>
    <dc:date>2017-06-27T23:08:39Z</dc:date>
    <item>
      <title>setting up a constraint</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/setting-up-a-constraint/m-p/366998#M1869</link>
      <description>&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem is to assign a number of persons to 5 tasks while maximizing an objective using OPTMODEL. 10%&amp;nbsp;or less of the persons can be assigned 2 tasks while the rest&amp;nbsp;only 1. If the constraint of "no more than 2" can be set up this way,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;con no_more_2&amp;nbsp;{i in persons}: sum {j in tasks} assign[i,j] &amp;lt;= 2;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;how should I specify the constraint of "only &amp;lt;= 10% can be assigned 2 tasks?" I tried the following&lt;/P&gt;&lt;P&gt;con percent: sum {i in persons} (if sum {j in tasks}assign[i,j] &amp;gt; 0 then 1 else 0) &amp;lt;= 10%*total&amp;nbsp;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It did not work and gave&amp;nbsp;this message:&lt;/P&gt;&lt;P&gt;ERROR: The specified optimization technique does not allow nonlinear constraints.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your help!&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jun 2017 15:14:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/setting-up-a-constraint/m-p/366998#M1869</guid>
      <dc:creator>ilee1801</dc:creator>
      <dc:date>2017-06-14T15:14:57Z</dc:date>
    </item>
    <item>
      <title>Re: setting up a constraint</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/setting-up-a-constraint/m-p/367017#M1871</link>
      <description>&lt;P&gt;You can do it by introducing binary variables as follows:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;   var IsTwo {persons} binary;
   con no_more_2 {i in persons}: sum {j in tasks} assign[i,j] &amp;lt;= 1 + IsTwo[i];
   con percent: sum {i in persons} IsTwo[i] &amp;lt;= 0.1*total ;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 16 Jun 2017 14:12:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/setting-up-a-constraint/m-p/367017#M1871</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2017-06-16T14:12:23Z</dc:date>
    </item>
    <item>
      <title>Re: setting up a constraint</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/setting-up-a-constraint/m-p/367493#M1874</link>
      <description>&lt;P&gt;Hi Mr. Pratt,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks so much for the help! I replaced&amp;nbsp;&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;con no_more_2 &lt;SPAN class="token punctuation"&gt;{&lt;/SPAN&gt;i &lt;SPAN class="token operator"&gt;in&lt;/SPAN&gt; persons&lt;SPAN class="token punctuation"&gt;}&lt;/SPAN&gt;: &lt;SPAN class="token function"&gt;sum&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;{&lt;/SPAN&gt;j &lt;SPAN class="token operator"&gt;in&lt;/SPAN&gt; tasks&lt;SPAN class="token punctuation"&gt;}&lt;/SPAN&gt; assign&lt;SPAN class="token punctuation"&gt;[&lt;/SPAN&gt;i&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;j&lt;SPAN class="token punctuation"&gt;]&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;&amp;lt;=&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;1&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;+&lt;/SPAN&gt; IsTwo&lt;SPAN class="token punctuation"&gt;[&lt;/SPAN&gt;i&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;j&lt;SPAN class="token punctuation"&gt;]&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;con percent: &lt;SPAN class="token function"&gt;sum&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;{&lt;/SPAN&gt;i &lt;SPAN class="token operator"&gt;in&lt;/SPAN&gt; persons&lt;SPAN class="token punctuation"&gt;}&lt;/SPAN&gt; IsTwo&lt;SPAN class="token punctuation"&gt;[&lt;/SPAN&gt;i&lt;SPAN class="token punctuation"&gt;]&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;&amp;lt;=&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;10&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;%&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;*&lt;/SPAN&gt;total &lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token punctuation"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;with&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;con no_more_2 &lt;SPAN class="token punctuation"&gt;{&lt;/SPAN&gt;i &lt;SPAN class="token operator"&gt;in&lt;/SPAN&gt; persons&lt;SPAN class="token punctuation"&gt;}&lt;/SPAN&gt;: &lt;SPAN class="token function"&gt;sum&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;{&lt;/SPAN&gt;j &lt;SPAN class="token operator"&gt;in&lt;/SPAN&gt; tasks&lt;SPAN class="token punctuation"&gt;}&lt;/SPAN&gt; assign&lt;SPAN class="token punctuation"&gt;[&lt;/SPAN&gt;i&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;j&lt;SPAN class="token punctuation"&gt;]&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;&amp;lt;=&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;1&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;+&lt;/SPAN&gt; IsTwo&lt;SPAN class="token punctuation"&gt;[&lt;/SPAN&gt;i&lt;SPAN class="token punctuation"&gt;]&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;con percent {j in tasks}: &lt;SPAN class="token function"&gt;sum&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;{&lt;/SPAN&gt;i &lt;SPAN class="token operator"&gt;in&lt;/SPAN&gt; persons&lt;SPAN class="token punctuation"&gt;}&lt;/SPAN&gt; IsTwo&lt;SPAN class="token punctuation"&gt;[&lt;/SPAN&gt;i&lt;SPAN class="token punctuation"&gt;]&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;&amp;lt;=&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;10&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;%&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;*&lt;/SPAN&gt;total &lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token punctuation"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;It seems to have worked. Hope it is correct. An extended question. If I need to replace "total" with the total of persons who are assigned a task, guess it could be specified like this&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;con percent: &lt;SPAN class="token function"&gt;sum&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;{&lt;/SPAN&gt;i &lt;SPAN class="token operator"&gt;in&lt;/SPAN&gt; persons&lt;SPAN class="token punctuation"&gt;}&lt;/SPAN&gt; IsTwo&lt;SPAN class="token punctuation"&gt;[&lt;/SPAN&gt;i&lt;SPAN class="token punctuation"&gt;]&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;&amp;lt;=&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;10&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;%&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;*sum {i in persons} assign[i,j]&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;But this dynamic way of defining the constraint does not wok. What am I missing? Thank you!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2017 20:15:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/setting-up-a-constraint/m-p/367493#M1874</guid>
      <dc:creator>ilee1801</dc:creator>
      <dc:date>2017-06-15T20:15:05Z</dc:date>
    </item>
    <item>
      <title>Re: setting up a constraint</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/setting-up-a-constraint/m-p/367732#M1875</link>
      <description>&lt;P&gt;Thanks for the correction of IsTwo[i,j] to IsTwo[i]. &amp;nbsp;I edited my reply.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For the percent constraint, there is no reason to have a separate constraint for each j. &amp;nbsp;If you use the EXPAND statement, you will see that the same constraint appears several times, once for each j.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your revised constraint declaration has two errors:&lt;/P&gt;
&lt;P&gt;1. Use 0.1 instead of 10%.&lt;/P&gt;
&lt;P&gt;2. The j index is unknown.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's one way to model what you want:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;   con percent:
      sum {i in persons} IsTwo[i] &amp;lt;= 0.1*sum {i in persons} (sum {j in tasks} assign[i,j] - IsTwo[i]);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The idea is that the expression in parentheses is 1 if person i is assigned to at least once task.&lt;/P&gt;</description>
      <pubDate>Sat, 17 Jun 2017 00:47:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/setting-up-a-constraint/m-p/367732#M1875</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2017-06-17T00:47:27Z</dc:date>
    </item>
    <item>
      <title>Re: setting up a constraint</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/setting-up-a-constraint/m-p/367915#M1876</link>
      <description>That is brilliant! Thank you!&lt;BR /&gt;&lt;BR /&gt;Should I change IsTwo[i,j] to IsTwo[i]?&lt;BR /&gt;</description>
      <pubDate>Fri, 16 Jun 2017 23:41:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/setting-up-a-constraint/m-p/367915#M1876</guid>
      <dc:creator>ilee1801</dc:creator>
      <dc:date>2017-06-16T23:41:49Z</dc:date>
    </item>
    <item>
      <title>Re: setting up a constraint</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/setting-up-a-constraint/m-p/367920#M1877</link>
      <description>&lt;P&gt;Glad to help. &amp;nbsp;Yes, please use IsTwo[i]. &amp;nbsp;I edited my reply again to correct that.&lt;/P&gt;</description>
      <pubDate>Sat, 17 Jun 2017 00:48:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/setting-up-a-constraint/m-p/367920#M1877</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2017-06-17T00:48:09Z</dc:date>
    </item>
    <item>
      <title>Re: setting up a constraint</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/setting-up-a-constraint/m-p/371085#M1900</link>
      <description>Hi Mr. Pratt,&lt;BR /&gt;Sorry for the bother again. I don't think this solution works as planned. For example, if I put 2 instead of 0.1, I obtain about the same number of persons assigned 2 tasks as those 1 task. Can you please take another look at this?&lt;BR /&gt;Thank you!&lt;BR /&gt;</description>
      <pubDate>Tue, 27 Jun 2017 23:08:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/setting-up-a-constraint/m-p/371085#M1900</guid>
      <dc:creator>ilee1801</dc:creator>
      <dc:date>2017-06-27T23:08:39Z</dc:date>
    </item>
    <item>
      <title>Re: setting up a constraint</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/setting-up-a-constraint/m-p/371098#M1901</link>
      <description>Please post the full code.</description>
      <pubDate>Wed, 28 Jun 2017 00:06:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/setting-up-a-constraint/m-p/371098#M1901</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2017-06-28T00:06:25Z</dc:date>
    </item>
    <item>
      <title>Re: setting up a constraint</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/setting-up-a-constraint/m-p/371333#M1903</link>
      <description>Here you go. The solution has about 24% of the persons assigned two tasks and 76% one. Is it a matter of precision? Thank you so much!&lt;BR /&gt;&lt;BR /&gt;proc optmodel forcepresolve=1 presolver=3 fd=central misscheck;&lt;BR /&gt;&lt;BR /&gt;performance details;&lt;BR /&gt;profile on percent=0.05;&lt;BR /&gt;&lt;BR /&gt;set persons;&lt;BR /&gt;number id{persons}, x{persons}, cond1{persons}, cond2{persons};&lt;BR /&gt;&lt;BR /&gt;read data test into&lt;BR /&gt;persons=[id] x cond1 cond2 ;&lt;BR /&gt;&lt;BR /&gt;number sumX=sum{i in persons} x[i];&lt;BR /&gt;&lt;BR /&gt;number target=0.1*sumX; /*targeting pool size information????*/&lt;BR /&gt;&lt;BR /&gt;var assign {persons, 1..5} binary;&lt;BR /&gt;var isTwo {persons} binary;&lt;BR /&gt;&lt;BR /&gt;set tasks = 1..5;&lt;BR /&gt;var surplus {tasks} &amp;gt;= 0;&lt;BR /&gt;var slack {tasks} &amp;gt;= 0;&lt;BR /&gt;min objabs = sum {j in tasks} (surplus[j] + slack[j]);&lt;BR /&gt;con obj_alt {j in tasks}: sum {i in persons} assign[i,j]* x[i] - surplus[j] + slack[j] = target;&lt;BR /&gt;&lt;BR /&gt;con taskId {j in 1..5}: sum {i in persons} assign[i,j] = 100;&lt;BR /&gt;&lt;BR /&gt;con no_more_2 {i in persons}: sum {j in 1..5} assign[i,j] &amp;lt;= 1 + isTwo[i];&lt;BR /&gt;&lt;BR /&gt;con percent_1: sum {i in persons} isTwo[i] &amp;lt;= 0.22*sum {i in persons} (sum {j in 1..5} assign[i,j] - isTwo[i]);&lt;BR /&gt;con percent_1: sum {i in persons} isTwo[i] &amp;gt;= 0.18*sum {i in persons} (sum {j in 1..5} assign[i,j] - isTwo[i]);&lt;BR /&gt;&lt;BR /&gt;con con_d1 {j in 1..5}: sum {i in persons} assign[i,j]* cond1[i] &amp;gt;= .10*100;&lt;BR /&gt;con con_d2 {j in 1..5}: sum {i in persons} assign[i,j]* cond1[i] &amp;lt;= .15*100;&lt;BR /&gt;con con_d3 {j in 1..5}: sum {i in persons} assign[i,j]* cond2[i] &amp;gt;= .10*100;&lt;BR /&gt;&lt;BR /&gt;expand;&lt;BR /&gt;solve with milp obj objabs / absobjgap=0.001 primalin ;&lt;BR /&gt;&lt;BR /&gt;create data output from [persons task] = {{i in persons}, {j in 1..5}} in=assign;&lt;BR /&gt;&lt;BR /&gt;quit;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 28 Jun 2017 14:58:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/setting-up-a-constraint/m-p/371333#M1903</guid>
      <dc:creator>ilee1801</dc:creator>
      <dc:date>2017-06-28T14:58:39Z</dc:date>
    </item>
    <item>
      <title>Re: setting up a constraint</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/setting-up-a-constraint/m-p/371368#M1904</link>
      <description>&lt;P&gt;I see that you have declared the percent_1 constraint twice, so that should have generated an error.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you please also attach the test data set?&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jun 2017 16:30:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/setting-up-a-constraint/m-p/371368#M1904</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2017-06-28T16:30:12Z</dc:date>
    </item>
    <item>
      <title>Re: setting up a constraint</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/setting-up-a-constraint/m-p/371460#M1906</link>
      <description>&lt;P&gt;Fixed and now the percentage of persons assigned two task is about 17 to 18. Are the two percent constraints set up correctly? Data file attached. Many thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jun 2017 21:04:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/setting-up-a-constraint/m-p/371460#M1906</guid>
      <dc:creator>ilee1801</dc:creator>
      <dc:date>2017-06-28T21:04:01Z</dc:date>
    </item>
    <item>
      <title>Re: setting up a constraint</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/setting-up-a-constraint/m-p/371484#M1907</link>
      <description>&lt;P&gt;The formulation I suggested enforces only the implication "if person i is assigned two tasks then IsTwo[i] = 1," which is fine if you have only the percent_1 constraint. &amp;nbsp;But the percent_2 constraint also requires the converse implication "if IsTwo[i] = 1 then person i is assigned two tasks." &amp;nbsp;Otherwise, the solver can "cheat" by setting IsTwo[i] = 1 to help satisfy percent_2 even if person i is assigned fewer than 2 tasks. &amp;nbsp;The code below implements&amp;nbsp;a more robust formulation that enforces both implications. &amp;nbsp;Notice that I used tasks instead of 1..5 throughout, and I also combined d1 and d2 into a range constraint.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc optmodel;
   set persons;
   number id{persons}, x{persons}, cond1{persons}, cond2{persons};

   read data test into
      persons=[id] x cond1 cond2;

   number sumX=sum{i in persons} x[i];

   number target=0.1*sumX;

   set tasks = 1..5;
   var assign {persons, tasks} binary;

   var surplus {tasks} &amp;gt;= 0;
   var slack {tasks} &amp;gt;= 0;
   min objabs = sum {j in tasks} (surplus[j] + slack[j]);
   con obj_alt {j in tasks}: sum {i in persons} assign[i,j]* x[i] - surplus[j] + slack[j] = target;

   con taskId {j in tasks}: sum {i in persons} assign[i,j] = 100;

   set counts = 0..2;
   var isCount {persons, counts} binary;
   con onecount {i in persons}: sum {c in counts} isCount[i,c] = 1;
   con isCountDef {i in persons}: sum {j in tasks} assign[i,j] = sum {c in counts} c*isCount[i,c];

   con percent_1: sum {i in persons} isCount[i,2] &amp;lt;= 0.22*sum {i in persons} (1 - isCount[i,0]);
   con percent_2: sum {i in persons} isCount[i,2] &amp;gt;= 0.18*sum {i in persons} (1 - isCount[i,0]);

   con con_d1_d2 {j in tasks}: .10*100 &amp;lt;= sum {i in persons} assign[i,j]* cond1[i] &amp;lt;= .15*100;
   con con_d3 {j in tasks}: sum {i in persons} assign[i,j]* cond2[i] &amp;gt;= .10*100;

   solve;
   put ((sum {i in persons} isCount[i,2]) / (sum {i in persons} (1 - isCount[i,0])));
   num numTasks {i in persons} = round(sum {j in tasks} assign[i,j].sol);
   put (card({i in persons: numTasks[i] = 2}) / card({i in persons: numTasks[i] &amp;gt; 0}));

   create data output from [persons task] in=assign;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 28 Jun 2017 22:38:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/setting-up-a-constraint/m-p/371484#M1907</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2017-06-28T22:38:30Z</dc:date>
    </item>
    <item>
      <title>Re: setting up a constraint</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/setting-up-a-constraint/m-p/374079#M1910</link>
      <description>Thank you so much for the detailed reply! My apologies for being able to come back to this so late. As a novice, I do not quite follow your code, especially the part after "solve". What is more, at my end, the code would run forever before showing the "out of memory" message. Is there a setting I need to change to make it work? Thank you!&lt;BR /&gt;</description>
      <pubDate>Fri, 07 Jul 2017 19:44:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/setting-up-a-constraint/m-p/374079#M1910</guid>
      <dc:creator>ilee1801</dc:creator>
      <dc:date>2017-07-07T19:44:39Z</dc:date>
    </item>
    <item>
      <title>Re: setting up a constraint</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/setting-up-a-constraint/m-p/374576#M1911</link>
      <description>&lt;P&gt;Here are a few suggestions:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Increase the MEMSIZE value, as discussed &lt;A href="http://go.documentation.sas.com/?docsetId=ormpug&amp;amp;docsetVersion=14.2&amp;amp;docsetTarget=ormpug_concepts_sect005.htm&amp;amp;locale=en" target="_self"&gt;here&lt;/A&gt;.&lt;/LI&gt;
&lt;LI&gt;Use the MAXTIME= option to limit the time.&lt;/LI&gt;
&lt;LI&gt;Interrupt the solver when the log shows slow progress.&lt;/LI&gt;
&lt;LI&gt;Use the decomposition algorithm. &amp;nbsp;The following code changes yielded a very good solution quickly for me:&lt;/LI&gt;
&lt;/OL&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;   for {i in persons} do;
      onecount[i].block = i;
      isCountDef[i].block = i;
   end;
   solve with milp / decomp;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The PUT and NUM statements after the SOLVE in the previous code display the ratio of people assigned two tasks to people assigned at least one task. &amp;nbsp;The two PUT statements should show the same value in the log, and that value should be between 0.18 and 0.22, as enforced by the optimization model.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The CREATE DATA statement saves the values of the assign variable in the resulting solution to a SAS data set.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jul 2017 16:04:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/setting-up-a-constraint/m-p/374576#M1911</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2017-07-10T16:04:12Z</dc:date>
    </item>
    <item>
      <title>Re: setting up a constraint</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/setting-up-a-constraint/m-p/375067#M1915</link>
      <description>Thanks for the cool solution! But it has been running for an hour on my computer. I have increased MEMSIZE (Intel i5 and 16G RAM). What else do I need to do? Thanks!&lt;BR /&gt;</description>
      <pubDate>Tue, 11 Jul 2017 18:07:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/setting-up-a-constraint/m-p/375067#M1915</guid>
      <dc:creator>ilee1801</dc:creator>
      <dc:date>2017-07-11T18:07:39Z</dc:date>
    </item>
    <item>
      <title>Re: setting up a constraint</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/setting-up-a-constraint/m-p/375089#M1916</link>
      <description>&lt;P&gt;If the solution found within an hour is acceptable, you could set MAXTIME=3600.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to find&amp;nbsp;solver option&amp;nbsp;settings that will yield an optimal solution more quickly, you might try the &lt;A href="http://go.documentation.sas.com/?docsetId=ormpug&amp;amp;docsetVersion=14.2&amp;amp;docsetTarget=ormpug_tuner_toc.htm&amp;amp;locale=en" target="_self"&gt;OPTMILP option tuner&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jul 2017 18:49:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/setting-up-a-constraint/m-p/375089#M1916</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2017-07-11T18:49:32Z</dc:date>
    </item>
  </channel>
</rss>

