Post Reply 
Simplex method in prime how to use the constrains maximise s.t. constraints.
11-11-2023, 04:03 PM
Post: #47
RE: Simplex method in prime how to use the constrains maximise s.t. constraints.
(11-11-2023 12:39 PM)Albert Chan Wrote:  > m2 := transpose(col(m,3 .. 0))
> simplex_le(transpose(m2, -∞)

\([-18.5714285714,[0,0,0],\left(\begin{array}{cccc}
0 & 1.0 & 0.142857142857 & 2.14285714286 \\
1.0 & 0.0 & 1.57142857143 & 3.57142857143 \\
0 & 0 & 3.57142857143 & 18.5714285714
\end{array}\right) ]\)

There is simplex() bug (or, HP Prime bug?) returning all zeroes for variables.

I mistakenly use DELCOL instead of delcols, CONCAT instead of extend ...
Still, even with float, getting all 0's for variables are weird.

Now, we get the right output:

\(\displaystyle [
\frac{-130}{7},[\frac{25}{7},\frac{15}{7},0],\left(\begin{array}{cccc}
0 & 1 & \frac{1}{7} & \frac{15}{7} \\
1 & 0 & \frac{11}{7} & \frac{25}{7} \\
0 & 0 & \frac{25}{7} & \frac{130}{7}
\end{array}\right)]\)

Latest update:
Code:
simplex_le(a, dir) :=
BEGIN
 LOCAL b := dim(a);
 a := transpose(extend(
    [col(a,1 .. b(2)-1)],
    [col(identity(b(1)),1 .. b(1)-1)],
    [col(a,b(2))]
 ));
 IF dir>0 THEN a[0] := -a[0] END /* maximize */
 a := simplex(a);
 IF dir>0 THEN a[1] := -a[1] END /* undo flip */
 return a;
END;
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Simplex method in prime how to use the constrains maximise s.t. constraints. - Albert Chan - 11-11-2023 04:03 PM



User(s) browsing this thread: 1 Guest(s)