<rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0">
  <channel>
    <title>MaplePrimes - answers and comments on Question, cardinal constraint in a {-1,0,1} Linear Program</title>
    <link>http://www.mapleprimes.com/questions/100761-Cardinal-Constraint-In-A-101-Linear-Program</link>
    <language>en-us</language>
    <copyright>2026 Maplesoft, A Division of Waterloo Maple Inc.</copyright>
    <generator>Maplesoft Document System</generator>
    <lastBuildDate>Tue, 16 Jun 2026 06:19:08 GMT</lastBuildDate>
    <pubDate>Tue, 16 Jun 2026 06:19:08 GMT</pubDate>
    <itunes:subtitle />
    <itunes:summary />
    <description>The latest answers and comments added to the Question, cardinal constraint in a {-1,0,1} Linear Program</description>
    <image>
      <url>http://www.mapleprimes.com/images/mapleprimeswhite.jpg</url>
      <title>MaplePrimes - answers and comments on Question, cardinal constraint in a {-1,0,1} Linear Program</title>
      <link>http://www.mapleprimes.com/questions/100761-Cardinal-Constraint-In-A-101-Linear-Program</link>
    </image>
    <item>
      <title>Not linear</title>
      <link>http://www.mapleprimes.com/questions/100761-Cardinal-Constraint-In-A-101-Linear-Program?ref=Feed:MaplePrimes:cardinal constraint in a {-1,0,1} Linear Program:Comments#answer100764</link>
      <itunes:summary>&lt;p&gt;Maple is exactly right: the constraint is not linear.&amp;nbsp; Well, you could this: for each i, have a new variable v[i] with constraints v[i] &amp;gt;= w[i] and v[i] &amp;gt;= -w[i], and then you can have a constraint &lt;span class="mainBody document"&gt;add(v[i], i = 1 .. NC) &amp;lt;= 4.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="mainBody document"&gt;Note that I said &amp;lt;= 4, not = 4, because v[i] &amp;gt;= w[i] and v[i] &amp;gt;= -w[i] just forces v[i] &amp;gt;= abs(w[i]), not v[i] = abs(w[i]).&amp;nbsp; In fact, the feasible region ceases to be convex if you require the number of 1's and -1's to be equal to 4: in a convex problem, if w[i] = -1 and w[i] = 1 are allowed then w[i] = 0. &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="mainBody document"&gt;&lt;br&gt;&lt;/span&gt;&lt;/p&gt;</itunes:summary>
      <description>&lt;p&gt;Maple is exactly right: the constraint is not linear.&amp;nbsp; Well, you could this: for each i, have a new variable v[i] with constraints v[i] &amp;gt;= w[i] and v[i] &amp;gt;= -w[i], and then you can have a constraint &lt;span class="mainBody document"&gt;add(v[i], i = 1 .. NC) &amp;lt;= 4.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="mainBody document"&gt;Note that I said &amp;lt;= 4, not = 4, because v[i] &amp;gt;= w[i] and v[i] &amp;gt;= -w[i] just forces v[i] &amp;gt;= abs(w[i]), not v[i] = abs(w[i]).&amp;nbsp; In fact, the feasible region ceases to be convex if you require the number of 1's and -1's to be equal to 4: in a convex problem, if w[i] = -1 and w[i] = 1 are allowed then w[i] = 0. &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="mainBody document"&gt;&lt;br&gt;&lt;/span&gt;&lt;/p&gt;</description>
      <guid>100764</guid>
      <pubDate>Mon, 10 Jan 2011 00:11:24 Z</pubDate>
      <itunes:author>Robert Israel</itunes:author>
      <author>Robert Israel</author>
    </item>
    <item>
      <title>Second thought</title>
      <link>http://www.mapleprimes.com/questions/100761-Cardinal-Constraint-In-A-101-Linear-Program?ref=Feed:MaplePrimes:cardinal constraint in a {-1,0,1} Linear Program:Comments#answer100786</link>
      <itunes:summary>&lt;p&gt;On second thought, it is possible to make the number of 1's and -1's equal to 4 with integer linear programming.&amp;nbsp; For each i, you have two new binary variables a[i] and b[i] with the constraints w[i] = a[i] - b[i], a[i] +b[i] &amp;lt;= 1 (so the possibilities are w[i] = -1 with a[i]=0, b[i]=1, w[i]=0 with a[i]=b[i]=0, w[i]=1 with a[i]=1, b[i]=0), and then &lt;br&gt;add(a[i] + b[i],i=1 .. NC) = 4.&lt;/p&gt;</itunes:summary>
      <description>&lt;p&gt;On second thought, it is possible to make the number of 1's and -1's equal to 4 with integer linear programming.&amp;nbsp; For each i, you have two new binary variables a[i] and b[i] with the constraints w[i] = a[i] - b[i], a[i] +b[i] &amp;lt;= 1 (so the possibilities are w[i] = -1 with a[i]=0, b[i]=1, w[i]=0 with a[i]=b[i]=0, w[i]=1 with a[i]=1, b[i]=0), and then &lt;br&gt;add(a[i] + b[i],i=1 .. NC) = 4.&lt;/p&gt;</description>
      <guid>100786</guid>
      <pubDate>Mon, 10 Jan 2011 21:24:15 Z</pubDate>
      <itunes:author>Robert Israel</itunes:author>
      <author>Robert Israel</author>
    </item>
    <item>
      <title>Thanx for that Robert! In the end I did like</title>
      <link>http://www.mapleprimes.com/questions/100761-Cardinal-Constraint-In-A-101-Linear-Program?ref=Feed:MaplePrimes:cardinal constraint in a {-1,0,1} Linear Program:Comments#answer100787</link>
      <itunes:summary>&lt;p&gt;Thanx for that Robert! In the end I did like this: &lt;br&gt;&lt;br&gt;PS:=4:&lt;br&gt;seq(v[i] &amp;gt;= w[i], i = 1 .. NC), seq(v[i] &amp;gt;= -w[i], i = 1 .. NC), &lt;br&gt;add(v[i], i = 1 .. NC) &amp;lt;= 2*PS, add(w[i], i = 1 .. NC) = 0;&lt;br&gt;&lt;br&gt;Then I get 4 long (1) and 4 short (-1) positions and the rest 0.&lt;/p&gt;</itunes:summary>
      <description>&lt;p&gt;Thanx for that Robert! In the end I did like this: &lt;br&gt;&lt;br&gt;PS:=4:&lt;br&gt;seq(v[i] &amp;gt;= w[i], i = 1 .. NC), seq(v[i] &amp;gt;= -w[i], i = 1 .. NC), &lt;br&gt;add(v[i], i = 1 .. NC) &amp;lt;= 2*PS, add(w[i], i = 1 .. NC) = 0;&lt;br&gt;&lt;br&gt;Then I get 4 long (1) and 4 short (-1) positions and the rest 0.&lt;/p&gt;</description>
      <guid>100787</guid>
      <pubDate>Mon, 10 Jan 2011 22:35:26 Z</pubDate>
      <itunes:author>alex_01</itunes:author>
      <author>alex_01</author>
    </item>
    <item>
      <title>Thanx Robert :-) Works great!&amp;nbsp; You are</title>
      <link>http://www.mapleprimes.com/questions/100761-Cardinal-Constraint-In-A-101-Linear-Program?ref=Feed:MaplePrimes:cardinal constraint in a {-1,0,1} Linear Program:Comments#comment100769</link>
      <itunes:summary>&lt;p&gt;Thanx Robert :-) Works great!&amp;nbsp; &lt;br&gt;You are stable as usual!&lt;/p&gt;</itunes:summary>
      <description>&lt;p&gt;Thanx Robert :-) Works great!&amp;nbsp; &lt;br&gt;You are stable as usual!&lt;/p&gt;</description>
      <guid>100769</guid>
      <pubDate>Mon, 10 Jan 2011 01:59:49 Z</pubDate>
      <itunes:author>alex_01</itunes:author>
      <author>alex_01</author>
    </item>
  </channel>
</rss>