CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 3 of 3 FirstFirst 123
Results 31 to 44 of 44
  1. #31
    Join Date
    Apr 1999
    Posts
    27,449

    Re: help with implementation of Linear programming solver.

    Quote Originally Posted by navy1991 View Post
    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

  2. #32
    Join Date
    Sep 2013
    Posts
    36

    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.

  3. #33
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,822

    Re: help with implementation of Linear programming solver.

    I do not have Matlab software suite.
    How, exactly, is this data file produced that you want to parse?
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  4. #34
    Join Date
    Sep 2013
    Posts
    36

    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.

  5. #35
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,822

    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?
    Last edited by 2kaud; September 20th, 2013 at 07:33 AM.
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  6. #36
    Join Date
    Sep 2013
    Posts
    36

    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.

  7. #37
    Join Date
    Sep 2013
    Posts
    36

    Re: help with implementation of Linear programming solver.

    newmetabolismcopy.zip 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.

  8. #38
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,822

    Re: help with implementation of Linear programming solver.

    Quote Originally Posted by navy1991 View Post
    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.
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  9. #39
    Join Date
    Sep 2013
    Posts
    36

    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.

  10. #40
    Join Date
    Apr 1999
    Posts
    27,449

    Re: help with implementation of Linear programming solver.

    Quote Originally Posted by navy1991 View Post
    Yes, I will ask him. In the mean time, I downloaded another LP solver : http://docs.oracle.com/javase/1.5.0/...nvocation.html .
    That link doesn't link to an LP solver.

    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

  11. #41
    Join Date
    Sep 2013
    Posts
    36

    Re: help with implementation of Linear programming solver.

    Sorry. This was the link which had the LPsolver : http://sourceforge.net/projects/lpso...solve/5.5.2.0/

    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.

  12. #42
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,822

    Re: help with implementation of Linear programming solver.

    Quote Originally Posted by navy1991 View Post
    Sorry. This was the link which had the LPsolver : http://sourceforge.net/projects/lpso...solve/5.5.2.0/

    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?
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  13. #43
    Join Date
    Sep 2013
    Posts
    36

    Re: help with implementation of Linear programming solver.

    Finally, I have found one. It is called clp : http://www.coin-or.org/download/source/Clp/

    It seems to be very detailed . I will try to implement with this one. If I encounter any problem, I will come back.

    Regards,
    Naveen.

  14. #44
    Join Date
    Sep 2013
    Posts
    36

    Re: help with implementation of Linear programming solver.

    Hello 2Kaud,
    It works perfectly fine. In fact, I solved my problem and got the result. (around 0.02) . At my place, I am trying to build / include a FBA solver in c++ platform (which will be incorporated into another suit). But, I think that the Clp Solver (post 43 ) will be good . It is implemented in c++.

Page 3 of 3 FirstFirst 123

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured