| We hope you enjoy your visit. You're currently viewing the Ultimate 3D Community as a guest. This means that you can only read posts, but can not create posts or topics by yourself. To be able to post you need to register. Then you can participate in the community active and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free. Join our community! If you are already a member please log in to your account to access all of our features: |
| Linear Programming | |
|---|---|
| Tweet Topic Started: Oct 19 2011, 04:34 PM (213 Views) | |
| DJ-Habana | Oct 19 2011, 04:34 PM Post #1 |
|
C# King
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
I want to create myself a program that would run in commandline that would solve linear programming equations in a text file for example (Input.txt) max z = 3x + 2y 2x + 1y <= 100 1x + 1y <= 80 1x + 0y <= 40 (Output.txt) z= 180.00 x = 20.00 y = 60.00 The solving part I can try on my own but the part where I am struggling is in command line. How would I code to get the program work in cmd just by calling it. Example calling in cmd solve <input> <output> Thats the part I don't understand |
|
| |
![]() |
|
| Reikyrr | Oct 19 2011, 04:46 PM Post #2 |
|
Forum God
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
I believe those are the arguments for the main() function. http://www.cprogramming.com/tutorial/lesson14.html so you'd call it like solve.exe input.txt output.txt I can't say im absolutely sure tho, you may need to use solve.exe -input.txt -output.txt Edited by Reikyrr, Oct 19 2011, 04:53 PM.
|
|
~Inspirational quote~ | |
![]() |
|
| DJ-Habana | Oct 19 2011, 06:38 PM Post #3 |
|
C# King
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
Thats exactly what I have been looking for, but now it seem that I am gonna need help with the Linear Programming, I need to use the Simplex Algorithm, (O shit) I searched google but no luck, What we've done in class is just simple stuff like: max z = 3x + 2y 2x + 1y <= 100 1x + 1y <= 80 Step 2 : 2x + 1y + S1 <= 100 1x + 1y + S2 <= 80 ![]() (Error : The empty spot in G is 30) But now the problem is there is a third line 1x + 0y <= 40 I am guessing that it would then be 2x + 1y + S1 <= 100 1x + 1y + S2 <= 80 1x + 0y + S3 <= 40 But how does the table look like then ![]() EDIT : Uploaded a picture of the table Edited by DJ-Habana, Oct 19 2011, 06:43 PM.
|
|
| |
![]() |
|
| DJ-Habana | Oct 20 2011, 03:12 PM Post #4 |
|
C# King
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
Guess there is always one subject one cannot pass at university I'm gonna fail tomorrows test and this Project well Guess I will have to do my very best in order to pass. |
|
| |
![]() |
|
| Sothh | Oct 20 2011, 05:07 PM Post #5 |
|
Shaman Of Time
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
Here the Python code to do it:
|
|
“You can’t outrun Death forever. But you can make the Bastard work for it.” Major Korgo Korgar “Last of The Lancers” - AFC 32 (Andromeda Ascendant Record Database) | |
![]() |
|
| DJ-Habana | Oct 20 2011, 06:17 PM Post #6 |
|
C# King
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
Nice it is somewhere I can start from |
|
| |
![]() |
|
| Sothh | Oct 20 2011, 06:32 PM Post #7 |
|
Shaman Of Time
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
All you need is arguments, and input parsing and it should be ready to go. The code is taken right from the brain of Tressy 2.0, my chat bot. By the way, this can only solve very simple linear equations, such as "2 = 47 - X" Edited by Sothh, Oct 20 2011, 06:33 PM.
|
|
“You can’t outrun Death forever. But you can make the Bastard work for it.” Major Korgo Korgar “Last of The Lancers” - AFC 32 (Andromeda Ascendant Record Database) | |
![]() |
|
| Reikyrr | Oct 20 2011, 08:49 PM Post #8 |
|
Forum God
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
Good luck Found something online too, http://www.indiastudychannel.com/resources/12903-C-Program-solve-linear-equation-variable.aspx Edited by Reikyrr, Oct 20 2011, 08:51 PM.
|
|
~Inspirational quote~ | |
![]() |
|
| DJ-Habana | Oct 20 2011, 10:55 PM Post #9 |
|
C# King
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
I had luck today... I went to my high school maths teacher she explained everything so perfectly for me. This is what I am going to do: Create a class holding a matrice of n elements (rows and collumns) Create an array of this class for each canonical form and follow the steps my teacher gave me. I'll post the Project when I am done if anyone is interested in looking at it
|
|
| |
![]() |
|
| DJ-Habana | Oct 20 2011, 10:57 PM Post #10 |
|
C# King
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
gauss elimination Almost forgot to study that one for tomorrows test. Thanks saved my life broI might not do 90% tomorrow but it wont be less than 60% The project will be perfect ( I Hope ) and next weeks test I will do better with more practice |
|
| |
![]() |
|
| DJ-Habana | Oct 21 2011, 12:19 PM Post #11 |
|
C# King
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
Solve this with linear Programming: Today was test day : 20 Minutes went by, oh wait there is a test to write. 20 Minutes again, I think I am sitting on dynamite. oh wait another 20 Minutes. mmm I look at Question 1: ??????????????????????????????????????????????????????? No luck Skip 80% of the test to Question 2. Yeah!! I can do it.. Wait it raped me in daylight I Love maths!! . . . . . . . . . . Yeah RIGHT!! Go back just do something Can't hand in empty papers like others. There will be a lot of hitting by mothers Please someone wish me luck This test gave a f*ck Answer : Guess how I wrote today |
|
| |
![]() |
|
| « Previous Topic · Basics · Next Topic » |





![]](http://z1.ifrm.com/static/1/pip_r.png)



&jsonp=vglnk_jsonp_13190749029881)

Untitled.png (9.26 KB)

10:20 AM Jul 11