# help with implementation of Linear programming solver.

Show 50 post(s) from this thread on one page
Page 3 of 3 First 123
• September 20th, 2013, 04:59 AM
Paul McKenzie
Re: help with implementation of Linear programming solver.
Quote:

Originally Posted by navy1991
Hello Paul,

The file was created using this Matlab Code it seems : https://github.com/CovertLab/WholeCe.../FbaLPWriter.m

Regards,
Naveen.

If you could alter the Malab code, maybe you can output 3 files, an "Objective function" file, a "Constraints" file, and a "Variable Bounds" file. For example, for the "Variable Bounds" file:
Code:

```Name  <  <=  ==  >  >= Adix    x    x    0    x    x AdPix  x    0    x    x    -5.495024 AHCYSix  x    x    0    x    x AMPix    x    0    x    x    -2.197701 ...```
The first line doesn't go in the file, it is to show you what each column denotes in the input file. The first column is the name of the variable. The <, <=, ==, >, >= are the relevant operations to describing the bounding condition (I used the C++ "==" to denote equal).

So for example, if you take a look at the AdPix variable bounds in your original input file:
Code:

``` ADPix >= -5.495024  ADPix <= 0```
Then the entry in the variable bounds file would be :
Code:

`AdPix  x    0    x    x    -5.495024`
The above is much easier to parse. Note that the "0" is in the <= column, and the "-5.495024" is in the >= column. The "x" means "ignore", no-op, i.e. whatever terminology to mean this operation doesn't apply.

This is just an idea. You need to come with a similar scheme for the maximization and constraints part of the file.

Regards,

Paul McKenzie
• September 20th, 2013, 06:09 AM
navy1991
Re: help with implementation of Linear programming solver.
Hello Paul,
I do not have Matlab software suite. It is not open source too. I have 2 ideas:

1. To build a parser by splitting it(the string or line) and by assigning the values as coeffecients , variables, etc as you have mentioned before.. or

2. to use the Java code in this file : http://sourceforge.net/projects/lpso...solve/5.5.2.0/ and call the functions in c++ (so to create a java API in C++)

Which will be easier? I feel the second one will be easier?

Regards,
Naveen.
• September 20th, 2013, 06:47 AM
2kaud
Re: help with implementation of Linear programming solver.
Quote:

I do not have Matlab software suite.
How, exactly, is this data file produced that you want to parse?
• September 20th, 2013, 06:56 AM
navy1991
Re: help with implementation of Linear programming solver.
Hi 2Kaud,
I want to parse it like the representation shown in this header file:

/*!
\internal

Representation of a LP constraint like:

(c1 * X1) + (c2 * X2) + ... = K
or <= K
or >= K

Where (ci, Xi) are the pairs in "variables" and K the real "constant".
*/

Please have a look at previous posts too : I have described about it

Regards,
Naveen.
• September 20th, 2013, 07:30 AM
2kaud
Re: help with implementation of Linear programming solver.
Yes, I know that you want to parse a data file. I have been following these threads. I asked how this file was produced because in post #28 you say that the file was produced using Matlab code and then in post #32 you say that you don't have Matlab. Is someone producing the data file for you? Have you discussed your parsing requirements with them?

If, as Paul and myself have suggested, you can change the program that produces this data file to produce one in a format more easily parsed, then the task of writing the parser becomes much easier as Paul explained. How is this file produced?

Also, as per posts #25 and #26 have you explored the possibility that a parser for the format of the data file you have may already have been written?
• September 20th, 2013, 07:38 AM
navy1991
Re: help with implementation of Linear programming solver.
Hi 2kaud,
I did not write the code in Matlab. It was written by Jonathan. I am working in a diiferent place but on the same topic : FBA (flux balance analysis) for whole cell model. I am working in a c++ platform to create this FBA solver.

Regards,
Naveen.
• September 20th, 2013, 07:46 AM
navy1991
Re: help with implementation of Linear programming solver.
Attachment 31799 please have a look at this attachment too. It is better to parse as it has whitespace in between. I retrieved it from one of the file formats posted in that website.

Regards,
Naveen.
• September 20th, 2013, 08:04 AM
2kaud
Re: help with implementation of Linear programming solver.
Quote:

Originally Posted by navy1991
Hi 2kaud,
I did not write the code in Matlab. It was written by Jonathan. I am working in a diiferent place but on the same topic : FBA (flux balance analysis) for whole cell model. I am working in a c++ platform to create this FBA solver.

Regards,
Naveen.

It would make your job much easier if you could ask Jonathan to amend his Matlab code to produce an output data file similar in format to that suggested by Paul in post #31.
• September 20th, 2013, 10:13 AM
navy1991
Re: help with implementation of Linear programming solver.
Yes, I will ask him. In the mean time, I downloaded another LP solver : http://docs.oracle.com/javase/1.5.0/...nvocation.html .

It has a source code in Java platform. I want to incorporate this into my c++ program. So, do you think incorporating this java lp solver is better? Or should I stick to the previous one and construct a parser with the new file I posted in post 37 Or wait for jonathan to amend his code like paul has mentioned?

Too many choices , Feeling confused .

Regards,
Naveen.
• September 20th, 2013, 10:35 AM
Paul McKenzie
Re: help with implementation of Linear programming solver.
Quote:

Originally Posted by navy1991
Yes, I will ask him. In the mean time, I downloaded another LP solver : http://docs.oracle.com/javase/1.5.0/...nvocation.html .

Also, if you're looking for a linear programming solver in C++, I would think that it has been done already, with full source code. Do a google search, and I'm sure it has been done.

Regards,

Paul McKenzie
• September 20th, 2013, 10:41 AM
navy1991
Re: help with implementation of Linear programming solver.

It has an implementation in many languages except c++.I was trying to use this one because we have an input file in the same format (lpsolve format).

Anyways, I will search for other c++ LP solvers too.

Regards,
Naveen.
• September 20th, 2013, 10:52 AM
2kaud
Re: help with implementation of Linear programming solver.
Quote:

Originally Posted by navy1991

It has an implementation in many languages except c++.I was trying to use this one because we have an input file in the same format (lpsolve format).

Anyways, I will search for other c++ LP solvers too.

Regards,
Naveen.

As that link provides both an .exe and the source in c and you have an input file in the required format, what's the problem in using LPsolver?
• September 20th, 2013, 10:54 AM
navy1991
Re: help with implementation of Linear programming solver.