Simplex Method updated to V20.13 (cas mode) - Printable Version +- HP Forums (http://www.hpmuseum.org/forum) +-- Forum: HP Software Libraries (/forum-10.html) +--- Forum: HP Prime Software Library (/forum-15.html) +--- Thread: Simplex Method updated to V20.13 (cas mode) (/thread-5281.html) |
Simplex Method updated to V20.13 (cas mode) - cclinus - 12-05-2015 10:30 PM Update note: Updated: 2016-12-17 sim20_13 : If there are infinitely many solutions, program will try to choose the smallest value. Updated: 2016-12-9 sim20_11 : user definable variables name when importing data from Spreadsheet. Use of argument: sim20(0) : new input, no previous data. sim20(1) : Load previous data. sim20(2),sim20(3).... : Load and save data to "2","3"..... sim20(99) : Import data from spreadsheet. Features: 1)Solve linear programming problem by simplex method. 2)Provide pure integer solution. 3)Provide Mixed integer, continuous and binary solution. (Read POST#6) 4)Save and reload data (Read POST#6) 5)Set target Z value (Read POST#6) 6)Import data from spreadsheet. (Read POST#10) 7)User definable variables name. (Read POST#11) Hello, Simplex program is updated to v20. First of all, try this example: Type sim20(0) in CAS mode. Max X1 + 0.64X2 s.t. 50X1 + 31X2 <= 250 3X1 - 2X2 >= -4 X1 and X2 >=0 integers ![]() Generally speaking, B&B should be more reliable. But above B&B solution is not optimal. Why? It is because the searching level is not deep enough. Pay attention to Reach Level: 5 ->6, it means the level limit is 5 but the program need to go to level 6 for more searching. So, try to increase Search Level to 10. ![]() Now, the solution is better and the Reach Level is 7. It means the program is stopped at level 7 and no need to go deeper. So, the solution should be optimal. Example to use this program to find shortest path. Set up the equations: ![]() The solution is {1,0,1,0,0,1} Z=6, it means X12->X23->X34 is the shortest path. Note that searching integer algorithm is time consuming, some problem may take one hour to solve. So, be patient. Troubleshooting: A) If you find sim20(0) is not working properly. solution: 1) Delete sim17/18/19 if you have it before. Some function names are same. 2) Check cas variables by pressing [SHIFT] [Mem], then press "CAS Vars" , delete all rubbish function and sim17/18/19 related functions. Then press "Esc". 3) Press [SHIFT][Program],edit sim20_8, press softkey "Check", then "Esc" and "Esc". 4) Type sim20(0) in CAS mode to see whether it is working well. If not, repeat step 2 and 3. B) Running non recursive evaluator ERROR solution: 1) Press [SHIFT][CAS setting], go to page 2, set "Recursive Function" to 100. ![]() C) Get Syntax error when pressing "CHECK" in program editor. solution: Put Spreadsheet App as the current App of calculator. Calculator title bar will show Spreadsheet App name. Then edit and CHECK program again. 1) Mixed Integer Continuous and Binary [0,1] Solution Example: Max: 0.043X1+0.027X2+0.025X3+0.022X4+0.045X5 S.T. X1 + X2 + X3 + X4 + X5 <= 10 X2 + X3 + X4 >= 4 0.6X1+ 0.6X2 - 0.4X3 - 0.4X4 + 3.6X5 <= 0 4X1 + 10X2 - X3 - 2X4 - 3X5 <= 0 X1 is integer, X3 is binary, others are continuous number. Solution = { 3 , 0 , 1 , 5.75 , 0.25 } ![]() 2) Target Z: You can specify a value for Z. Z=no target value, "<=", ">=" or "=" with target value. ![]() 3) Mixed branch and cut method for integer solution. May be I am not program it right, this method seems not reliable. Sometimes it can not provide the optimal solution. B&B is most reliable. 4) Allow re-edit and save data. This program use argument to save and reload data. sim19(0): "0" zero, for clean input, no previous data. sim19(1): always reload previous data. sim19(2), sim19(3),sim19(4)....: save equation data into the file"2","3","4"... . type sim19(2) to reload file"2" data. If you want to copy previous data to "4", just type reeditbag(4):=reeditbag(1) in cas mode. This version add import data from spreadsheet. Since INPUT dialog box only allow to have 10 pages input fields at most. If your linear programming problem has many variables and constraints. It will cause invalid input ERROR. So, use spreadsheet as input interface could avoid this error from happen. Below shows the standard format of spreadsheet. ![]() In CAS mode, type sim20(99). Make sure the name of the spreadsheet is on calculator's title bar. ![]() Here are spreadsheet app example: SimA(spreadsheet) has 25 variables with 10 constraints. SimB(spreadsheet) has 2 variables with 2 constraints, just show the standard format. Target Z value place here: ![]() User is allowed to define the variables name when importing data from spreadsheet. Below is an example: Type sim20(99) ![]() Spreadsheet example in SimD Regards, |