<?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 Define constraints and optimization function in matrix form in Mathematical Optimization, Discrete-Event Simulation, and OR</title>
    <link>https://communities.sas.com/t5/Mathematical-Optimization/Define-constraints-and-optimization-function-in-matrix-form/m-p/566862#M2797</link>
    <description>&lt;P&gt;I'm getting stuck in defining constraints and the optimization function in matrix form for proc optmodel.&lt;/P&gt;
&lt;P&gt;Suppose these scenarios:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1) I have two vectors A and B, and my constraint is A&amp;lt;=B (meaning: element-wise). How can I write it without a for loop to cycle the on the elements?&lt;/P&gt;
&lt;P&gt;2) I have two matrices A and B, and my constraint is A[:, k]' * B[: ,k] &amp;lt;= 0 for each k in 1..n (meaning: for each k in 1..n, take the k-th column of matrix A, transpose it, take the k-th column of matrix B, and do the scalar product between the two vectors; this number must be &amp;lt;=0).&amp;nbsp;How can I write it with only one for loop to cycle over k?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;These conditions are very easy to write e.g. in Matlab, but I find very difficult to write them in the proc optmodel.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How would you do that?&lt;/P&gt;
&lt;P&gt;Any help appreciated,&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
    <pubDate>Tue, 18 Jun 2019 13:30:36 GMT</pubDate>
    <dc:creator>Edoedoedo</dc:creator>
    <dc:date>2019-06-18T13:30:36Z</dc:date>
    <item>
      <title>Define constraints and optimization function in matrix form</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Define-constraints-and-optimization-function-in-matrix-form/m-p/566862#M2797</link>
      <description>&lt;P&gt;I'm getting stuck in defining constraints and the optimization function in matrix form for proc optmodel.&lt;/P&gt;
&lt;P&gt;Suppose these scenarios:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1) I have two vectors A and B, and my constraint is A&amp;lt;=B (meaning: element-wise). How can I write it without a for loop to cycle the on the elements?&lt;/P&gt;
&lt;P&gt;2) I have two matrices A and B, and my constraint is A[:, k]' * B[: ,k] &amp;lt;= 0 for each k in 1..n (meaning: for each k in 1..n, take the k-th column of matrix A, transpose it, take the k-th column of matrix B, and do the scalar product between the two vectors; this number must be &amp;lt;=0).&amp;nbsp;How can I write it with only one for loop to cycle over k?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;These conditions are very easy to write e.g. in Matlab, but I find very difficult to write them in the proc optmodel.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How would you do that?&lt;/P&gt;
&lt;P&gt;Any help appreciated,&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jun 2019 13:30:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Define-constraints-and-optimization-function-in-matrix-form/m-p/566862#M2797</guid>
      <dc:creator>Edoedoedo</dc:creator>
      <dc:date>2019-06-18T13:30:36Z</dc:date>
    </item>
    <item>
      <title>Re: Define constraints and optimization function in matrix form</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Define-constraints-and-optimization-function-in-matrix-form/m-p/566926#M2798</link>
      <description>&lt;P&gt;PROC OPTMODEL uses algebraic expressions to declare such constraints:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;   var A {1..n};
   var B {1..n};
   con MyCon {i in 1..n}:
      A[i] &amp;lt;= B[i];
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;   var A {1..m, 1..n};
   var B {1..m, 1..n};
   con MyCon {k in 1..n}:
      sum {i in 1..m} A[i,k] * B[i,k] &amp;lt;= 0;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You might also be interested in &lt;A href="https://communities.sas.com/t5/Mathematical-Optimization/Matrix-operators-in-PROC-OPTMODEL/td-p/90545" target="_self"&gt;this post&lt;/A&gt;, which shows how to use PROC FCMP with PROC OPTMODEL to access some matrix routines.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jun 2019 15:25:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Define-constraints-and-optimization-function-in-matrix-form/m-p/566926#M2798</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2019-06-18T15:25:41Z</dc:date>
    </item>
    <item>
      <title>Re: Define constraints and optimization function in matrix form</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Define-constraints-and-optimization-function-in-matrix-form/m-p/568727#M2799</link>
      <description>Thanks a lot, it really helped!</description>
      <pubDate>Tue, 25 Jun 2019 12:43:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Define-constraints-and-optimization-function-in-matrix-form/m-p/568727#M2799</guid>
      <dc:creator>Edoedoedo</dc:creator>
      <dc:date>2019-06-25T12:43:12Z</dc:date>
    </item>
  </channel>
</rss>

