help-glpk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-glpk] Import data from Matlab variables to GLPK/GMPL


From: Nazmul Islam
Subject: Re: [Help-glpk] Import data from Matlab variables to GLPK/GMPL
Date: Sun, 29 Dec 2013 03:45:25 -0500

Hello Reg (& others),

Thanks a lot for your email. 

As a fast step, I want to solve a mixed integer linear program like follows 

min c'x
s.t. Ax <= b, 
lb <= x <= ub
Some variables of x are binary ones.

I have generated A, b, c, lb, ub in Matlab and stored them in .mat format. I have to convert them to GMPL readable format so that I can solve this code using GLPK. I have attached a sample of those files with my email. I will really appreciate if you could tell me how I can convert them using AWK. Please let me know if you want me to send a .mat file with smaller size.

Your help will be very appreciated.

Thanks,

Nazmul


On Fri, Dec 27, 2013 at 3:30 PM, Reginald Beardsley <address@hidden> wrote:
Nazmul,

I suggest you consider using  awk to generate data files in GMPL format from ASCII text (.txt) files if you have very many instances to solve.  You put the problem formulation in one file and the data for each instance in  another file and execute "gplsol -m model.dat -d data.dat".  I've found this works very well solving large numbers of problem instances.  In particular, it makes changing the model very simple.  I can't find out anything about the Guesk editor so I can't comment on setting up GMPL notation data files using that.

I tried using the CSV import facility in GMPL, but found it not very convenient because of restrictions on the CSV format glpk accepts. 

There is a MATLAB binding for GLPK, but I don't know how usable it is.  The MATLAB clone, Octave, also has a built-in binding to GLPK.

http://en.wikibooks.org/wiki/GLPK/Matlab

http://en.wikibooks.org/wiki/GLPK/Octave

http://en.wikibooks.org/wiki/GLPK/Scripting_plus_MathProg

There is a Gnu implementation of awk, gawk, which is standard on Linux systems.  It's also available on Windows.

http://gnuwin32.sourceforge.net/packages/gawk.htm

If you need help with writing an awk script to convert the MATLAB .txt files to GMPL notation send me a small example of the MATLAB .txt file and I'll add an example to the GLPK wiki.

You'll need to figure out how to write a basic GMPL problem first.  A good place to look is in the examples directory at cf12a.mod which implements an L1 line fit.  I solve physics inverse  problems by basis pursuit using GMPL notation so I can probably offer some help.  I do problems with 30,000 columns by 50-300 rows.  The resulting files are huge, so you want to get everything working using a small example before doing something that large.  I did some little 10x10 problems to figure out how to set it up.

Reg




--------------------------------------------
On Thu, 12/26/13, Nazmul Islam <address@hidden> wrote:

 Subject: [Help-glpk] Import data from Matlab variables to GLPK/GMPL
 To: address@hidden
 Date: Thursday, December 26, 2013, 8:49 PM

 Hello,
 I want to write my GLPK code through the Guesk
 editor and I am very new to the GNU Math Programming
 Language. 
 I want to import some data from Matlab to my GLPK
 code. I want to run the code with these imported data. The
 data is currently in some variables of Matlab and I can
 store them in some .mat files. Do I need to save all these
 Matlab variables in a single .dat file (or .txt file?) and
 then import to GNU Math Prog language?

 Is there any example that I can
 follow?
 Thanks,
 Nazmul


 -----Inline Attachment Follows-----

 _______________________________________________
 Help-glpk mailing list
 address@hidden
 https://lists.gnu.org/mailman/listinfo/help-glpk




Attachment: A.mat
Description: Binary data

Attachment: b.mat
Description: Binary data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]