Post Reply 
Simplex method in prime how to use the constrains maximise s.t. constraints.
11-09-2023, 08:02 PM
Post: #35
RE: Simplex method in prime how to use the constrains maximise s.t. constraints.
Sad to hear prime can't recieve lpsolve.

Anthony, you may find this program I wrote to be useful. It can be loaded onto the HP Prime using the Connectivity Kit. But currently it requires you to extract the coefficients into a matrix yourself. When I get around to it I would like to add support for symbolic input, so that you are not required to put it in standard form yourself. I make no guarantee that it is bug free, and there are probably optimizations I can make, but in my experience it works as long as you input the system correctly. On my virtual calculator it seems to always return a solution instantly, but on the physical calculator larger problems may take a few seconds. If it takes more than a few seconds, you may be stuck in an infinite loop and should hit Shift On to stop the program and recheck everything was typed correctly.

Here are 2 example ways to use it for your original problem, but other combinations can produce the same result as well.

Convert the system into standard form:
Example 1: 3 ">=" constraints, so we must subtract a slack variable and add an artificial variable to each row. Because we add artificial variables, we add an extra row to the bottom as shown below. the matrix becomes:

> a:=[[2,4,-1,0,0,1,0,0,22],[3,2,0,-1,0,0,1,0,20],[4,5,0,0,-1,0,0,1,40],[6,5,0,0,0,0,0,0,0],[0,0,0,0,0,1,1,1,0]]

> simplex(a)

[320/7,[20/7,40/7,46/7,0,0],[[0,0,1,6/7,-8/7,46/7],[1,0,0,-5/7,2/7,20/7],[0,1,0,4/7,-3/7,40/7],[0,0,0,10/7,3/7,-320/7]]]

The system has only 2 variables so x1,x2 are the first 2 items from the second item in the list. Thus the min is 320/7 at x1=20/7 and x2=40/7

Example 2: Multiply each ">=" constraint row by -1 to convert to "<=". We now have 3 "<=" constraints, so we only need add a slack variable to each row.

> a:=[[-2,-4,1,0,0,-22],[-3,-2,0,1,0,-20],[-4,-5,0,0,1,-40],[6,5,0,0,0,0]]

> simplex(a)

[320/7,[20/7,40/7,46/7,0,0],[[0,0,1,6/7,-8/7,46/7],[1,0,0,-5/7,2/7,20/7],[0,1,0,4/7,-3/7,40/7],[0,0,0,10/7,3/7,-320/7]]]
Same min.

.hpprgm  simplex.hpprgm (Size: 11.89 KB / Downloads: 10)

- neek
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. - ftneek - 11-09-2023 08:02 PM



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