<?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 How do I use alldiff for the results of a constraint? in Mathematical Optimization, Discrete-Event Simulation, and OR</title>
    <link>https://communities.sas.com/t5/Mathematical-Optimization/How-do-I-use-alldiff-for-the-results-of-a-constraint/m-p/407711#M2019</link>
    <description>&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am&amp;nbsp;unable to use alldiff&amp;nbsp;within a constraint. My intention is to&amp;nbsp;constrain all results from difcolrow to be different from each other. I am using SAS Studio (web based).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Find below&amp;nbsp;a code&amp;nbsp;with an example using &lt;STRONG&gt;&amp;gt;=-3&lt;/STRONG&gt; in the difcolrow constraint to illustrate what I mean:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc optmodel;

set column={'1','2','3','4'};
set row={'1','2','3','4'};

var x{column} &amp;gt;=1 &amp;lt;=4 integer;
var y{row} &amp;gt;=1 &amp;lt;=4 integer;

con alldiff(x);
con alldiff(y);
con difcolrow{i in column}: x[i]-y[i]&amp;gt;=-3;

solve; print x y difcolrow.body; quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="code results" style="width: 191px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/16242i816DC8C7D07B5F22/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2017-10-26 at 18.17.56.png" alt="code results" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;code results&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As you can see the difcolrow has several results equal to zero. What I want is all this difcolrow values to be also all different from each other.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried too use alldiff in the constraint in different ways, but I got continuous code errors:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;con difcolrow{i in column}: alldiff(x[i]-y[i]);&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It is possible to do it using alldiff? Any other idea about how to do it? Thanks a lot.&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>Thu, 26 Oct 2017 16:27:51 GMT</pubDate>
    <dc:creator>carenman</dc:creator>
    <dc:date>2017-10-26T16:27:51Z</dc:date>
    <item>
      <title>How do I use alldiff for the results of a constraint?</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/How-do-I-use-alldiff-for-the-results-of-a-constraint/m-p/407711#M2019</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am&amp;nbsp;unable to use alldiff&amp;nbsp;within a constraint. My intention is to&amp;nbsp;constrain all results from difcolrow to be different from each other. I am using SAS Studio (web based).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Find below&amp;nbsp;a code&amp;nbsp;with an example using &lt;STRONG&gt;&amp;gt;=-3&lt;/STRONG&gt; in the difcolrow constraint to illustrate what I mean:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc optmodel;

set column={'1','2','3','4'};
set row={'1','2','3','4'};

var x{column} &amp;gt;=1 &amp;lt;=4 integer;
var y{row} &amp;gt;=1 &amp;lt;=4 integer;

con alldiff(x);
con alldiff(y);
con difcolrow{i in column}: x[i]-y[i]&amp;gt;=-3;

