<?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: summation of non-zero elements of sparse matrix using optmodel in Mathematical Optimization, Discrete-Event Simulation, and OR</title>
    <link>https://communities.sas.com/t5/Mathematical-Optimization/summation-of-non-zero-elements-of-sparse-matrix-using-optmodel/m-p/161771#M845</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can write this more compactly by using an "implicit" slice:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; con test{t in ASC}: sum{&amp;lt;(t),u&amp;gt; in Map} y&lt;U&gt; &amp;gt;= 0;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;See this doc example for more discussion:&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/ormpex/67518/HTML/default/viewer.htm#ormpex_ex5_toc.htm" title="http://support.sas.com/documentation/cdl/en/ormpex/67518/HTML/default/viewer.htm#ormpex_ex5_toc.htm"&gt;SAS/OR(R) 13.2 User's Guide: Mathematical Programming Examples&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 07 Nov 2014 17:49:32 GMT</pubDate>
    <dc:creator>RobPratt</dc:creator>
    <dc:date>2014-11-07T17:49:32Z</dc:date>
    <item>
      <title>summation of non-zero elements of sparse matrix using optmodel</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/summation-of-non-zero-elements-of-sparse-matrix-using-optmodel/m-p/161770#M844</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a constraint which sums the nonzero elements of a sparse matrix. To do this, I am using the SLICE expression, so my constraint reads&lt;BR /&gt;like this:&lt;/P&gt;&lt;P&gt;con test{t in ASC}:sum{u in slice(&amp;lt;t,*&amp;gt;,Map)}y&lt;U&gt;&amp;gt;=0;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;Here 'Map' is a sparse matrix, with 2 mapped variables - ASC and UIN, i.e. 'Map' contains all eligible pairs of ASC and UIN. &lt;BR /&gt;The constraint should work like this: For each element 't' of ASC, it should check whether 't' has a corresponding value 'u' for UIN variable. If there is, then it adds y for that row.&lt;BR /&gt;However, when I run this constraint, I get a "Constraint is empty" error.&lt;/P&gt;&lt;P&gt;What am I doing wrong here/is there a better way of doing this?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Nov 2014 17:41:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/summation-of-non-zero-elements-of-sparse-matrix-using-optmodel/m-p/161770#M844</guid>
      <dc:creator>abhik_giri</dc:creator>
      <dc:date>2014-11-07T17:41:57Z</dc:date>
    </item>
    <item>
      <title>Re: summation of non-zero elements of sparse matrix using optmodel</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/summation-of-non-zero-elements-of-sparse-matrix-using-optmodel/m-p/161771#M845</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can write this more compactly by using an "implicit" slice:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; con test{t in ASC}: sum{&amp;lt;(t),u&amp;gt; in Map} y&lt;U&gt; &amp;gt;= 0;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;See this doc example for more discussion:&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/ormpex/67518/HTML/default/viewer.htm#ormpex_ex5_toc.htm" title="http://support.sas.com/documentation/cdl/en/ormpex/67518/HTML/default/viewer.htm#ormpex_ex5_toc.htm"&gt;SAS/OR(R) 13.2 User's Guide: Mathematical Programming Examples&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Nov 2014 17:49:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/summation-of-non-zero-elements-of-sparse-matrix-using-optmodel/m-p/161771#M845</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2014-11-07T17:49:32Z</dc:date>
    </item>
    <item>
      <title>Re: summation of non-zero elements of sparse matrix using optmodel</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/summation-of-non-zero-elements-of-sparse-matrix-using-optmodel/m-p/161772#M846</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the link.&lt;/P&gt;&lt;P&gt;Somehow the constraint you gave doesn't seem to work(again a "Constraint is empty" error). But the following constraint worked(I got it from the link you gave):&lt;/P&gt;&lt;P&gt;con test{t in ASC}:sum{u in UIN:&amp;lt;u,t&amp;gt; in Map}y&lt;U&gt;&amp;gt;=0;&lt;/U&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 08 Nov 2014 08:18:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/summation-of-non-zero-elements-of-sparse-matrix-using-optmodel/m-p/161772#M846</guid>
      <dc:creator>abhik_giri</dc:creator>
      <dc:date>2014-11-08T08:18:11Z</dc:date>
    </item>
    <item>
      <title>Re: summation of non-zero elements of sparse matrix using optmodel</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/summation-of-non-zero-elements-of-sparse-matrix-using-optmodel/m-p/161773#M847</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your latest version is not equivalent to the other two.&amp;nbsp; Instead, it should be:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; con test{t in ASC}:sum{u in UIN:&amp;lt;t,u&amp;gt; in Map}y&lt;U&gt;&amp;gt;=0;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, the "Constraint is empty" message is only a NOTE and not an ERROR.&amp;nbsp; If you use the EXPAND statement, you will see that the constraint is 0 &amp;gt;= 0 because the sum is empty.&amp;nbsp; If you really want to avoid generating these constraints, you can use a logical condition:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; con test{t in ASC: card(slice(&amp;lt;t,*&amp;gt;,Map)) &amp;gt; 0}:sum{u in slice(&amp;lt;t,*&amp;gt;,Map)}y&lt;U&gt;&amp;gt;=0;&lt;/U&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 08 Nov 2014 17:36:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/summation-of-non-zero-elements-of-sparse-matrix-using-optmodel/m-p/161773#M847</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2014-11-08T17:36:41Z</dc:date>
    </item>
  </channel>
</rss>

