[Top][All Lists]

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

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

From: Jeffrey Kantor
Subject: Re: [Help-glpk] Import data from Matlab variables to GLPK/GMPL
Date: Fri, 27 Dec 2013 17:42:01 -0500

You  can find a number of GMPL/Mathprog examples under the examples menu at

Reg's points are on the money.  Managing mathprog models out of Matlab is doable, but a bit painful.  Depending on your needs,  you may find yalmip or cvx better integrated with the matlab environment.



On Friday, December 27, 2013, Reginald Beardsley wrote:

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.

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

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.


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

 I want to write my GLPK code through the Guesk
 editor and I am very new to the GNU Math Programming
 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

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

 Help-glpk mailing list

Help-glpk mailing list

reply via email to

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