<?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: Problem related to linear programming, when the supply and demand exchange, the code doesn't wor in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Problem-related-to-linear-programming-when-the-supply-and-demand/m-p/814672#M5817</link>
    <description>&lt;P&gt;This is not my area of expertise, but I am guessing that you also need to reverse the direction of flow by multiplying the matrix A by -1.&amp;nbsp; The "end;" statement in your code should also be removed as this is generating an error.&lt;/P&gt;</description>
    <pubDate>Mon, 23 May 2022 08:49:48 GMT</pubDate>
    <dc:creator>IanWakeling</dc:creator>
    <dc:date>2022-05-23T08:49:48Z</dc:date>
    <item>
      <title>Problem related to linear programming, when the supply and demand exchange, the code doesn't work</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Problem-related-to-linear-programming-when-the-supply-and-demand/m-p/814661#M5816</link>
      <description>&lt;P&gt;The code works perfectly for the first time:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;Proc IML ;
*Define the routes between the nodes;
arcs = { 'AB' 'AC' 'AE' 'BC' 'BD' 'CE' 'CH' 'DE' 'DF' 'EF' 'EH' 'GF' 'GH' }; /* decision variables */
nodes = {'A' 'B' 'C' 'D' 'E' 'F' 'G' 'H'};
*Input the constraint matrix;
A={ 1 1 -1 0 0 0 0 0 0 0 0 0 0,
 -1 0 0 1 1 0 0 0 0 0 0 0 0,
 0 -1 0 1 0 -1 1 0 0 0 0 0 0,
 0 0 0 0 -1 0 0 1 1 0 0 0 0,
 0 0 1 0 0 1 0 0 0 1 -1 0 0,
 0 0 0 0 0 0 0 0 1 -1 0 1 0,
 0 0 0 0 0 0 0 0 0 0 0 -1 1,
 0 0 0 0 0 0 -1 0 0 0 1 0 1};
end;
print 'The constraint matrix of the direction of flows' ;
print A[r=nodes c=arcs l={'The Network Constraint Matrix'}] ;
COST = {28.259407 41.255207 67.664184 39.863161 34.92524 35.860331 41.266789 27.098869 36.723808 23.638669 29.807257 24.900754 42.253725 };
print cost [c=arcs l={'The cost/distance for each internode route'}] ;
*The supply and demand at each node;
supply = { 0 -2 12 -2 -2 0 -3 -3 };
print supply[c=nodes l={'Supply and Demand at each node'}] ;
*Force all demand and supply to even out by making all constraints equalities
operators: 'L' for &amp;lt;=, 'G' for &amp;gt;=, 'E' for =;
ops = j(8,1,'E') ;
cntl = j(1,13,.); /* control vector */
cntl[1] = 1; /* 1 for minimum; -1 for maximum */
call lpsolve(rc, value, x, dual, redcost,cost, A, supply, cntl, ops);
print value[L='Minimum Cost'];
print x[r=arcs L='Optimal Flow'];
quit;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;After I exchange the demand and supply, it doesn't work, which in specific, I change this line of code:&lt;/P&gt;&lt;PRE&gt;supply = { 0 2 -12 2 2 0 3 3 };&lt;/PRE&gt;&lt;P&gt;Based on the graph in description, the transportation can surely work both forward and backwards. I'm not sure whether I have made the correct modifications.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 23 May 2022 04:10:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Problem-related-to-linear-programming-when-the-supply-and-demand/m-p/814661#M5816</guid>
      <dc:creator>InfinityShu</dc:creator>
      <dc:date>2022-05-23T04:10:14Z</dc:date>
    </item>
    <item>
      <title>Re: Problem related to linear programming, when the supply and demand exchange, the code doesn't wor</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Problem-related-to-linear-programming-when-the-supply-and-demand/m-p/814672#M5817</link>
      <description>&lt;P&gt;This is not my area of expertise, but I am guessing that you also need to reverse the direction of flow by multiplying the matrix A by -1.&amp;nbsp; The "end;" statement in your code should also be removed as this is generating an error.&lt;/P&gt;</description>
      <pubDate>Mon, 23 May 2022 08:49:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Problem-related-to-linear-programming-when-the-supply-and-demand/m-p/814672#M5817</guid>
      <dc:creator>IanWakeling</dc:creator>
      <dc:date>2022-05-23T08:49:48Z</dc:date>
    </item>
    <item>
      <title>Re: Problem related to linear programming, when the supply and demand exchange, the code doesn't wor</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Problem-related-to-linear-programming-when-the-supply-and-demand/m-p/814673#M5818</link>
      <description>&lt;P&gt;Thank you so much!!!!! I got the right results after applying your suggestions! You are a lifesaver!!!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 23 May 2022 08:56:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Problem-related-to-linear-programming-when-the-supply-and-demand/m-p/814673#M5818</guid>
      <dc:creator>InfinityShu</dc:creator>
      <dc:date>2022-05-23T08:56:51Z</dc:date>
    </item>
  </channel>
</rss>

