1

I want to design a console application (in visual studio 2010 C#) that can read an LP from a textfile and then solve it using the simplex method.

Example of textfile:

"max 4 5"

"9 8 <= 45"

"5 1 <= 29"

"1 7 <= 15"

The numbers represent the coefficients of the decision variables (eg. 6 7 8 will represent 6x1 + 7x2 + 8x3)

It should then write to/create an output file containing the optimal solution and the values of the decision variables.

I was thinking of using a two-dimensional array.

Any thoughts on how to "import" the LP from the textfile to the program and to convert the equations in standard form, ready to be inserted to the 2D array which will act as my tableu.

1 Answers1

1

You are sort of re-inventing the wheel.

The MPS format is a de facto standard.

I personally prefer the CPLEX LP format.

See also the ILOG CPLEX File Formats or the File Formats Reference Manual for other formats.

I know that it seems easy and simple to implement the simplex tableu method. Unless you do it for fun and to learn, I seriously suggest you don't do that.

It takes years and significant experience to implement a production quality simplex method. I would use a simplex solver instead, for example GLPK, SoPlex, Clp or lpsolve.

Ali
  • 56,466
  • 29
  • 168
  • 265
  • Unfortunately I am not allowed to make use of libraries, and I have to make use of the simplex method – user1668047 Sep 13 '12 at 09:21
  • You can still use the standard MPS format. I hope that person, who doesn't allow you to use libraries, knows what it takes to implement a production quality simplex method. What's wrong with the libraries? Some of the libraries do allow commercial applications. – Ali Sep 13 '12 at 09:26
  • This is what I have to do for a project in my first year. Next one will build upon this one implementing the 2 phase method. But if I can get my LP in standard form and in a 2D array I should be able to solve it – user1668047 Sep 13 '12 at 09:30
  • Yes, as I said before, if you do it for fun or to learn from it then it is OK. Just don't be too disappointed if your method breaks down on a real life example. Even the commercial solvers can break down... Good luck anyway! – Ali Sep 13 '12 at 12:25
  • @ali The OP is trying to implement a textbook simplex method as an exercise, not create a product complete with other established solvers. Also, the mps format is specifically designed for a sparse matrices which is likely out of scope. – David Nehme Sep 13 '12 at 20:21
  • @DavidNehme Yes, as I said in the answer, and later in a comment, it is OK to do it if you do it to learn or for fun. It was not clear from the question what his actual goal were (exercise or production). – Ali Sep 13 '12 at 22:08