solve; print x y difcolrow.body; quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="code results" style="width: 191px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/16242i816DC8C7D07B5F22/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2017-10-26 at 18.17.56.png" alt="code results" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;code results&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As you can see the difcolrow has several results equal to zero. What I want is all this difcolrow values to be also all different from each other.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried too use alldiff in the constraint in different ways, but I got continuous code errors:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;con difcolrow{i in column}: alldiff(x[i]-y[i]);&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It is possible to do it using alldiff? Any other idea about how to do it? Thanks a lot.&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>Thu, 26 Oct 2017 16:27:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/How-do-I-use-alldiff-for-the-results-of-a-constraint/m-p/407711#M2019</guid>
      <dc:creator>carenman</dc:creator>
      <dc:date>2017-10-26T16:27:51Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use alldiff for the results of a constraint?</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/How-do-I-use-alldiff-for-the-results-of-a-constraint/m-p/407744#M2020</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;con difcolrow: alldiff({i in column} (x[i]-y[i]));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 26 Oct 2017 17:25:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/How-do-I-use-alldiff-for-the-results-of-a-constraint/m-p/407744#M2020</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2017-10-26T17:25:49Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use alldiff for the results of a constraint?</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/How-do-I-use-alldiff-for-the-results-of-a-constraint/m-p/407759#M2021</link>
      <description>&lt;P&gt;Thanks for the reply RobPratt.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried your solution and I still get some code errors:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 59         
 60         proc optmodel;
 61         
 62         set column={'1','2','3','4'};
 63         set row={'1','2','3','4'};
 64         
 65         var x{column} &amp;gt;=1 &amp;lt;=4 integer;
 66         var y{row} &amp;gt;=1 &amp;lt;=4 integer;
 67         
 68         con alldiff(x);
 69         con alldiff(y);
 70         con difcolrow: alldiff({i in column} (x[i]-y[i]));
                                                 _    _   _
                                                 22   79  621
                                                 200
 ERROR 22-322: Expecting a name.  
 
 ERROR 79-322: Expecting a {.
 
 ERROR 621-782: Subscript 1 must be a string, found a number.
 
 ERROR 200-322: The symbol is not recognized and will be ignored.
 
                                                         _
                                                         525
 ERROR 525-782: The symbol 'i' is unknown.
 
                                                           _
                                                           76
 ERROR 76-322: Syntax error, statement will be ignored.
 
 70       ! con difcolrow: alldiff({i in column} (x[i]-y[i]));
                                                           _
                                                           22
 ERROR 22-322: Syntax error, expecting one of the following: !!, *, **, +, ',', -, .., /, :, &amp;lt;&amp;gt;, &amp;gt;&amp;lt;, BY, CROSS, DIFF, ELSE, INTER, 
               SYMDIFF, TO, UNION, ^, ||, }.  
 
 71         
 72         solve;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Maybe&amp;nbsp;ALLDIFF can only be applied to VAR and not to the result of operations made with VARS?&lt;/P&gt;</description>
      <pubDate>Thu, 26 Oct 2017 18:02:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/How-do-I-use-alldiff-for-the-results-of-a-constraint/m-p/407759#M2021</guid>
      <dc:creator>carenman</dc:creator>
      <dc:date>2017-10-26T18:02:35Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use alldiff for the results of a constraint?</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/How-do-I-use-alldiff-for-the-results-of-a-constraint/m-p/407763#M2022</link>
      <description>&lt;P&gt;Here's a workaround if you are not using the latest release:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;var diff {column} integer;
con diffcon {i in column}: diff[i] = x[i] - y[i];
con difcolrow: alldiff(diff);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 26 Oct 2017 18:12:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/How-do-I-use-alldiff-for-the-results-of-a-constraint/m-p/407763#M2022</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2017-10-26T18:12:48Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use alldiff for the results of a constraint?</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/How-do-I-use-alldiff-for-the-results-of-a-constraint/m-p/407768#M2023</link>
      <description>&lt;P&gt;This workaround worked perfectly. Thanks a lot.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using SAS Studio, web based. I guess it is not the latest version:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class="dijitDialogPaneContentArea"&gt;&lt;DIV class="dijitTabContainer dijitTabContainerTop dijitContainer dijitLayoutContainer tabStrip-disabled"&gt;&lt;DIV class="dijitTabPaneWrapper dijitTabContainerTop-container dijitAlignCenter"&gt;&lt;DIV class="dijitTabContainerTopChildWrapper dijitVisible"&gt;&lt;DIV class="dijitContentPane dijitTabPane dijitTabContainerTop-child dijitTabContainerTop-dijitContentPane"&gt;&lt;DIV&gt;&lt;STRONG&gt;Release: 3.6 (Enterprise Edition)&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Supported browsers:&lt;/STRONG&gt;&lt;UL&gt;&lt;LI&gt;Microsoft Internet Explorer 11&lt;/LI&gt;&lt;LI&gt;Mozilla Firefox 21+&lt;/LI&gt;&lt;LI&gt;Google Chrome 27+&lt;/LI&gt;&lt;LI&gt;Apple Safari 6.0+ (on Apple OS X)&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;Build date:&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;Apr 20, 2017 3:45:55 PM&lt;BR /&gt;&lt;STRONG&gt;SAS Mid-tier release:&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;Apr 18, 2017 2:38:00 PM&lt;BR /&gt;&lt;STRONG&gt;Java Version: 1.7.0_111&lt;BR /&gt;SAS release:&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;9.04.01M4P11092016&lt;BR /&gt;SAS platform:&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;Linux LIN X64 3.10.0-693.2.2.el7.x86_64&lt;BR /&gt;Site name:&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;SAS ONDEMAND FOR ACADEMICS&lt;BR /&gt;Site number:&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;70094220&lt;BR /&gt;&lt;BR /&gt;Copyright © 2012-2017, SAS Institute Inc., Cary, NC, USA.&lt;/STRONG&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 26 Oct 2017 18:31:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/How-do-I-use-alldiff-for-the-results-of-a-constraint/m-p/407768#M2023</guid>
      <dc:creator>carenman</dc:creator>
      <dc:date>2017-10-26T18:31:42Z</dc:date>
    </item>
  </channel>
</rss>

